@gobing-ai/knowledge-kit 0.1.24 → 0.1.25
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 +302 -59
- 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/daily-stages.ts +500 -33
- package/plugins/kk/scripts/kk-workflow-stages.ts +5 -0
- 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 +5 -3
- package/plugins/kk/skills/news-editorial/references/daily-visual-composition.md +150 -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 +3 -2
- package/plugins/publishings/bilibili-pub/dist/profile-check.js +3 -2
- package/plugins/publishings/cnblogs-pub/dist/index.js +3 -2
- package/plugins/publishings/cnblogs-pub/dist/profile-check.js +3 -2
- package/plugins/publishings/csdn-pub/dist/index.js +3 -2
- package/plugins/publishings/csdn-pub/dist/profile-check.js +3 -2
- package/plugins/publishings/infoq-pub/dist/index.js +3 -2
- package/plugins/publishings/infoq-pub/dist/profile-check.js +3 -2
- package/plugins/publishings/jike-pub/dist/index.js +3 -2
- package/plugins/publishings/jike-pub/dist/profile-check.js +3 -2
- package/plugins/publishings/juejin-pub/dist/index.js +3 -2
- package/plugins/publishings/juejin-pub/dist/profile-check.js +3 -2
- package/plugins/publishings/linkedin-pub/dist/index.js +3 -2
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +3 -2
- package/plugins/publishings/medium-pub/dist/index.js +9198 -279
- package/plugins/publishings/medium-pub/dist/profile-check.js +21174 -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 +6 -3
- package/plugins/publishings/shipinhao-pub/dist/profile-check.js +5 -3
- 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 +3 -2
- package/plugins/publishings/sspai-pub/dist/profile-check.js +3 -2
- package/plugins/publishings/substack-pub/dist/index.js +3 -2
- package/plugins/publishings/substack-pub/dist/profile-check.js +3 -2
- package/plugins/publishings/threads-pub/dist/index.js +3 -2
- package/plugins/publishings/threads-pub/dist/profile-check.js +3 -2
- package/plugins/publishings/wechatmp-pub/dist/index.js +262 -42
- package/plugins/publishings/wechatmp-pub/dist/profile-check.js +3 -2
- package/plugins/publishings/wechatmp-pub/src/flow.ts +447 -53
- package/plugins/publishings/wechatmp-pub/src/index.ts +4 -1
- package/plugins/publishings/wechatmp-pub/src/page.ts +8 -0
- package/plugins/publishings/weibo-pub/dist/index.js +3 -2
- package/plugins/publishings/weibo-pub/dist/profile-check.js +3 -2
- package/plugins/publishings/x-pub/dist/index.js +3 -2
- package/plugins/publishings/x-pub/dist/profile-check.js +3 -2
- package/plugins/publishings/xhs-pub/dist/index.js +3 -2
- package/plugins/publishings/xhs-pub/dist/profile-check.js +3 -2
- package/plugins/publishings/xiaoyuzhou-pub/dist/index.js +3 -2
- package/plugins/publishings/xiaoyuzhou-pub/dist/profile-check.js +3 -2
package/dist/index.js
CHANGED
|
@@ -38318,7 +38318,8 @@ async function busyGuidance(fileSystem, leaseDir) {
|
|
|
38318
38318
|
}
|
|
38319
38319
|
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
38320
|
}
|
|
38321
|
-
|
|
38321
|
+
const suffix = 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 \u2014 confirm no browser for this profile is open, then remove the stale lease with: rm -rf ${leaseDir}`;
|
|
38322
|
+
return `browser lease ${leaseDir} is held by pid ${owner.pid} (logical ${owner.logicalPath}) \u2014 ${suffix}`;
|
|
38322
38323
|
}
|
|
38323
38324
|
async function holderResidue(fileSystem, leaseDir) {
|
|
38324
38325
|
try {
|
|
@@ -38930,6 +38931,7 @@ __export(exports_browser, {
|
|
|
38930
38931
|
createExclusiveFile: () => createExclusiveFile,
|
|
38931
38932
|
createKkBrowserLauncher: () => createKkBrowserLauncher,
|
|
38932
38933
|
createShadowFinder: () => createShadowFinder,
|
|
38934
|
+
ensureProfileDir: () => ensureProfileDir2,
|
|
38933
38935
|
enterDelegatedLease: () => enterDelegatedLease,
|
|
38934
38936
|
execBot: () => execBot,
|
|
38935
38937
|
execFailureDetail: () => execFailureDetail,
|
|
@@ -38938,6 +38940,7 @@ __export(exports_browser, {
|
|
|
38938
38940
|
findLeftoverTransaction: () => findLeftoverTransaction,
|
|
38939
38941
|
findShadowControl: () => findShadowControl,
|
|
38940
38942
|
injectBrowserAntiDetection: () => injectBrowserAntiDetection,
|
|
38943
|
+
isProcessAlive: () => isProcessAlive,
|
|
38941
38944
|
isSafeBotName: () => isSafeBotName,
|
|
38942
38945
|
isSessionFactDate: () => isSessionFactDate,
|
|
38943
38946
|
isSessionFactIdentity: () => isSessionFactIdentity,
|
|
@@ -38965,6 +38968,7 @@ __export(exports_browser, {
|
|
|
38965
38968
|
resolveSelector: () => resolveSelector,
|
|
38966
38969
|
rmdir: () => rmdir,
|
|
38967
38970
|
runProfileCli: () => runProfileCli,
|
|
38971
|
+
signalSafeRelease: () => signalSafeRelease,
|
|
38968
38972
|
uploadFile: () => uploadFile,
|
|
38969
38973
|
validateExecUrl: () => validateExecUrl,
|
|
38970
38974
|
verifyLeaseHeld: () => verifyLeaseHeld,
|
|
@@ -39090,7 +39094,7 @@ function resolveChannelProfileDir(channel, override) {
|
|
|
39090
39094
|
return resolveBrowserProfileDir(channel, chosen);
|
|
39091
39095
|
}
|
|
39092
39096
|
async function checkChannelSession(config, opts) {
|
|
39093
|
-
const timeoutMs = opts.timeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
39097
|
+
const timeoutMs = opts.timeoutMs ?? config.checkTimeoutMs ?? DEFAULT_CHECK_TIMEOUT_MS;
|
|
39094
39098
|
const passes = opts.headedOnly ? [false] : opts.headedFallback === false ? [true] : [true, false];
|
|
39095
39099
|
let lastDetail = `${config.channel} readiness was never probed`;
|
|
39096
39100
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -39449,16 +39453,67 @@ async function readIdentityOrUndefined(readIdentity, page) {
|
|
|
39449
39453
|
return;
|
|
39450
39454
|
}
|
|
39451
39455
|
}
|
|
39456
|
+
function signalSafeRelease(options) {
|
|
39457
|
+
const sigintBefore = new Set(process.listeners("SIGINT"));
|
|
39458
|
+
let releasing;
|
|
39459
|
+
const release = (signal) => {
|
|
39460
|
+
releasing ??= (async () => {
|
|
39461
|
+
await options.close().catch(() => {});
|
|
39462
|
+
await options.release().catch((error) => {
|
|
39463
|
+
echoError(`kk: releasing the profile lease after ${signal ?? "shutdown"} failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
39464
|
+
});
|
|
39465
|
+
if (signal !== undefined)
|
|
39466
|
+
process.exit(signal === "SIGINT" ? 130 : 143);
|
|
39467
|
+
})();
|
|
39468
|
+
return releasing;
|
|
39469
|
+
};
|
|
39470
|
+
const onSigint = () => void release("SIGINT");
|
|
39471
|
+
const onSigterm = () => void release("SIGTERM");
|
|
39472
|
+
process.once("SIGINT", onSigint);
|
|
39473
|
+
process.once("SIGTERM", onSigterm);
|
|
39474
|
+
return {
|
|
39475
|
+
park: () => {
|
|
39476
|
+
const parked = process.listeners("SIGINT").filter((listener) => !sigintBefore.has(listener) && listener !== onSigint);
|
|
39477
|
+
for (const listener of parked)
|
|
39478
|
+
process.off("SIGINT", listener);
|
|
39479
|
+
return () => {
|
|
39480
|
+
for (const listener of parked)
|
|
39481
|
+
process.on("SIGINT", listener);
|
|
39482
|
+
};
|
|
39483
|
+
},
|
|
39484
|
+
shutdown: async (signal) => {
|
|
39485
|
+
process.off("SIGINT", onSigint);
|
|
39486
|
+
process.off("SIGTERM", onSigterm);
|
|
39487
|
+
await release(signal);
|
|
39488
|
+
}
|
|
39489
|
+
};
|
|
39490
|
+
}
|
|
39452
39491
|
async function loginBot(name, url, options = {}) {
|
|
39453
39492
|
assertSafeBotName(name);
|
|
39454
39493
|
const defaultUrl = normalizeBotDefaultUrl(url);
|
|
39455
39494
|
const navigationUrl = url.trim();
|
|
39456
39495
|
const fileSystem = options.fileSystem ?? createNodeFileSystem();
|
|
39457
39496
|
const profileDir = resolveBotProfileDir(name, { root: options.root });
|
|
39458
|
-
const lease = await acquireProfileLease(profileDir, { leaseRoot: options.leaseRoot, fileSystem });
|
|
39459
39497
|
let transaction;
|
|
39460
39498
|
let context;
|
|
39461
39499
|
let promoting = false;
|
|
39500
|
+
const childAbort = new AbortController;
|
|
39501
|
+
const leaseRef = {};
|
|
39502
|
+
const shutdown = signalSafeRelease({
|
|
39503
|
+
close: async () => {
|
|
39504
|
+
childAbort.abort();
|
|
39505
|
+
await closeBotContext(context);
|
|
39506
|
+
if (!promoting)
|
|
39507
|
+
await transaction?.abort().catch(() => {});
|
|
39508
|
+
},
|
|
39509
|
+
release: () => leaseRef.current?.release() ?? Promise.resolve()
|
|
39510
|
+
});
|
|
39511
|
+
const lease = await acquireProfileLease(profileDir, { leaseRoot: options.leaseRoot, fileSystem }).catch(async (error) => {
|
|
39512
|
+
await shutdown.shutdown();
|
|
39513
|
+
throw error;
|
|
39514
|
+
});
|
|
39515
|
+
leaseRef.current = lease;
|
|
39516
|
+
let unpark;
|
|
39462
39517
|
try {
|
|
39463
39518
|
transaction = await beginBotTransaction({
|
|
39464
39519
|
name,
|
|
@@ -39472,11 +39527,13 @@ async function loginBot(name, url, options = {}) {
|
|
|
39472
39527
|
adapter: options.adapter,
|
|
39473
39528
|
transaction,
|
|
39474
39529
|
lease,
|
|
39475
|
-
fileSystem
|
|
39530
|
+
fileSystem,
|
|
39531
|
+
signal: childAbort.signal
|
|
39476
39532
|
});
|
|
39477
39533
|
}
|
|
39478
39534
|
const launcher = options.launcher ?? createKkBrowserLauncher(undefined, { lease, physicalProfileDir: transaction.stageDir }, { leaseRoot: options.leaseRoot, fileSystem });
|
|
39479
39535
|
context = await launcher.launch({ profileDir: transaction.stageDir, headless: false });
|
|
39536
|
+
unpark = shutdown.park();
|
|
39480
39537
|
const page = await openBotPage(context);
|
|
39481
39538
|
await navigateBot(page, navigationUrl);
|
|
39482
39539
|
await focusBotPage(page);
|
|
@@ -39505,21 +39562,24 @@ async function loginBot(name, url, options = {}) {
|
|
|
39505
39562
|
};
|
|
39506
39563
|
} catch (error) {
|
|
39507
39564
|
await closeBotContext(context);
|
|
39565
|
+
context = undefined;
|
|
39508
39566
|
if (!promoting && transaction !== undefined) {
|
|
39509
39567
|
await transaction.abort().catch(() => {});
|
|
39510
39568
|
}
|
|
39511
39569
|
throw error;
|
|
39512
39570
|
} finally {
|
|
39513
|
-
await
|
|
39571
|
+
await shutdown.shutdown();
|
|
39572
|
+
unpark?.();
|
|
39514
39573
|
}
|
|
39515
39574
|
}
|
|
39516
39575
|
async function runAdapterLogin(name, url, ctx) {
|
|
39517
|
-
const { adapter, transaction, lease, fileSystem } = ctx;
|
|
39576
|
+
const { adapter, transaction, lease, fileSystem, signal } = ctx;
|
|
39518
39577
|
const child = await adapter.run({
|
|
39519
39578
|
mode: "login",
|
|
39520
39579
|
profileDir: transaction.stageDir,
|
|
39521
39580
|
url,
|
|
39522
|
-
env: await lease.delegatedEnv(transaction.stageDir)
|
|
39581
|
+
env: await lease.delegatedEnv(transaction.stageDir),
|
|
39582
|
+
...signal === undefined ? {} : { signal }
|
|
39523
39583
|
});
|
|
39524
39584
|
if (child.exitCode === 2) {
|
|
39525
39585
|
throw new BotError("usage", `session adapter '${adapter.pluginName}' reported a usage error (exit 2) \u2014 nothing was saved`);
|
|
@@ -39599,14 +39659,29 @@ async function openBot(name, options = {}) {
|
|
|
39599
39659
|
if (openUrl === undefined) {
|
|
39600
39660
|
throw missingBotProfile(name, lstat(profileDir) !== null);
|
|
39601
39661
|
}
|
|
39602
|
-
const
|
|
39662
|
+
const leaseRef = {};
|
|
39663
|
+
let context;
|
|
39664
|
+
const childAbort = new AbortController;
|
|
39665
|
+
const shutdown = signalSafeRelease({
|
|
39666
|
+
close: async () => {
|
|
39667
|
+
childAbort.abort();
|
|
39668
|
+
await closeBotContext(context);
|
|
39669
|
+
},
|
|
39670
|
+
release: () => leaseRef.current?.release() ?? Promise.resolve()
|
|
39671
|
+
});
|
|
39672
|
+
const lease = await acquireProfileLease(profileDir, { leaseRoot: options.leaseRoot, fileSystem }).catch(async (error) => {
|
|
39673
|
+
await shutdown.shutdown();
|
|
39674
|
+
throw error;
|
|
39675
|
+
});
|
|
39676
|
+
leaseRef.current = lease;
|
|
39603
39677
|
if (options.adapter !== undefined) {
|
|
39604
39678
|
try {
|
|
39605
39679
|
const child = await options.adapter.run({
|
|
39606
39680
|
mode: "open",
|
|
39607
39681
|
profileDir,
|
|
39608
39682
|
url: openUrl,
|
|
39609
|
-
env: await lease.delegatedEnv(profileDir)
|
|
39683
|
+
env: await lease.delegatedEnv(profileDir),
|
|
39684
|
+
signal: childAbort.signal
|
|
39610
39685
|
});
|
|
39611
39686
|
if (child.exitCode === 2) {
|
|
39612
39687
|
throw new BotError("usage", `session adapter '${options.adapter.pluginName}' reported a usage error (exit 2)`);
|
|
@@ -39620,13 +39695,14 @@ async function openBot(name, options = {}) {
|
|
|
39620
39695
|
message: `closed the local session for bot '${name}' \u2014 the saved profile is unchanged`
|
|
39621
39696
|
};
|
|
39622
39697
|
} finally {
|
|
39623
|
-
await
|
|
39698
|
+
await shutdown.shutdown();
|
|
39624
39699
|
}
|
|
39625
39700
|
}
|
|
39626
|
-
let
|
|
39701
|
+
let unpark;
|
|
39627
39702
|
try {
|
|
39628
39703
|
const launcher = options.launcher ?? createKkBrowserLauncher(undefined, { lease, physicalProfileDir: profileDir }, { leaseRoot: options.leaseRoot, fileSystem });
|
|
39629
39704
|
context = await launcher.launch({ profileDir, headless: false });
|
|
39705
|
+
unpark = shutdown.park();
|
|
39630
39706
|
const closed = new Promise((resolveClose) => {
|
|
39631
39707
|
context?.once("close", () => resolveClose());
|
|
39632
39708
|
});
|
|
@@ -39641,9 +39717,11 @@ async function openBot(name, options = {}) {
|
|
|
39641
39717
|
};
|
|
39642
39718
|
} catch (error) {
|
|
39643
39719
|
await closeBotContext(context);
|
|
39720
|
+
context = undefined;
|
|
39644
39721
|
throw error;
|
|
39645
39722
|
} finally {
|
|
39646
|
-
await
|
|
39723
|
+
await shutdown.shutdown();
|
|
39724
|
+
unpark?.();
|
|
39647
39725
|
}
|
|
39648
39726
|
}
|
|
39649
39727
|
async function execBot(name, request, options = {}) {
|
|
@@ -39853,6 +39931,7 @@ var init_browser = __esm(() => {
|
|
|
39853
39931
|
init_bot_transaction();
|
|
39854
39932
|
init_src();
|
|
39855
39933
|
init_profile_dir2();
|
|
39934
|
+
init_profile_dir2();
|
|
39856
39935
|
init_profile_lease();
|
|
39857
39936
|
init_browser_anti_detection();
|
|
39858
39937
|
init_bot();
|
|
@@ -41072,6 +41151,7 @@ async function replayBotSession(bot, transcript, options) {
|
|
|
41072
41151
|
return { bot, rows, stoppedBeforeSubmit: false };
|
|
41073
41152
|
}
|
|
41074
41153
|
async function replayBot(bot, transcript, options = {}) {
|
|
41154
|
+
await Promise.resolve().then(() => init_browser());
|
|
41075
41155
|
await Promise.resolve().then(() => init_browser());
|
|
41076
41156
|
const { mkdirSync } = await import("fs");
|
|
41077
41157
|
const { join } = await import("path");
|
|
@@ -41080,11 +41160,22 @@ async function replayBot(bot, transcript, options = {}) {
|
|
|
41080
41160
|
const profileDir = resolveBotProfileDir(bot, { root: options.root });
|
|
41081
41161
|
const outDir = options.outDir ?? join(".spur", "run", `bot-replay-${bot}`);
|
|
41082
41162
|
mkdirSync(outDir, { recursive: true });
|
|
41083
|
-
const lease = await acquireProfileLease(profileDir, { leaseRoot: options.leaseRoot, fileSystem });
|
|
41084
41163
|
let context;
|
|
41164
|
+
const leaseRef = {};
|
|
41165
|
+
const shutdown = signalSafeRelease({
|
|
41166
|
+
close: () => closeBotContext(context),
|
|
41167
|
+
release: () => leaseRef.current?.release() ?? Promise.resolve()
|
|
41168
|
+
});
|
|
41169
|
+
const lease = await acquireProfileLease(profileDir, { leaseRoot: options.leaseRoot, fileSystem }).catch(async (error) => {
|
|
41170
|
+
await shutdown.shutdown();
|
|
41171
|
+
throw error;
|
|
41172
|
+
});
|
|
41173
|
+
leaseRef.current = lease;
|
|
41174
|
+
let unpark;
|
|
41085
41175
|
try {
|
|
41086
41176
|
const launcher = options.launcher ?? createKkBrowserLauncher(undefined, { lease, physicalProfileDir: profileDir }, { leaseRoot: options.leaseRoot, fileSystem });
|
|
41087
41177
|
context = await launcher.launch({ profileDir, headless: false });
|
|
41178
|
+
unpark = shutdown.park();
|
|
41088
41179
|
const page = await openBotPage(context);
|
|
41089
41180
|
const shots = [];
|
|
41090
41181
|
const result = await replayBotSession(bot, transcript, {
|
|
@@ -41104,8 +41195,8 @@ async function replayBot(bot, transcript, options = {}) {
|
|
|
41104
41195
|
`);
|
|
41105
41196
|
return { result, outDir, replayPath };
|
|
41106
41197
|
} finally {
|
|
41107
|
-
await
|
|
41108
|
-
|
|
41198
|
+
await shutdown.shutdown();
|
|
41199
|
+
unpark?.();
|
|
41109
41200
|
}
|
|
41110
41201
|
}
|
|
41111
41202
|
var UNREACHABLE = '[aria-hidden="true"], [inert]';
|
|
@@ -44013,7 +44104,8 @@ async function spawnPluginSession(opts) {
|
|
|
44013
44104
|
env: pluginEntryEnv(opts),
|
|
44014
44105
|
stdin: "inherit",
|
|
44015
44106
|
stdout: "pipe",
|
|
44016
|
-
stderr: "inherit"
|
|
44107
|
+
stderr: "inherit",
|
|
44108
|
+
...opts.signal === undefined ? {} : { signal: opts.signal }
|
|
44017
44109
|
});
|
|
44018
44110
|
} catch {
|
|
44019
44111
|
return null;
|
|
@@ -49519,13 +49611,20 @@ async function sendRows(options) {
|
|
|
49519
49611
|
if (retry) {
|
|
49520
49612
|
if (!await fs.exists(targetReceiptPath))
|
|
49521
49613
|
continue;
|
|
49614
|
+
let priorRetry;
|
|
49522
49615
|
try {
|
|
49523
|
-
|
|
49524
|
-
if (priorReceipt.status === "succeeded" || priorReceipt.effect !== "none")
|
|
49525
|
-
continue;
|
|
49616
|
+
priorRetry = JSON.parse(await fs.readFile(targetReceiptPath));
|
|
49526
49617
|
} catch {
|
|
49527
49618
|
continue;
|
|
49528
49619
|
}
|
|
49620
|
+
if (priorRetry.status === "succeeded")
|
|
49621
|
+
continue;
|
|
49622
|
+
if (priorRetry.effect !== "none") {
|
|
49623
|
+
const unknownEffect = (priorRetry.status === "uncertain" || priorRetry.effect === "unknown") && (row.mode === "live" || priorRetry.mode === "live");
|
|
49624
|
+
if (!unknownEffect || options.confirmNone !== true)
|
|
49625
|
+
continue;
|
|
49626
|
+
echoError(`${label}: ${row.key} re-attempted on the operator's confirmation that the unknown-effect attempt published nothing (--confirm-none)`);
|
|
49627
|
+
}
|
|
49529
49628
|
reattempt = true;
|
|
49530
49629
|
} else if (await fs.exists(targetReceiptPath)) {
|
|
49531
49630
|
const priorRaw = await fs.exists(targetReceiptPath) ? await fs.readFile(targetReceiptPath) : undefined;
|
|
@@ -50108,7 +50207,7 @@ class UnknownChannelModeError extends Error {
|
|
|
50108
50207
|
}
|
|
50109
50208
|
}
|
|
50110
50209
|
function targetMatchesChannel(target, token) {
|
|
50111
|
-
return target.plugin === token || target.id === token || target.variant !== undefined && `${target.plugin}/${target.variant}` === token;
|
|
50210
|
+
return target.plugin === token || target.id === token || targetId(target) === token || target.variant !== undefined && `${target.plugin}/${target.variant}` === token;
|
|
50112
50211
|
}
|
|
50113
50212
|
function validatePublishChannelTokens(preset, tokens) {
|
|
50114
50213
|
for (const token of tokens) {
|
|
@@ -50336,7 +50435,7 @@ async function composePlan(fs, input) {
|
|
|
50336
50435
|
throw new Error(`channel '${liveToken}' is dummy-only and cannot be promoted to live`);
|
|
50337
50436
|
}
|
|
50338
50437
|
const mode = input.dummy ? "dummy" : liveToken !== undefined || target.mode === "live" ? "live" : target.mode === "dummy" ? "dummy" : "draft";
|
|
50339
|
-
if (mode === "live" && safety === undefined) {
|
|
50438
|
+
if (mode === "live" && safety === undefined && bundle.contentType === "news") {
|
|
50340
50439
|
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
50440
|
}
|
|
50342
50441
|
if (target.variant === undefined) {
|
|
@@ -50371,7 +50470,17 @@ async function composePlan(fs, input) {
|
|
|
50371
50470
|
delete inherited.publishStatus;
|
|
50372
50471
|
delete inherited.published;
|
|
50373
50472
|
delete inherited.status;
|
|
50374
|
-
const nativeMode = mode === "live" ? {
|
|
50473
|
+
const nativeMode = mode === "live" ? {
|
|
50474
|
+
"surfdash-pub": { published: true },
|
|
50475
|
+
"podcast-pub": { status: "published" },
|
|
50476
|
+
"qiita-pub": { private: false, published: true },
|
|
50477
|
+
"zenn-pub": { published: true }
|
|
50478
|
+
} : {
|
|
50479
|
+
"surfdash-pub": { published: false },
|
|
50480
|
+
"podcast-pub": { status: "unpublished" },
|
|
50481
|
+
"qiita-pub": { private: true, published: false },
|
|
50482
|
+
"zenn-pub": { published: false }
|
|
50483
|
+
};
|
|
50375
50484
|
const payload = {
|
|
50376
50485
|
...parsedContent.data,
|
|
50377
50486
|
metadata: {
|
|
@@ -50384,6 +50493,7 @@ async function composePlan(fs, input) {
|
|
|
50384
50493
|
const payloadRelative = `4-publish/payloads/content.${id}.json`;
|
|
50385
50494
|
const payloadText = `${JSON.stringify(payload, null, 2)}
|
|
50386
50495
|
`;
|
|
50496
|
+
const explicitlySelected = mode !== "dummy" && (liveToken !== undefined || input.channels.some((token) => matches(target, token)));
|
|
50387
50497
|
rows.push({
|
|
50388
50498
|
id,
|
|
50389
50499
|
plugin: target.plugin,
|
|
@@ -50392,7 +50502,7 @@ async function composePlan(fs, input) {
|
|
|
50392
50502
|
tier: target.tier ?? 3,
|
|
50393
50503
|
window: input.window,
|
|
50394
50504
|
mode,
|
|
50395
|
-
required: target.required ?? false,
|
|
50505
|
+
required: (target.required ?? false) || explicitlySelected,
|
|
50396
50506
|
approval: mode === "live" ? "required" : "none",
|
|
50397
50507
|
status: "planned",
|
|
50398
50508
|
...target.transport !== undefined ? { transport: target.transport } : {},
|
|
@@ -53659,7 +53769,8 @@ function bindAdapterSession(candidate) {
|
|
|
53659
53769
|
url: request.url,
|
|
53660
53770
|
extraEnv: request.env,
|
|
53661
53771
|
pluginKind: record.kind,
|
|
53662
|
-
pluginName: record.name
|
|
53772
|
+
pluginName: record.name,
|
|
53773
|
+
...request.signal === undefined ? {} : { signal: request.signal }
|
|
53663
53774
|
});
|
|
53664
53775
|
}
|
|
53665
53776
|
};
|
|
@@ -56676,10 +56787,14 @@ async function validatePreset(fs, presetName, variants) {
|
|
|
56676
56787
|
}
|
|
56677
56788
|
async function runFreezeStage(input, fs) {
|
|
56678
56789
|
const bundlePath = join28(input.workDir, PUBLISH_DIR, "bundle.json");
|
|
56679
|
-
const
|
|
56680
|
-
|
|
56681
|
-
|
|
56682
|
-
|
|
56790
|
+
const request = await readJson3(fs, join28(input.workDir, REQUEST_FILE));
|
|
56791
|
+
const seededFromFile = typeof request?.from === "string" && request.from.trim() !== "";
|
|
56792
|
+
if (!seededFromFile) {
|
|
56793
|
+
const completed = await deps.runItc(["itc-author-complete", input.workDir, input.runId]);
|
|
56794
|
+
if (completed !== 0) {
|
|
56795
|
+
echoError(`kk generate-bundle: itc-author-complete failed (exit ${completed}) for ${input.workDir}`);
|
|
56796
|
+
return 1;
|
|
56797
|
+
}
|
|
56683
56798
|
}
|
|
56684
56799
|
const content = await readJson3(fs, join28(input.workDir, PUBLISH_DIR, CONTENT_FILE));
|
|
56685
56800
|
if (content === null) {
|
|
@@ -56691,13 +56806,23 @@ async function runFreezeStage(input, fs) {
|
|
|
56691
56806
|
echoError(`kk generate-bundle: ${join28(input.workDir, PUBLISH_DIR, CONTENT_FILE)} has no title; the draft's H1 is the bundle title`);
|
|
56692
56807
|
return 1;
|
|
56693
56808
|
}
|
|
56694
|
-
const sourceLocale = typeof content.sourceLocale === "string" ? content.sourceLocale : "en";
|
|
56809
|
+
const sourceLocale = typeof content.sourceLocale === "string" ? content.sourceLocale : typeof request?.locale === "string" ? request.locale : "en";
|
|
56695
56810
|
const variants = {};
|
|
56696
56811
|
for (const [key, variant] of Object.entries(generationVariants(content))) {
|
|
56697
56812
|
if (!variant.adapt)
|
|
56698
56813
|
continue;
|
|
56699
56814
|
variants[key] = await variantEntry(fs, input.workDir, variant.file);
|
|
56700
56815
|
}
|
|
56816
|
+
if (isObject3(request?.variants)) {
|
|
56817
|
+
for (const name of Object.keys(request.variants)) {
|
|
56818
|
+
if (variants[name] !== undefined)
|
|
56819
|
+
continue;
|
|
56820
|
+
const file = `content.${name}.json`;
|
|
56821
|
+
if (await fs.exists(join28(input.workDir, PUBLISH_DIR, file))) {
|
|
56822
|
+
variants[name] = await variantEntry(fs, input.workDir, file);
|
|
56823
|
+
}
|
|
56824
|
+
}
|
|
56825
|
+
}
|
|
56701
56826
|
const source = await variantEntry(fs, input.workDir, CONTENT_FILE);
|
|
56702
56827
|
variants.article = source;
|
|
56703
56828
|
variants[`${sourceLocale}-article`] = source;
|
|
@@ -57261,7 +57386,20 @@ async function countFiles(ctx, dir, suffix) {
|
|
|
57261
57386
|
const path = join29(ctx.workDir, dir);
|
|
57262
57387
|
if (!await ctx.fs.exists(path))
|
|
57263
57388
|
return 0;
|
|
57264
|
-
|
|
57389
|
+
let count = 0;
|
|
57390
|
+
for (const entry of await ctx.fs.readDir(path)) {
|
|
57391
|
+
if (entry.endsWith(suffix)) {
|
|
57392
|
+
count += 1;
|
|
57393
|
+
continue;
|
|
57394
|
+
}
|
|
57395
|
+
const nested = join29(path, entry);
|
|
57396
|
+
if (!await ctx.fs.exists(nested))
|
|
57397
|
+
continue;
|
|
57398
|
+
try {
|
|
57399
|
+
count += (await ctx.fs.readDir(nested)).filter((child) => child.endsWith(suffix)).length;
|
|
57400
|
+
} catch {}
|
|
57401
|
+
}
|
|
57402
|
+
return count;
|
|
57265
57403
|
}
|
|
57266
57404
|
var newsVariantsStage = (ctx) => ctx.noun === "news" && ctx.bundleStage === "variants";
|
|
57267
57405
|
var GENERATE_ROWS = [
|
|
@@ -57772,7 +57910,7 @@ async function runPreflight(deps, context) {
|
|
|
57772
57910
|
...await diffDirs(deps, join30(context.harnessRoot, "plugins", "kk", "scripts"), join30(install, "plugins", "kk", "scripts"))
|
|
57773
57911
|
];
|
|
57774
57912
|
if (diffs.length > 0) {
|
|
57775
|
-
reasons.push(`checkout diverges from installed kk (${install}): ${diffs.join("; ")}`);
|
|
57913
|
+
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
57914
|
}
|
|
57777
57915
|
}
|
|
57778
57916
|
const target = context.agent === "inline" ? "scribe" : context.agent;
|
|
@@ -58177,7 +58315,8 @@ function validateLiveTokens(preset, window, tokens, presetName) {
|
|
|
58177
58315
|
fail2(5, "kk.content.publish", `cannot validate --live-channels: preset '${presetName}' was not found`);
|
|
58178
58316
|
}
|
|
58179
58317
|
const inWindow = (preset.targets ?? []).filter((target) => (target.window ?? "after-generate") === window);
|
|
58180
|
-
const
|
|
58318
|
+
const computedId = (target) => target.id ?? (target.plugin && target.operation ? `${target.plugin}.${target.operation.trim().replace(/[\s/]+/g, "-")}` : target.plugin);
|
|
58319
|
+
const refused = tokens.filter((token) => !inWindow.some((target) => (target.plugin === token || target.id === token || computedId(target) === token) && (target.mode ?? "draft") !== "off"));
|
|
58181
58320
|
if (refused.length > 0) {
|
|
58182
58321
|
fail2(5, "kk.content.publish", `live token(s) ${refused.join(", ")} have no active row in window '${window}' of preset '${presetName}'`);
|
|
58183
58322
|
}
|
|
@@ -58187,6 +58326,22 @@ async function readPreset(presetName, fs) {
|
|
|
58187
58326
|
const path = join31(root, "plugins", "kk", "publish-presets", `${presetName}.json`);
|
|
58188
58327
|
return await readJson4(fs, path);
|
|
58189
58328
|
}
|
|
58329
|
+
var INLINE_FIGURE_OPERATION = "\u6587\u7AE0";
|
|
58330
|
+
var INLINE_FIGURE_VARIANT = "article";
|
|
58331
|
+
function targetSelectedBy(target, tokens) {
|
|
58332
|
+
return tokens.some((token) => target.plugin === token || target.id === token || target.plugin !== undefined && target.variant !== undefined && `${target.plugin}/${target.variant}` === token);
|
|
58333
|
+
}
|
|
58334
|
+
function inlineFigureRefusal(presetName, targets, channels) {
|
|
58335
|
+
const rows = targets.filter((target) => target.plugin === "wechatmp-pub" && target.operation === INLINE_FIGURE_OPERATION && target.variant === INLINE_FIGURE_VARIANT);
|
|
58336
|
+
const enabled = rows.filter((target) => target.mode !== undefined && target.mode !== "off");
|
|
58337
|
+
if (enabled.length === 0) {
|
|
58338
|
+
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}'`;
|
|
58339
|
+
}
|
|
58340
|
+
if (channels !== undefined && channels.length > 0 && !enabled.some((target) => targetSelectedBy(target, channels))) {
|
|
58341
|
+
return `--inline-illustrations: --channels (${channels.join(", ")}) excludes the wechatmp-pub ${INLINE_FIGURE_OPERATION} (${INLINE_FIGURE_VARIANT}) target, so no article would carry the figures`;
|
|
58342
|
+
}
|
|
58343
|
+
return null;
|
|
58344
|
+
}
|
|
58190
58345
|
async function generateAction(noun, defaultType, options) {
|
|
58191
58346
|
const fs = createNodeFileSystem();
|
|
58192
58347
|
const type = options.type ?? defaultType;
|
|
@@ -58206,7 +58361,21 @@ async function generateAction(noun, defaultType, options) {
|
|
|
58206
58361
|
const workflowPath = await resolveWorkflowPath(resolved.workflow, config, fs);
|
|
58207
58362
|
const channels = channelList(options.channels);
|
|
58208
58363
|
const liveChannels = channelList(options.liveChannels);
|
|
58364
|
+
const packageRoot = await resolvePackageRoot(fs);
|
|
58209
58365
|
const vars = { skill_dir: resolved.skillDir, preset: resolved.publish_preset };
|
|
58366
|
+
if (type === "news")
|
|
58367
|
+
vars.visual_skill_root = join31(packageRoot, "plugins", "kk", "skills");
|
|
58368
|
+
if (options.inlineIllustrations === true) {
|
|
58369
|
+
if (type !== "news") {
|
|
58370
|
+
fail2(2, "kk.content.generate", `'--inline-illustrations' is news-only: the '${type}' workflow declares no inline-figure stage`);
|
|
58371
|
+
}
|
|
58372
|
+
const preset = await readPreset(resolved.publish_preset, fs);
|
|
58373
|
+
const selected = channels === undefined ? undefined : channels.split(",").map((token) => token.trim());
|
|
58374
|
+
const refusal = inlineFigureRefusal(resolved.publish_preset, preset?.targets ?? [], selected);
|
|
58375
|
+
if (refusal !== null)
|
|
58376
|
+
fail2(5, "kk.content.generate", refusal);
|
|
58377
|
+
vars.inline_illustrations = "true";
|
|
58378
|
+
}
|
|
58210
58379
|
if (options.skipReview === true)
|
|
58211
58380
|
vars.skip_review = "true";
|
|
58212
58381
|
if (options.auto === true) {
|
|
@@ -58215,6 +58384,16 @@ async function generateAction(noun, defaultType, options) {
|
|
|
58215
58384
|
}
|
|
58216
58385
|
vars.auto = "true";
|
|
58217
58386
|
}
|
|
58387
|
+
if (options.adaptOnly === true) {
|
|
58388
|
+
if (type !== "itc") {
|
|
58389
|
+
fail2(2, "kk.content.generate", `--adapt-only is article-only: the '${type}' workflow declares no 'adapt_only' var`);
|
|
58390
|
+
}
|
|
58391
|
+
const draftPath = join31(run.workDir, "3-draft-draft-article.md");
|
|
58392
|
+
if (!await fs.exists(draftPath)) {
|
|
58393
|
+
fail2(5, "kk.content.generate", `--adapt-only requires an existing draft at ${draftPath}; seed with \`kk article new --from <file.md>\` first`);
|
|
58394
|
+
}
|
|
58395
|
+
vars.adapt_only = "true";
|
|
58396
|
+
}
|
|
58218
58397
|
const receipt = await launchWorkflow({
|
|
58219
58398
|
type,
|
|
58220
58399
|
workflow: resolved.workflow,
|
|
@@ -58222,7 +58401,7 @@ async function generateAction(noun, defaultType, options) {
|
|
|
58222
58401
|
run: run.run,
|
|
58223
58402
|
workDir: run.workDir,
|
|
58224
58403
|
worksDir,
|
|
58225
|
-
harnessRoot:
|
|
58404
|
+
harnessRoot: packageRoot,
|
|
58226
58405
|
identityVar: type === "news" ? "run_date" : "slug",
|
|
58227
58406
|
vars,
|
|
58228
58407
|
writerSkill: { dir: resolved.skillDir, sha256: resolved.skillSha256 },
|
|
@@ -58315,6 +58494,24 @@ async function publishRun(settings) {
|
|
|
58315
58494
|
}
|
|
58316
58495
|
}
|
|
58317
58496
|
}
|
|
58497
|
+
if (bundle === null && type !== "news" && settings.dryRun !== true) {
|
|
58498
|
+
const request = await readJson4(fs, join31(run.workDir, "request.json"));
|
|
58499
|
+
if (typeof request?.from === "string" && request.from.trim() !== "" && await fs.exists(join31(publishDir, "content.json"))) {
|
|
58500
|
+
const frozen = await runArticleBundle({
|
|
58501
|
+
workDir: run.workDir,
|
|
58502
|
+
type,
|
|
58503
|
+
runId: `kk-content-${run.run}`,
|
|
58504
|
+
preset: presetName,
|
|
58505
|
+
maxRevisions: DEFAULT_MAX_REVISIONS,
|
|
58506
|
+
step: "",
|
|
58507
|
+
bundleStage: "freeze"
|
|
58508
|
+
}, fs);
|
|
58509
|
+
if (frozen.code !== 0) {
|
|
58510
|
+
fail2(5, "kk.content.publish", `failed to freeze seeded article bundle in ${run.workDir}`);
|
|
58511
|
+
}
|
|
58512
|
+
bundle = await readJson4(fs, await resolveBundlePath(fs, run.workDir));
|
|
58513
|
+
}
|
|
58514
|
+
}
|
|
58318
58515
|
if (bundle === null && settings.dryRun !== true) {
|
|
58319
58516
|
fail2(5, "kk.content.publish", `no publishable bundle at ${bundlePath}`);
|
|
58320
58517
|
}
|
|
@@ -58355,6 +58552,7 @@ async function publishRun(settings) {
|
|
|
58355
58552
|
receiptPath,
|
|
58356
58553
|
...settings.agent === undefined ? {} : { agent: settings.agent },
|
|
58357
58554
|
...settings.timeoutMs === undefined ? {} : { timeoutMs: settings.timeoutMs },
|
|
58555
|
+
...settings.allowDirty === undefined ? {} : { allowDirty: settings.allowDirty },
|
|
58358
58556
|
...settings.dryRun === undefined ? {} : { dryRun: settings.dryRun }
|
|
58359
58557
|
});
|
|
58360
58558
|
if (receipt.dryRun === undefined || planned.length === 0)
|
|
@@ -58418,6 +58616,7 @@ async function publishAction(noun, defaultType, options) {
|
|
|
58418
58616
|
...options.retry === undefined ? {} : { retry: options.retry },
|
|
58419
58617
|
...options.agent === undefined ? {} : { agent: options.agent },
|
|
58420
58618
|
...timeoutMs === undefined ? {} : { timeoutMs },
|
|
58619
|
+
...options.allowDirty === undefined ? {} : { allowDirty: options.allowDirty },
|
|
58421
58620
|
...options.dryRun === undefined ? {} : { dryRun: options.dryRun }
|
|
58422
58621
|
});
|
|
58423
58622
|
const code = reportReceipt(receipt);
|
|
@@ -58430,7 +58629,7 @@ function configureGenerate(command, noun, defaultType) {
|
|
|
58430
58629
|
} else {
|
|
58431
58630
|
command.option("--run-date <YYYYMMDD>", "news run date");
|
|
58432
58631
|
}
|
|
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));
|
|
58632
|
+
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
58633
|
}
|
|
58435
58634
|
function configurePublish(command, noun, defaultType) {
|
|
58436
58635
|
if (noun === "article") {
|
|
@@ -58438,7 +58637,7 @@ function configurePublish(command, noun, defaultType) {
|
|
|
58438
58637
|
} else {
|
|
58439
58638
|
command.option("--run-date <YYYYMMDD>", "news run date");
|
|
58440
58639
|
}
|
|
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));
|
|
58640
|
+
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
58641
|
}
|
|
58443
58642
|
function registerContentLaunchVerbs(group, noun, defaultType) {
|
|
58444
58643
|
configureGenerate(group.command("generate").description("launch the generation workflow for a run"), noun, defaultType);
|
|
@@ -58485,6 +58684,13 @@ function commandFailure(command, code, message) {
|
|
|
58485
58684
|
function isOutcomeRows(value) {
|
|
58486
58685
|
return typeof value === "object" && value !== null && Array.isArray(value.rows);
|
|
58487
58686
|
}
|
|
58687
|
+
async function everyPlannedRealRowFailed(fs, workDir, window, rows) {
|
|
58688
|
+
const plan = await readJson5(fs, join32(workDir, "4-publish", `plan.${window}.json`));
|
|
58689
|
+
const planRows = Array.isArray(plan?.rows) ? plan.rows : [];
|
|
58690
|
+
const rehearsalIds = new Set(planRows.filter((row) => row.mode === "dummy").map((row) => String(row.id)));
|
|
58691
|
+
const real = rows.filter((row) => !rehearsalIds.has(String(row.id)) && row.dummy !== true);
|
|
58692
|
+
return real.length > 0 && real.every((row) => row.status !== "succeeded");
|
|
58693
|
+
}
|
|
58488
58694
|
function quietStdout2(action) {
|
|
58489
58695
|
const restore = setDefaultOutputTargets({ stdout: { write() {} } });
|
|
58490
58696
|
return action().finally(restore);
|
|
@@ -58544,6 +58750,9 @@ async function planAction(type, options) {
|
|
|
58544
58750
|
const command = "kk.content.publish-plan";
|
|
58545
58751
|
const fs = createNodeFileSystem();
|
|
58546
58752
|
const context = await loadContext(type, options, command, fs);
|
|
58753
|
+
const stalePlanPath = join32(context.workDir, "4-publish", `plan.${context.window}.json`);
|
|
58754
|
+
if (await fs.exists(stalePlanPath))
|
|
58755
|
+
await fs.deleteFile(stalePlanPath);
|
|
58547
58756
|
const applied = (() => {
|
|
58548
58757
|
try {
|
|
58549
58758
|
validatePublishChannelTokens(context.preset, [
|
|
@@ -58718,7 +58927,7 @@ async function settleAction(type, options) {
|
|
|
58718
58927
|
}
|
|
58719
58928
|
const outcomePath = join32(context.workDir, "4-publish", `outcome.${context.window}.json`);
|
|
58720
58929
|
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");
|
|
58930
|
+
const failedRequired = outcome.rows.some((row) => row.required && !row.dummy && row.status !== "succeeded") || await everyPlannedRealRowFailed(fs, context.workDir, context.window, outcome.rows);
|
|
58722
58931
|
consoleOutput.write(JSON.stringify(outcome));
|
|
58723
58932
|
if (settleCode !== 0 || failedRequired)
|
|
58724
58933
|
throw new CommanderError(1, command, "publish-settle: required targets failed");
|
|
@@ -58777,7 +58986,7 @@ async function reportAction(type, options) {
|
|
|
58777
58986
|
} catch {
|
|
58778
58987
|
return commandFailure(command, 1, `publish-report: ${outcomePath} is unreadable or malformed`);
|
|
58779
58988
|
}
|
|
58780
|
-
const failed = rows.some((row) => row.required === true && row.dummy !== true && row.status !== "succeeded");
|
|
58989
|
+
const failed = rows.some((row) => row.required === true && row.dummy !== true && row.status !== "succeeded") || await everyPlannedRealRowFailed(fs, context.workDir, context.window, rows);
|
|
58781
58990
|
if (failed) {
|
|
58782
58991
|
return commandFailure(command, 1, `publish-report: required targets failed \u2014 see outcome.${context.window}.json and the page`);
|
|
58783
58992
|
}
|
|
@@ -58935,28 +59144,47 @@ function splitMarkdown(markdown, fallbackTitle, titleOverride) {
|
|
|
58935
59144
|
`).trim();
|
|
58936
59145
|
return { title, body };
|
|
58937
59146
|
}
|
|
58938
|
-
async function writeSeededContent(fs, workDir, locale, markdown, options) {
|
|
59147
|
+
async function writeSeededContent(fs, workDir, locale, markdown, options, coverDest, variants) {
|
|
58939
59148
|
const contentDir = join33(workDir, "content", locale);
|
|
58940
59149
|
await fs.ensureDir(contentDir);
|
|
58941
59150
|
await fs.writeFile(join33(contentDir, "article.md"), markdown);
|
|
59151
|
+
await fs.writeFile(join33(workDir, "3-draft-draft-article.md"), markdown);
|
|
58942
59152
|
const fallbackTitle = options.slug?.replaceAll("-", " ") ?? "article";
|
|
58943
59153
|
const article = splitMarkdown(markdown, fallbackTitle, options.title);
|
|
58944
59154
|
if (article.body === "")
|
|
58945
59155
|
fail3(2, "kk.content.new", `source file is empty: ${options.from ?? "(source)"}`);
|
|
59156
|
+
const metadata = {
|
|
59157
|
+
published: false,
|
|
59158
|
+
...parseTags(options.tags) !== undefined ? { tags: parseTags(options.tags) } : {},
|
|
59159
|
+
...options.description !== undefined ? { description: options.description } : {},
|
|
59160
|
+
...coverDest !== undefined ? { coverImage: coverDest } : {}
|
|
59161
|
+
};
|
|
58946
59162
|
const content = {
|
|
58947
59163
|
title: article.title,
|
|
58948
59164
|
format: "markdown",
|
|
58949
59165
|
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
|
-
}
|
|
59166
|
+
metadata
|
|
58955
59167
|
};
|
|
58956
59168
|
const publishDir = join33(workDir, "4-publish");
|
|
58957
59169
|
await fs.ensureDir(publishDir);
|
|
58958
59170
|
await fs.writeFile(join33(publishDir, "content.json"), `${JSON.stringify(content, null, 2)}
|
|
58959
59171
|
`);
|
|
59172
|
+
if (variants !== undefined) {
|
|
59173
|
+
for (const [name, sourcePath] of Object.entries(variants)) {
|
|
59174
|
+
const variantMd = await fs.readFile(sourcePath);
|
|
59175
|
+
const split = splitMarkdown(variantMd, article.title);
|
|
59176
|
+
if (split.body === "")
|
|
59177
|
+
fail3(2, "kk.content.new", `variant file is empty: ${sourcePath}`);
|
|
59178
|
+
const variantContent = {
|
|
59179
|
+
title: split.title,
|
|
59180
|
+
format: "markdown",
|
|
59181
|
+
body: split.body,
|
|
59182
|
+
metadata
|
|
59183
|
+
};
|
|
59184
|
+
await fs.writeFile(join33(publishDir, `content.${name}.json`), `${JSON.stringify(variantContent, null, 2)}
|
|
59185
|
+
`);
|
|
59186
|
+
}
|
|
59187
|
+
}
|
|
58960
59188
|
}
|
|
58961
59189
|
async function seedItcPreparation(fs, workDir, run, options, preset) {
|
|
58962
59190
|
const launchPath = join33(workDir, ".content-itc-prepare.json");
|
|
@@ -59031,13 +59259,16 @@ async function newAction(defaultType, options, article) {
|
|
|
59031
59259
|
await fs.ensureDir(run.workDir);
|
|
59032
59260
|
if (article)
|
|
59033
59261
|
await seedItcPreparation(fs, run.workDir, run, options, resolved.publish_preset);
|
|
59034
|
-
|
|
59035
|
-
await writeSeededContent(fs, run.workDir, locale, await fs.readFile(fromPath), options);
|
|
59262
|
+
let coverDest;
|
|
59036
59263
|
if (options.cover !== undefined) {
|
|
59037
59264
|
const coverPath = resolve26(expandHome4(options.cover));
|
|
59038
59265
|
const coverDir = join33(run.workDir, "4-illustrations");
|
|
59039
59266
|
await fs.ensureDir(coverDir);
|
|
59040
|
-
|
|
59267
|
+
coverDest = join33(coverDir, `cover${extname(coverPath) || ".png"}`);
|
|
59268
|
+
await fs.copy(coverPath, coverDest);
|
|
59269
|
+
}
|
|
59270
|
+
if (fromPath !== undefined) {
|
|
59271
|
+
await writeSeededContent(fs, run.workDir, locale, await fs.readFile(fromPath), options, coverDest, variants);
|
|
59041
59272
|
}
|
|
59042
59273
|
const request = requestObject(type, resolved, run, options, locale, variants, run.workDir);
|
|
59043
59274
|
await fs.writeFile(requestPath, `${JSON.stringify(request, null, 2)}
|
|
@@ -60674,19 +60905,22 @@ var SILENCE_EDGE_TOLERANCE_SECONDS = 0.05;
|
|
|
60674
60905
|
var DEFAULT_SILENCE_NOISE_DB = -50;
|
|
60675
60906
|
var DEFAULT_SILENCE_MIN_SECONDS = 0.5;
|
|
60676
60907
|
var processExecutor = new NodeProcessExecutor;
|
|
60677
|
-
|
|
60678
|
-
|
|
60679
|
-
|
|
60680
|
-
|
|
60681
|
-
|
|
60682
|
-
|
|
60683
|
-
|
|
60684
|
-
|
|
60685
|
-
|
|
60686
|
-
|
|
60687
|
-
|
|
60688
|
-
|
|
60689
|
-
};
|
|
60908
|
+
function createSpawnRunner(executor = processExecutor) {
|
|
60909
|
+
return async (argv) => {
|
|
60910
|
+
const [bin, ...args] = argv;
|
|
60911
|
+
if (bin === undefined) {
|
|
60912
|
+
throw new AudioToolError("ffmpeg", "spawn", "no binary was given to the audio runner", "");
|
|
60913
|
+
}
|
|
60914
|
+
const result = await executor.run({ command: bin, args, label: `audio ${bin}` });
|
|
60915
|
+
if (result.exitCode === null) {
|
|
60916
|
+
const detail = result.stderr.trim();
|
|
60917
|
+
const killed = result.signal === undefined ? "" : ` (killed by ${result.signal})`;
|
|
60918
|
+
throw new AudioToolError(bin, "spawn", `could not be executed${detail === "" ? "" : ` (${detail})`}${killed} \u2014 install ffmpeg or point ffmpegBin/ffprobeBin at it`, "");
|
|
60919
|
+
}
|
|
60920
|
+
return { exitCode: result.exitCode, stdout: result.stdout, stderr: result.stderr };
|
|
60921
|
+
};
|
|
60922
|
+
}
|
|
60923
|
+
var spawnRunner = createSpawnRunner();
|
|
60690
60924
|
function ffprobeArgs(path, bin = DEFAULT_FFPROBE_BIN) {
|
|
60691
60925
|
return [bin, "-v", "error", "-print_format", "json", "-show_format", "-show_streams", path];
|
|
60692
60926
|
}
|
|
@@ -64086,6 +64320,7 @@ async function readLabelItems(items, ids) {
|
|
|
64086
64320
|
title: row.title,
|
|
64087
64321
|
body: row.body,
|
|
64088
64322
|
source: row.source,
|
|
64323
|
+
sourceUri: row.canonicalUrl,
|
|
64089
64324
|
contentHash: row.contentHash,
|
|
64090
64325
|
metadata: parseMetadata(row.metadataJson)
|
|
64091
64326
|
});
|
|
@@ -64139,6 +64374,7 @@ async function heuristicAnnotations(fs, scratch, runId, items) {
|
|
|
64139
64374
|
id: item.id,
|
|
64140
64375
|
title: item.title,
|
|
64141
64376
|
body: item.body,
|
|
64377
|
+
...item.sourceUri === null ? {} : { sourceUri: item.sourceUri },
|
|
64142
64378
|
metadata: item.metadata
|
|
64143
64379
|
}));
|
|
64144
64380
|
await fs.writeFile(inputPath, JSON.stringify(docs));
|
|
@@ -66393,6 +66629,10 @@ async function main2(argv = process.argv, options = {}) {
|
|
|
66393
66629
|
};
|
|
66394
66630
|
inheritSettings(program);
|
|
66395
66631
|
const userArgs = argv.slice(2);
|
|
66632
|
+
const isHelpOrVersion = userArgs.length === 0 || userArgs[0] === "help" || ["--help", "-h", "--version", "-V"].some((flag) => userArgs.includes(flag));
|
|
66633
|
+
const previousExitCode = process.exitCode;
|
|
66634
|
+
if (isHelpOrVersion)
|
|
66635
|
+
process.exitCode = 0;
|
|
66396
66636
|
try {
|
|
66397
66637
|
if (userArgs.length === 0) {
|
|
66398
66638
|
program.help();
|
|
@@ -66407,6 +66647,9 @@ async function main2(argv = process.argv, options = {}) {
|
|
|
66407
66647
|
return err.exitCode;
|
|
66408
66648
|
}
|
|
66409
66649
|
throw err;
|
|
66650
|
+
} finally {
|
|
66651
|
+
if (isHelpOrVersion)
|
|
66652
|
+
process.exitCode = previousExitCode;
|
|
66410
66653
|
}
|
|
66411
66654
|
}
|
|
66412
66655
|
|