@gobing-ai/knowledge-kit 0.1.22 → 0.1.23
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 +165 -91
- package/package.json +1 -1
- package/plugins/generations/gemini-tts/dist/index.js +47 -7
- package/plugins/generations/gemini-tts/src/gemini-client.ts +34 -6
- package/plugins/generations/music-gen/README.md +2 -2
- package/plugins/generations/music-gen/dist/index.js +46 -10
- package/plugins/generations/music-gen/presets/formats/song.yaml +6 -1
- package/plugins/generations/music-gen/presets/themes/synthwave.yaml +6 -1
- package/plugins/generations/music-gen/src/adapter/instance.ts +34 -11
- package/plugins/generations/music-gen/src/presets.ts +36 -3
- package/plugins/generations/omni-voice-gen/uv.toml +5 -0
- package/plugins/generations/vibe-voice-tts/README.md +64 -0
- package/plugins/generations/vibe-voice-tts/dist/index.js +14259 -0
- package/plugins/generations/vibe-voice-tts/package.json +16 -0
- package/plugins/generations/vibe-voice-tts/plugin.json +6 -0
- package/plugins/generations/vibe-voice-tts/profiles.json +10 -0
- package/plugins/generations/vibe-voice-tts/pyproject.toml +9 -0
- package/plugins/generations/vibe-voice-tts/python/worker.py +566 -0
- package/plugins/generations/vibe-voice-tts/src/index.ts +88 -0
- package/plugins/generations/vibe-voice-tts/src/vibevoice-client.ts +828 -0
- package/plugins/generations/vibe-voice-tts/tsconfig.json +8 -0
- package/plugins/generations/vibe-voice-tts/uv.lock +1767 -0
- package/plugins/generations/vibe-voice-tts/uv.toml +4 -0
- package/plugins/generations/voice-gen/dist/index.js +31 -1
- package/plugins/generations/voice-gen/src/voicebox-client.ts +50 -1
- package/plugins/generations/voxcpm-tts/dist/index.js +81 -9
- package/plugins/generations/voxcpm-tts/python/worker.py +9 -0
- package/plugins/generations/voxcpm-tts/src/index.ts +41 -0
- package/plugins/generations/voxcpm-tts/src/voxcpm-client.ts +32 -11
- package/plugins/generations/voxcpm-tts/uv.toml +5 -0
- package/plugins/kk/README.md +21 -0
- package/plugins/kk/decisions/kk-safety.yaml +5 -2
- package/plugins/kk/plugin.json +1 -1
- package/plugins/kk/schedules/kk-serve.launchd.plist.tmpl +12 -1
- package/plugins/kk/scripts/daily-stages.ts +274 -40
- package/plugins/kk/scripts/kk-workflow-stages.ts +74 -11
- package/plugins/kk/scripts/safety-artifact-check.ts +28 -5
- package/plugins/kk/workflows/kk-daily-ai-voice.yaml +4 -3
- package/plugins/kk/workflows/kk-daily-ai-voice2.yaml +6 -5
- package/plugins/kk/workflows/kk-daily-safety.yaml +12 -10
- package/plugins/kk/workflows/kk-music.yaml +20 -16
- package/plugins/kk/workflows/kk-news-generate.yaml +23 -3
- package/plugins/kk/workflows/kk-publish.yaml +4 -1
- package/plugins/publishings/linkedin-pub/dist/index.js +51 -9
- package/plugins/publishings/linkedin-pub/dist/profile-check.js +5 -0
- package/plugins/publishings/linkedin-pub/src/index.ts +99 -12
- package/plugins/publishings/surfdash-pub/dist/index.js +8 -4
- package/plugins/publishings/surfdash-pub/src/index.ts +7 -1
- package/plugins/publishings/surfdash-pub/src/patch.ts +21 -3
- package/plugins/publishings/threads-pub/dist/index.js +47 -5
- package/plugins/publishings/threads-pub/dist/profile-check.js +7 -1
- package/plugins/publishings/threads-pub/src/post-rail.ts +101 -4
- package/plugins/publishings/wechatmp-pub/dist/index.js +94 -34
- package/plugins/publishings/wechatmp-pub/src/cgi-draft.ts +87 -53
- package/plugins/publishings/wechatmp-pub/src/enrich.ts +61 -3
- package/plugins/publishings/wechatmp-pub/src/flow.ts +28 -0
- package/plugins/publishings/x-pub/dist/index.js +84 -9
- package/plugins/publishings/x-pub/src/post-rail.ts +154 -12
package/dist/index.js
CHANGED
|
@@ -44290,7 +44290,7 @@ var FAMILY_SETTINGS = {
|
|
|
44290
44290
|
"kk-daily-ai-voice2": {
|
|
44291
44291
|
window: { kind: "duration" },
|
|
44292
44292
|
language: { kind: "choice", values: ["en", "zh", "ja"] },
|
|
44293
|
-
vdriver: { kind: "choice", values: ["voicebox", "ominivoice", "gemini", "voxcpm"] },
|
|
44293
|
+
vdriver: { kind: "choice", values: ["voicebox", "ominivoice", "gemini", "voxcpm", "vibe-voice", "vibevoice"] },
|
|
44294
44294
|
skip_review: { kind: "boolean" },
|
|
44295
44295
|
transcode_mp3: { kind: "boolean" },
|
|
44296
44296
|
cover_enabled: { kind: "boolean" },
|
|
@@ -56675,8 +56675,14 @@ async function runArticleBundle(input, fs = createNodeFileSystem()) {
|
|
|
56675
56675
|
init_ledger2();
|
|
56676
56676
|
var PARSE_JSON2 = JSON.parse.bind(JSON);
|
|
56677
56677
|
var NEWS_TOPIC = "ai-news";
|
|
56678
|
-
var VOICE_ENGINES = ["voxcpm", "gemini", "omnivoice"];
|
|
56679
|
-
var ENGINE_DRIVERS = {
|
|
56678
|
+
var VOICE_ENGINES = ["voxcpm", "gemini", "omnivoice", "voicebox", "vibe-voice"];
|
|
56679
|
+
var ENGINE_DRIVERS = {
|
|
56680
|
+
voxcpm: "voxcpm",
|
|
56681
|
+
gemini: "gemini",
|
|
56682
|
+
omnivoice: "ominivoice",
|
|
56683
|
+
voicebox: "voicebox",
|
|
56684
|
+
"vibe-voice": "vibe-voice"
|
|
56685
|
+
};
|
|
56680
56686
|
var NEWS_CHECK_STEPS = ["curate", "script"];
|
|
56681
56687
|
var BUNDLE_STAGES = ["variants", "freeze"];
|
|
56682
56688
|
var STORE_SELECT_TIMEOUT_MS = 120000;
|
|
@@ -56991,7 +56997,8 @@ var ARGS = {
|
|
|
56991
56997
|
NEWS_TOPIC,
|
|
56992
56998
|
ctx.settings.window,
|
|
56993
56999
|
String(ctx.settings.episode_min_minutes),
|
|
56994
|
-
ctx.settings.vdriver
|
|
57000
|
+
ctx.settings.vdriver,
|
|
57001
|
+
String(ctx.settings.plan_max_items)
|
|
56995
57002
|
],
|
|
56996
57003
|
plan: (ctx) => [
|
|
56997
57004
|
ctx.workDir,
|
|
@@ -57271,12 +57278,13 @@ var GENERATE_ROWS = [
|
|
|
57271
57278
|
verb: "generate-voice",
|
|
57272
57279
|
stages: [
|
|
57273
57280
|
STEP.generate(),
|
|
57274
|
-
STEP.
|
|
57275
|
-
STEP.
|
|
57276
|
-
STEP.
|
|
57277
|
-
STEP.
|
|
57278
|
-
STEP.
|
|
57279
|
-
STEP.
|
|
57281
|
+
STEP.poolGate(),
|
|
57282
|
+
{ ...STEP.intro(), when: candidatesNonEmpty },
|
|
57283
|
+
{ ...STEP.voiceAudit(), when: candidatesNonEmpty },
|
|
57284
|
+
{ ...STEP.duration(), when: candidatesNonEmpty },
|
|
57285
|
+
{ ...STEP.qualityReport(), when: candidatesNonEmpty },
|
|
57286
|
+
{ ...STEP.qualityVerdict(), when: candidatesNonEmpty },
|
|
57287
|
+
{ ...STEP.showNotes(), when: candidatesNonEmpty }
|
|
57280
57288
|
],
|
|
57281
57289
|
summary: async (ctx) => {
|
|
57282
57290
|
const metadata = await audioMetadata(ctx);
|
|
@@ -58692,6 +58700,13 @@ async function reportAction(type, options) {
|
|
|
58692
58700
|
consoleOutput.error(`publish-report: ledger sync warning: ${error instanceof Error ? error.message : String(error)}`);
|
|
58693
58701
|
}
|
|
58694
58702
|
consoleOutput.write(JSON.stringify({ report: reportPath }));
|
|
58703
|
+
try {
|
|
58704
|
+
const pruneCode = await quietStdout2(async () => runStage(["audio-prune", context.workDir]));
|
|
58705
|
+
if (pruneCode !== 0)
|
|
58706
|
+
consoleOutput.error(`publish-report: audio-prune exited ${pruneCode}`);
|
|
58707
|
+
} catch (error) {
|
|
58708
|
+
consoleOutput.error(`publish-report: audio-prune warning: ${error instanceof Error ? error.message : String(error)}`);
|
|
58709
|
+
}
|
|
58695
58710
|
const outcomePath = join32(context.workDir, "4-publish", `outcome.${context.window}.json`);
|
|
58696
58711
|
if (await fs.exists(outcomePath)) {
|
|
58697
58712
|
let rows;
|
|
@@ -59742,6 +59757,7 @@ function silentWav(seconds = SILENT_WAV_SECONDS) {
|
|
|
59742
59757
|
// ../../plugins/generations/music-gen/src/adapter/instance.ts
|
|
59743
59758
|
var GENERATE_PATH = "/api/lyria/generate";
|
|
59744
59759
|
var LIBRARY_PATH = "/api/generations";
|
|
59760
|
+
var STATUS_PATH = "/api/settings/status";
|
|
59745
59761
|
var ANALYZE_PATH = "/api/ai/analyze";
|
|
59746
59762
|
var DEFAULT_CONNECT_ATTEMPTS = 3;
|
|
59747
59763
|
var DEFAULT_RETRY_DELAY_MS = 250;
|
|
@@ -59895,14 +59911,15 @@ class InstanceClient {
|
|
|
59895
59911
|
}
|
|
59896
59912
|
async attempt(method, path, body) {
|
|
59897
59913
|
const controller = new AbortController;
|
|
59898
|
-
|
|
59914
|
+
const enforceConnectTimer = method === "GET";
|
|
59915
|
+
let phase = enforceConnectTimer ? "connect" : "body";
|
|
59899
59916
|
let abortReason;
|
|
59900
|
-
const connectTimer = setTimeout(() => {
|
|
59917
|
+
const connectTimer = enforceConnectTimer ? setTimeout(() => {
|
|
59901
59918
|
if (phase === "connect" && abortReason === undefined) {
|
|
59902
59919
|
abortReason = "connect-timeout";
|
|
59903
59920
|
controller.abort();
|
|
59904
59921
|
}
|
|
59905
|
-
}, this.connectTimeoutMs);
|
|
59922
|
+
}, this.connectTimeoutMs) : undefined;
|
|
59906
59923
|
const totalTimer = setTimeout(() => {
|
|
59907
59924
|
if (abortReason === undefined) {
|
|
59908
59925
|
abortReason = "generate-timeout";
|
|
@@ -59921,7 +59938,9 @@ class InstanceClient {
|
|
|
59921
59938
|
};
|
|
59922
59939
|
const response = await this.fetchImpl(this.url(path), init);
|
|
59923
59940
|
phase = "body";
|
|
59924
|
-
|
|
59941
|
+
if (connectTimer !== undefined) {
|
|
59942
|
+
clearTimeout(connectTimer);
|
|
59943
|
+
}
|
|
59925
59944
|
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
59926
59945
|
const contentType = response.headers.get("content-type") ?? undefined;
|
|
59927
59946
|
return {
|
|
@@ -59954,7 +59973,9 @@ class InstanceClient {
|
|
|
59954
59973
|
}
|
|
59955
59974
|
return { kind: "ambiguous", reason };
|
|
59956
59975
|
} finally {
|
|
59957
|
-
|
|
59976
|
+
if (connectTimer !== undefined) {
|
|
59977
|
+
clearTimeout(connectTimer);
|
|
59978
|
+
}
|
|
59958
59979
|
clearTimeout(totalTimer);
|
|
59959
59980
|
}
|
|
59960
59981
|
}
|
|
@@ -59989,6 +60010,17 @@ class InstanceClient {
|
|
|
59989
60010
|
let lastReason = "";
|
|
59990
60011
|
for (;; ) {
|
|
59991
60012
|
attempts += 1;
|
|
60013
|
+
if (method === "POST") {
|
|
60014
|
+
const probe = await this.attempt("GET", STATUS_PATH, undefined);
|
|
60015
|
+
if (probe.kind === "connect") {
|
|
60016
|
+
lastReason = probe.reason;
|
|
60017
|
+
if (attempts >= maxAttempts) {
|
|
60018
|
+
return { kind: "connect-exhausted", reason: lastReason, attempts };
|
|
60019
|
+
}
|
|
60020
|
+
await this.sleep(this.retryDelayMs * 2 ** (attempts - 1));
|
|
60021
|
+
continue;
|
|
60022
|
+
}
|
|
60023
|
+
}
|
|
59992
60024
|
const outcome = await this.attempt(method, path, body);
|
|
59993
60025
|
if (outcome.kind === "response") {
|
|
59994
60026
|
return this.classify(outcome.response, attempts);
|
|
@@ -62010,7 +62042,7 @@ init_zod();
|
|
|
62010
62042
|
// ../../plugins/generations/music-gen/src/presets.ts
|
|
62011
62043
|
init_dist3();
|
|
62012
62044
|
init_zod();
|
|
62013
|
-
import { join as join38 } from "path";
|
|
62045
|
+
import { join as join38, resolve as resolve29 } from "path";
|
|
62014
62046
|
var BUILTIN_DEFAULTS = {
|
|
62015
62047
|
model: "pro",
|
|
62016
62048
|
language: "EN",
|
|
@@ -62386,6 +62418,25 @@ class PresetDataError extends Error {
|
|
|
62386
62418
|
}
|
|
62387
62419
|
}
|
|
62388
62420
|
var MUSIC_PRESET_ROOT = join38(import.meta.dir, "..", "presets");
|
|
62421
|
+
function musicPresetRootCandidates(from = import.meta.dir) {
|
|
62422
|
+
const candidates = [];
|
|
62423
|
+
let dir = resolve29(from);
|
|
62424
|
+
for (;; ) {
|
|
62425
|
+
candidates.push(join38(dir, "..", "presets"));
|
|
62426
|
+
candidates.push(join38(dir, "plugins", "generations", "music-gen", "presets"));
|
|
62427
|
+
const parent = resolve29(dir, "..");
|
|
62428
|
+
if (parent === dir)
|
|
62429
|
+
return candidates;
|
|
62430
|
+
dir = parent;
|
|
62431
|
+
}
|
|
62432
|
+
}
|
|
62433
|
+
async function resolveMusicPresetRoot(fs, from) {
|
|
62434
|
+
for (const candidate of musicPresetRootCandidates(from)) {
|
|
62435
|
+
if (await fs.exists(candidate))
|
|
62436
|
+
return candidate;
|
|
62437
|
+
}
|
|
62438
|
+
return MUSIC_PRESET_ROOT;
|
|
62439
|
+
}
|
|
62389
62440
|
async function readPresetFiles(dir, axis, fs, problems) {
|
|
62390
62441
|
if (!await fs.exists(dir)) {
|
|
62391
62442
|
problems.push({ path: dir, field: axis, message: "preset directory is missing" });
|
|
@@ -62462,8 +62513,8 @@ function collectPresets(args) {
|
|
|
62462
62513
|
return byName;
|
|
62463
62514
|
}
|
|
62464
62515
|
async function loadMusicPresets(options = {}) {
|
|
62465
|
-
const root = options.root ?? MUSIC_PRESET_ROOT;
|
|
62466
62516
|
const fs = options.fileSystem ?? createNodeFileSystem();
|
|
62517
|
+
const root = options.root ?? await resolveMusicPresetRoot(fs);
|
|
62467
62518
|
const problems = [];
|
|
62468
62519
|
const formatFiles = await readPresetFiles(join38(root, "formats"), "formats", fs, problems);
|
|
62469
62520
|
const themeFiles = await readPresetFiles(join38(root, "themes"), "themes", fs, problems);
|
|
@@ -62621,7 +62672,7 @@ function parseMusicJob(docs) {
|
|
|
62621
62672
|
return { brief, spec, job: resolveJob(brief, asPresetLayers(spec)) };
|
|
62622
62673
|
}
|
|
62623
62674
|
// ../../plugins/generations/music-gen/src/plugin.ts
|
|
62624
|
-
import { dirname as dirname18, join as join39, resolve as
|
|
62675
|
+
import { dirname as dirname18, join as join39, resolve as resolve30 } from "path";
|
|
62625
62676
|
init_dist3();
|
|
62626
62677
|
init_dist();
|
|
62627
62678
|
|
|
@@ -62873,7 +62924,7 @@ function isVerbose2(command) {
|
|
|
62873
62924
|
}
|
|
62874
62925
|
|
|
62875
62926
|
// src/commands/music/verbs.ts
|
|
62876
|
-
import { dirname as dirname19, join as join40, resolve as
|
|
62927
|
+
import { dirname as dirname19, join as join40, resolve as resolve31 } from "path";
|
|
62877
62928
|
init_output2();
|
|
62878
62929
|
var PAID_VERBS = new Set(["gen", "analyze"]);
|
|
62879
62930
|
function envelope(verb, dryRun) {
|
|
@@ -62945,7 +62996,7 @@ function emitPayload(payload, json, human) {
|
|
|
62945
62996
|
}
|
|
62946
62997
|
}
|
|
62947
62998
|
async function runRender(options, context) {
|
|
62948
|
-
const brief = await readBrief(
|
|
62999
|
+
const brief = await readBrief(resolve31(options.in));
|
|
62949
63000
|
const presets = await loadPresets(options.root);
|
|
62950
63001
|
const workflow = defaultModelLayer(brief, presets, context.config);
|
|
62951
63002
|
const job = resolveNamedJob(brief, presets, workflow === undefined ? {} : { workflow });
|
|
@@ -62954,14 +63005,14 @@ async function runRender(options, context) {
|
|
|
62954
63005
|
const imageHashes = await Promise.all((brief.images ?? []).map(async (path) => sha256Hex3(await readImageBytes(path))));
|
|
62955
63006
|
const digest = takeDigest(job, { imageHashes, takeIndex: 0 });
|
|
62956
63007
|
const explain = explainJob(job);
|
|
62957
|
-
const outPath = options.out === undefined ? null :
|
|
63008
|
+
const outPath = options.out === undefined ? null : resolve31(options.out);
|
|
62958
63009
|
if (outPath !== null) {
|
|
62959
63010
|
await musicSeams.fileSystem.writeFile(outPath, `${prompt}
|
|
62960
63011
|
`);
|
|
62961
63012
|
}
|
|
62962
63013
|
const payload = {
|
|
62963
63014
|
...envelope("render", context.config.dryRun),
|
|
62964
|
-
brief:
|
|
63015
|
+
brief: resolve31(options.in),
|
|
62965
63016
|
prompt,
|
|
62966
63017
|
request,
|
|
62967
63018
|
explain
|
|
@@ -63014,8 +63065,8 @@ async function runLibrary(_options, context) {
|
|
|
63014
63065
|
}
|
|
63015
63066
|
async function runGen(options, context) {
|
|
63016
63067
|
const fs = musicSeams.fileSystem;
|
|
63017
|
-
const inputPath =
|
|
63018
|
-
const outputPath =
|
|
63068
|
+
const inputPath = resolve31(options.in);
|
|
63069
|
+
const outputPath = resolve31(options.out);
|
|
63019
63070
|
const takes = options.takes === undefined ? undefined : Number(options.takes);
|
|
63020
63071
|
if (options.takes !== undefined && (!Number.isInteger(takes) || (takes ?? 0) < 1)) {
|
|
63021
63072
|
throw new Error(`--takes ${options.takes} is not a whole number of takes (1 or more)`);
|
|
@@ -63124,14 +63175,14 @@ function analysisObject(raw) {
|
|
|
63124
63175
|
return typeof nested === "object" && nested !== null ? nested : parsed;
|
|
63125
63176
|
}
|
|
63126
63177
|
async function runCheck(takePath, options, context) {
|
|
63127
|
-
const artifactPath =
|
|
63178
|
+
const artifactPath = resolve31(takePath);
|
|
63128
63179
|
const sidecar = await readSidecar(artifactPath);
|
|
63129
|
-
const brief = options.brief === undefined ? null : await readBrief(
|
|
63180
|
+
const brief = options.brief === undefined ? null : await readBrief(resolve31(options.brief));
|
|
63130
63181
|
const model = takeModel(options.model ?? brief?.model, sidecar);
|
|
63131
63182
|
const durationTarget = options.durationTarget ?? sidecar?.durationTarget ?? brief?.duration_target;
|
|
63132
63183
|
const style = options.style ?? brief?.style;
|
|
63133
63184
|
const sections = options.sections ?? (brief?.structure === undefined ? undefined : String(brief.structure.length));
|
|
63134
|
-
const analysisPath = options.analysis === undefined ? sidecar === null ? undefined :
|
|
63185
|
+
const analysisPath = options.analysis === undefined ? sidecar === null ? undefined : resolve31(join40(dirname19(artifactPath), `analysis-${sidecar.instanceId}.json`)) : resolve31(options.analysis);
|
|
63135
63186
|
const hasAnalysis = analysisPath !== undefined && await musicSeams.fileSystem.exists(analysisPath);
|
|
63136
63187
|
const analysis = hasAnalysis ? analysisObject(await musicSeams.fileSystem.readFile(analysisPath)) : undefined;
|
|
63137
63188
|
const runner = musicSeams.audioRunner;
|
|
@@ -63157,7 +63208,7 @@ async function runCheck(takePath, options, context) {
|
|
|
63157
63208
|
return payload;
|
|
63158
63209
|
}
|
|
63159
63210
|
async function runMaster(takePath, options, context) {
|
|
63160
|
-
const take =
|
|
63211
|
+
const take = resolve31(takePath);
|
|
63161
63212
|
const profileName = options.profile ?? DEFAULT_DELIVERY_PROFILE;
|
|
63162
63213
|
const profile = resolveDeliveryProfile(profileName, context.config.delivery);
|
|
63163
63214
|
const runner = musicSeams.audioRunner;
|
|
@@ -63165,7 +63216,7 @@ async function runMaster(takePath, options, context) {
|
|
|
63165
63216
|
takePath: take,
|
|
63166
63217
|
profileName,
|
|
63167
63218
|
profile,
|
|
63168
|
-
...options.out === undefined ? {} : { outputPath:
|
|
63219
|
+
...options.out === undefined ? {} : { outputPath: resolve31(options.out) },
|
|
63169
63220
|
...runner === undefined ? {} : { runner }
|
|
63170
63221
|
});
|
|
63171
63222
|
const sidecar = await readSidecar(take);
|
|
@@ -63240,7 +63291,7 @@ function registerMusicCommand(program) {
|
|
|
63240
63291
|
|
|
63241
63292
|
// src/commands/plugin.ts
|
|
63242
63293
|
import { existsSync as existsSync6 } from "fs";
|
|
63243
|
-
import { resolve as
|
|
63294
|
+
import { resolve as resolve32 } from "path";
|
|
63244
63295
|
init_dist();
|
|
63245
63296
|
init_commander();
|
|
63246
63297
|
init_output2();
|
|
@@ -63252,7 +63303,7 @@ function buildStatusReport(opts) {
|
|
|
63252
63303
|
const discovery = discoverAllPlugins({ pluginsRoot: opts.pluginsRoot, extraPaths: opts.pluginsPath });
|
|
63253
63304
|
const plugins = discovery.plugins.map((record) => {
|
|
63254
63305
|
const diagnostics = [];
|
|
63255
|
-
const entryPath =
|
|
63306
|
+
const entryPath = resolve32(record.dir, record.entry);
|
|
63256
63307
|
if (!existsSync6(entryPath)) {
|
|
63257
63308
|
diagnostics.push({
|
|
63258
63309
|
code: "missing_entry",
|
|
@@ -63454,11 +63505,12 @@ function registerPluginCommand(program) {
|
|
|
63454
63505
|
init_dist3();
|
|
63455
63506
|
init_commander();
|
|
63456
63507
|
init_output2();
|
|
63508
|
+
import { existsSync as existsSync7, realpathSync as realpathSync6 } from "fs";
|
|
63457
63509
|
import { homedir as homedir13 } from "os";
|
|
63458
|
-
import { resolve as
|
|
63510
|
+
import { dirname as dirname20, join as join41, resolve as resolve33 } from "path";
|
|
63459
63511
|
var SCHEDULE_PLATFORMS = ["launchd", "cron", "grok-bot"];
|
|
63460
63512
|
var SCHEDULES_REL = "plugins/kk/schedules";
|
|
63461
|
-
var CHECKOUT_ROOT2 =
|
|
63513
|
+
var CHECKOUT_ROOT2 = resolve33(import.meta.dir, "../../../..");
|
|
63462
63514
|
var SCHEDULE_TEMPLATES = {
|
|
63463
63515
|
"kk-collect": { launchd: "launchd.plist.tmpl", cron: "cron.tmpl", "grok-bot": "kk-collect.grok-bot.md.tmpl" },
|
|
63464
63516
|
"kk-serve": { launchd: "kk-serve.launchd.plist.tmpl" },
|
|
@@ -63471,6 +63523,28 @@ var DEFAULT_GROK_CRON = "0 4,10,16,22 * * *";
|
|
|
63471
63523
|
var REPO_PLACEHOLDER = "{{repo}}";
|
|
63472
63524
|
var HOME_PLACEHOLDER = "{{home}}";
|
|
63473
63525
|
var TYPESAFE_API_KEY_PLACEHOLDER = "{{typesafe_api_key}}";
|
|
63526
|
+
var SPUR_MODULES_PLACEHOLDER = "{{spur_modules}}";
|
|
63527
|
+
function spurModulesDir() {
|
|
63528
|
+
const conventional = resolve33(homedir13(), ".bun/install/global/node_modules");
|
|
63529
|
+
const binary = Bun.which("spur");
|
|
63530
|
+
if (binary === null)
|
|
63531
|
+
return conventional;
|
|
63532
|
+
let dir;
|
|
63533
|
+
try {
|
|
63534
|
+
dir = dirname20(realpathSync6(binary));
|
|
63535
|
+
} catch {
|
|
63536
|
+
return conventional;
|
|
63537
|
+
}
|
|
63538
|
+
for (;; ) {
|
|
63539
|
+
const modules = join41(dir, "node_modules");
|
|
63540
|
+
if (existsSync7(join41(modules, "@gobing-ai/spur/package.json")))
|
|
63541
|
+
return modules;
|
|
63542
|
+
const parent = dirname20(dir);
|
|
63543
|
+
if (parent === dir)
|
|
63544
|
+
return conventional;
|
|
63545
|
+
dir = parent;
|
|
63546
|
+
}
|
|
63547
|
+
}
|
|
63474
63548
|
function minuteGap(cronExpr) {
|
|
63475
63549
|
const minutes = new Set;
|
|
63476
63550
|
for (const part of (cronExpr.trim().split(/\s+/)[0] ?? "").split(",")) {
|
|
@@ -63508,7 +63582,7 @@ function xmlEscape(value) {
|
|
|
63508
63582
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
63509
63583
|
}
|
|
63510
63584
|
async function readTemplate(fs, repo, file) {
|
|
63511
|
-
const candidates = [
|
|
63585
|
+
const candidates = [resolve33(repo, SCHEDULES_REL, file), resolve33(CHECKOUT_ROOT2, SCHEDULES_REL, file)];
|
|
63512
63586
|
for (const path of candidates) {
|
|
63513
63587
|
if (await fs.exists(path)) {
|
|
63514
63588
|
return await fs.readFile(path);
|
|
@@ -63537,9 +63611,9 @@ async function renderAction(schedule, options) {
|
|
|
63537
63611
|
}
|
|
63538
63612
|
throw new Error(`schedule '${schedule}' has no ${options.platform} template (expected ${Object.keys(templates).join("|")})`);
|
|
63539
63613
|
}
|
|
63540
|
-
const repo =
|
|
63614
|
+
const repo = resolve33(options.repo);
|
|
63541
63615
|
const rendered = isGrok ? await renderGrokBody(options, template) : await readTemplate(createNodeFileSystem(), repo, template);
|
|
63542
|
-
const substitution = isGrok ? rendered.replaceAll("{{bot}}", options.bot ?? "").replaceAll("{{cron}}", options.cron ?? DEFAULT_GROK_CRON).replaceAll("{{tz}}", options.tz || Intl.DateTimeFormat().resolvedOptions().timeZone) : rendered.replaceAll(REPO_PLACEHOLDER, repo).replaceAll(HOME_PLACEHOLDER, homedir13()).replaceAll(TYPESAFE_API_KEY_PLACEHOLDER, xmlEscape(process.env.TYPESAFE_API_KEY ?? ""));
|
|
63616
|
+
const substitution = isGrok ? rendered.replaceAll("{{bot}}", options.bot ?? "").replaceAll("{{cron}}", options.cron ?? DEFAULT_GROK_CRON).replaceAll("{{tz}}", options.tz || Intl.DateTimeFormat().resolvedOptions().timeZone) : rendered.replaceAll(REPO_PLACEHOLDER, repo).replaceAll(HOME_PLACEHOLDER, homedir13()).replaceAll(TYPESAFE_API_KEY_PLACEHOLDER, xmlEscape(process.env.TYPESAFE_API_KEY ?? "")).replaceAll(SPUR_MODULES_PLACEHOLDER, xmlEscape(spurModulesDir()));
|
|
63543
63617
|
if (isGrok && substitution.includes("{{")) {
|
|
63544
63618
|
throw new Error("grok-bot routine left an unsubstituted placeholder \u2014 grok-bot templates may carry only {{bot}}, {{cron}}, {{tz}}");
|
|
63545
63619
|
}
|
|
@@ -63566,7 +63640,7 @@ async function renderGrokBody(options, template) {
|
|
|
63566
63640
|
throw new Error(`--cron '${options.cron}' fires under ${GROK_MIN_INTERVAL_MINUTES} minutes apart \u2014 Grok Bot routines need a ${GROK_MIN_INTERVAL_MINUTES}-minute minimum gap`);
|
|
63567
63641
|
}
|
|
63568
63642
|
}
|
|
63569
|
-
return await readTemplate(createNodeFileSystem(),
|
|
63643
|
+
return await readTemplate(createNodeFileSystem(), resolve33(options.repo), template);
|
|
63570
63644
|
}
|
|
63571
63645
|
function registerScheduleCommand(program) {
|
|
63572
63646
|
const schedule = program.command("schedule").description("Render the operator-installed schedules");
|
|
@@ -63639,7 +63713,7 @@ function registerStageCommand(program) {
|
|
|
63639
63713
|
}
|
|
63640
63714
|
|
|
63641
63715
|
// src/commands/store.ts
|
|
63642
|
-
import { dirname as
|
|
63716
|
+
import { dirname as dirname21, join as join43, resolve as resolve35 } from "path";
|
|
63643
63717
|
init_dist3();
|
|
63644
63718
|
init_commander();
|
|
63645
63719
|
|
|
@@ -63647,16 +63721,16 @@ init_commander();
|
|
|
63647
63721
|
init_dist3();
|
|
63648
63722
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
63649
63723
|
import { tmpdir as tmpdir4 } from "os";
|
|
63650
|
-
import { join as
|
|
63724
|
+
import { join as join42, resolve as resolve34 } from "path";
|
|
63651
63725
|
var STORE_CATALOG_PATH_REL = "plugins/kk/decisions/kk-items.yaml";
|
|
63652
63726
|
var SPUR_CONFIG_PATH_REL = ".spur/config.yaml";
|
|
63653
63727
|
var EVIDENCE_MAX_CHARS = 2000;
|
|
63654
63728
|
var SUBPROCESS_FALLBACK_AFTER = 2;
|
|
63655
63729
|
async function resolveCatalogPath(projectRoot, fs = createNodeFileSystem()) {
|
|
63656
63730
|
const candidates = [
|
|
63657
|
-
|
|
63658
|
-
|
|
63659
|
-
|
|
63731
|
+
resolve34(projectRoot, STORE_CATALOG_PATH_REL),
|
|
63732
|
+
resolve34(import.meta.dir, "../../..", STORE_CATALOG_PATH_REL),
|
|
63733
|
+
resolve34(import.meta.dir, "..", STORE_CATALOG_PATH_REL)
|
|
63660
63734
|
];
|
|
63661
63735
|
for (const candidate of candidates) {
|
|
63662
63736
|
if (await fs.exists(candidate))
|
|
@@ -63676,7 +63750,7 @@ async function loadInjectedHub() {
|
|
|
63676
63750
|
}
|
|
63677
63751
|
async function readDecisionRouting(projectRoot, fs = createNodeFileSystem()) {
|
|
63678
63752
|
const catalogPath = await resolveCatalogPath(projectRoot, fs);
|
|
63679
|
-
const configPath =
|
|
63753
|
+
const configPath = join42(projectRoot, SPUR_CONFIG_PATH_REL);
|
|
63680
63754
|
if (!await fs.exists(configPath))
|
|
63681
63755
|
return { catalogPath, routing: { makers: {} } };
|
|
63682
63756
|
let parsed;
|
|
@@ -63760,8 +63834,8 @@ function createBufferedDecisionFetch(inner = fetch) {
|
|
|
63760
63834
|
var bufferedDecisionFetch = createBufferedDecisionFetch();
|
|
63761
63835
|
function runDecisionSubprocess(decisionId, input, maker, fs = createNodeFileSystem()) {
|
|
63762
63836
|
const command = process.env.KK_SPUR_BIN ?? "spur";
|
|
63763
|
-
const scratch =
|
|
63764
|
-
const evidencePath =
|
|
63837
|
+
const scratch = join42(tmpdir4(), `kk-decision-${randomUUID2()}`);
|
|
63838
|
+
const evidencePath = join42(scratch, "evidence.md");
|
|
63765
63839
|
try {
|
|
63766
63840
|
fs.writeFile(evidencePath, input.body);
|
|
63767
63841
|
const args = [
|
|
@@ -63795,7 +63869,7 @@ var HEURISTIC_MAKER = "heuristic";
|
|
|
63795
63869
|
var LABEL_PLUGIN = "episode-plan-gen";
|
|
63796
63870
|
var LABEL_SCRATCH_DIR = "label";
|
|
63797
63871
|
var PROFILE_DIR_REL = "plugins/kk/decisions/extract";
|
|
63798
|
-
var CHECKOUT_ROOT3 =
|
|
63872
|
+
var CHECKOUT_ROOT3 = resolve35(import.meta.dir, "../../../..");
|
|
63799
63873
|
var CATALOG_PATH_REL = "plugins/kk/decisions/kk-items.yaml";
|
|
63800
63874
|
var TOPIC_SLUG = /^[a-z0-9][a-z0-9-]*$/;
|
|
63801
63875
|
var WINDOW_UNITS2 = { s: 1000, m: 60000, h: 3600000, d: 86400000 };
|
|
@@ -63876,7 +63950,7 @@ function sourceCountsOf3(docs) {
|
|
|
63876
63950
|
return counts;
|
|
63877
63951
|
}
|
|
63878
63952
|
async function writeNewIds(fs, path, ids) {
|
|
63879
|
-
await fs.ensureDir(
|
|
63953
|
+
await fs.ensureDir(dirname21(path));
|
|
63880
63954
|
await fs.writeFile(path, `${JSON.stringify([...new Set(ids)], null, 2)}
|
|
63881
63955
|
`);
|
|
63882
63956
|
}
|
|
@@ -63997,8 +64071,8 @@ async function readAnnotations(fs, outputPath) {
|
|
|
63997
64071
|
async function heuristicAnnotations(fs, scratch, runId, items) {
|
|
63998
64072
|
if (items.length === 0)
|
|
63999
64073
|
return new Map;
|
|
64000
|
-
const inputPath =
|
|
64001
|
-
const outputPath =
|
|
64074
|
+
const inputPath = join43(scratch, "label-input.json");
|
|
64075
|
+
const outputPath = join43(scratch, "label-out.json");
|
|
64002
64076
|
await fs.ensureDir(scratch);
|
|
64003
64077
|
const docs = items.map((item) => ({
|
|
64004
64078
|
id: item.id,
|
|
@@ -64217,7 +64291,7 @@ function parseDecisions(raw) {
|
|
|
64217
64291
|
return ids;
|
|
64218
64292
|
}
|
|
64219
64293
|
async function readCatalogVersion(fs) {
|
|
64220
|
-
const candidates = [
|
|
64294
|
+
const candidates = [resolve35(process.cwd(), CATALOG_PATH_REL), resolve35(CHECKOUT_ROOT3, CATALOG_PATH_REL)];
|
|
64221
64295
|
for (const path of candidates) {
|
|
64222
64296
|
try {
|
|
64223
64297
|
if (!await fs.exists(path))
|
|
@@ -64349,7 +64423,7 @@ async function labelAction(options) {
|
|
|
64349
64423
|
const mode = parseLabelMode(options.mode);
|
|
64350
64424
|
const configPath = resolveKkConfigPath();
|
|
64351
64425
|
const dbPath = await resolveStorePath(configPath, options.db);
|
|
64352
|
-
const scratch =
|
|
64426
|
+
const scratch = join43(dirname21(plan.kind === "new-ids" ? plan.newIds : dbPath), LABEL_SCRATCH_DIR);
|
|
64353
64427
|
const store = await openStore({ path: dbPath });
|
|
64354
64428
|
const catalogVersion = await readCatalogVersion(fs);
|
|
64355
64429
|
const labels = (await readStoreConfig(configPath)).labels;
|
|
@@ -64394,8 +64468,8 @@ async function resolveProfilePath(fs, topic) {
|
|
|
64394
64468
|
throw new Error(`--topic must be a lowercase slug (e.g. ai-news), got '${topic}'`);
|
|
64395
64469
|
}
|
|
64396
64470
|
const candidates = [
|
|
64397
|
-
|
|
64398
|
-
|
|
64471
|
+
resolve35(process.cwd(), PROFILE_DIR_REL, `${topic}.yaml`),
|
|
64472
|
+
resolve35(CHECKOUT_ROOT3, PROFILE_DIR_REL, `${topic}.yaml`)
|
|
64399
64473
|
];
|
|
64400
64474
|
for (const path of candidates) {
|
|
64401
64475
|
if (await fs.exists(path))
|
|
@@ -64432,7 +64506,7 @@ async function extractAction(options) {
|
|
|
64432
64506
|
try {
|
|
64433
64507
|
const policy = (await readStoreConfig(resolveKkConfigPath())).labels;
|
|
64434
64508
|
const docs = (await store.items.selectByProfile(query, policy)).map(toPoolDoc2);
|
|
64435
|
-
await fs.ensureDir(
|
|
64509
|
+
await fs.ensureDir(dirname21(options.out));
|
|
64436
64510
|
await fs.writeFile(options.out, `${JSON.stringify(docs, null, 2)}
|
|
64437
64511
|
`);
|
|
64438
64512
|
consoleOutput.write(JSON.stringify({ count: docs.length }));
|
|
@@ -64656,7 +64730,7 @@ init_commander();
|
|
|
64656
64730
|
init_output2();
|
|
64657
64731
|
|
|
64658
64732
|
// src/wiki/ingest.ts
|
|
64659
|
-
import { extname as extname4, isAbsolute as isAbsolute15, join as
|
|
64733
|
+
import { extname as extname4, isAbsolute as isAbsolute15, join as join50 } from "path";
|
|
64660
64734
|
|
|
64661
64735
|
// ../../packages/kk-wiki/src/compile.ts
|
|
64662
64736
|
function oneLineSummary(body) {
|
|
@@ -64858,11 +64932,11 @@ ${page.body.trim()}
|
|
|
64858
64932
|
`, pages: included.map((page) => page.path) };
|
|
64859
64933
|
}
|
|
64860
64934
|
// ../../packages/kk-wiki/src/gc.ts
|
|
64861
|
-
import { dirname as
|
|
64935
|
+
import { dirname as dirname22, isAbsolute as isAbsolute11, join as join44 } from "path";
|
|
64862
64936
|
async function planGc(index, options) {
|
|
64863
64937
|
const fs = options.fileSystem;
|
|
64864
|
-
const root =
|
|
64865
|
-
const mirrorPaths = (options.mirrors ?? []).map((mirror) => isAbsolute11(mirror) ? mirror :
|
|
64938
|
+
const root = dirname22(options.rawDir);
|
|
64939
|
+
const mirrorPaths = (options.mirrors ?? []).map((mirror) => isAbsolute11(mirror) ? mirror : join44(root, mirror));
|
|
64866
64940
|
const referenced = new Set;
|
|
64867
64941
|
for (const page of index.pages) {
|
|
64868
64942
|
for (const source of page.frontmatter.sources)
|
|
@@ -64870,16 +64944,16 @@ async function planGc(index, options) {
|
|
|
64870
64944
|
}
|
|
64871
64945
|
const candidates = [];
|
|
64872
64946
|
for (const type of ["url", "pdf", "html", "rss"]) {
|
|
64873
|
-
const dir =
|
|
64947
|
+
const dir = join44(options.rawDir, type);
|
|
64874
64948
|
if (!await fs.exists(dir))
|
|
64875
64949
|
continue;
|
|
64876
64950
|
for (const name of await fs.readDir(dir))
|
|
64877
|
-
candidates.push(
|
|
64951
|
+
candidates.push(join44(dir, name));
|
|
64878
64952
|
}
|
|
64879
|
-
const tmpDir =
|
|
64953
|
+
const tmpDir = join44(options.rawDir, "tmp");
|
|
64880
64954
|
if (await fs.exists(tmpDir)) {
|
|
64881
64955
|
for (const name of await fs.readDir(tmpDir))
|
|
64882
|
-
candidates.push(
|
|
64956
|
+
candidates.push(join44(tmpDir, name));
|
|
64883
64957
|
}
|
|
64884
64958
|
const skippedMirrors = (options.mirrors ?? []).filter((_, index) => {
|
|
64885
64959
|
const path = mirrorPaths[index];
|
|
@@ -65015,7 +65089,7 @@ function resolveLink(index, link) {
|
|
|
65015
65089
|
}
|
|
65016
65090
|
// ../../packages/kk-wiki/src/link.ts
|
|
65017
65091
|
init_dist3();
|
|
65018
|
-
import { join as
|
|
65092
|
+
import { join as join45 } from "path";
|
|
65019
65093
|
|
|
65020
65094
|
// ../../packages/kk-wiki/src/write.ts
|
|
65021
65095
|
function guardHeading(date) {
|
|
@@ -65126,7 +65200,7 @@ async function fixLinks(index, options = { date: "" }) {
|
|
|
65126
65200
|
const changed = [];
|
|
65127
65201
|
const refused = [];
|
|
65128
65202
|
for (const [path, pageMentions] of grouped) {
|
|
65129
|
-
const raw = await fs.readFile(
|
|
65203
|
+
const raw = await fs.readFile(join45(contentDir, path));
|
|
65130
65204
|
const page = parsePage(raw, path);
|
|
65131
65205
|
const rewritten = rewriteBody(page.body, pageMentions, parseFrontmatter(raw).bodyStartLine);
|
|
65132
65206
|
const { text, guard } = applyWriteToPage(page, rewritten, {
|
|
@@ -65137,7 +65211,7 @@ async function fixLinks(index, options = { date: "" }) {
|
|
|
65137
65211
|
changed.push(path);
|
|
65138
65212
|
continue;
|
|
65139
65213
|
}
|
|
65140
|
-
await fs.writeFile(
|
|
65214
|
+
await fs.writeFile(join45(contentDir, path), text);
|
|
65141
65215
|
if (guard === "appended")
|
|
65142
65216
|
refused.push(path);
|
|
65143
65217
|
else
|
|
@@ -65188,7 +65262,7 @@ function lintExitCode(findings) {
|
|
|
65188
65262
|
init_dist3();
|
|
65189
65263
|
import { createHash as createHash14 } from "crypto";
|
|
65190
65264
|
import { tmpdir as tmpdir5 } from "os";
|
|
65191
|
-
import { isAbsolute as isAbsolute12, join as
|
|
65265
|
+
import { isAbsolute as isAbsolute12, join as join46 } from "path";
|
|
65192
65266
|
|
|
65193
65267
|
class MissingNormalizerError extends Error {
|
|
65194
65268
|
binary;
|
|
@@ -65217,7 +65291,7 @@ function createMarkitdownRunner(options = {}) {
|
|
|
65217
65291
|
let target = input.target;
|
|
65218
65292
|
if (input.kind === "html") {
|
|
65219
65293
|
const id = createHash14("sha256").update(input.body ?? "").digest("hex").slice(0, 12);
|
|
65220
|
-
tempPath =
|
|
65294
|
+
tempPath = join46(tmpdir5(), `kk-wiki-${id}.html`);
|
|
65221
65295
|
await fs.writeFile(tempPath, input.body ?? "");
|
|
65222
65296
|
target = tempPath;
|
|
65223
65297
|
}
|
|
@@ -65311,23 +65385,23 @@ ${source.body.replace(/^\s+/, "")}`;
|
|
|
65311
65385
|
};
|
|
65312
65386
|
}
|
|
65313
65387
|
// ../../packages/kk-wiki/src/publish.ts
|
|
65314
|
-
import { dirname as
|
|
65388
|
+
import { dirname as dirname23, isAbsolute as isAbsolute13, join as join47, relative as relative6, resolve as resolve36 } from "path";
|
|
65315
65389
|
function isInside(parent, child) {
|
|
65316
65390
|
const rel = relative6(parent, child);
|
|
65317
65391
|
return rel === "" || !rel.startsWith("..") && !isAbsolute13(rel);
|
|
65318
65392
|
}
|
|
65319
65393
|
async function publishVault(index, options) {
|
|
65320
|
-
const targetRoot =
|
|
65321
|
-
if (isInside(
|
|
65394
|
+
const targetRoot = resolve36(options.target);
|
|
65395
|
+
if (isInside(resolve36(index.contentDir), targetRoot))
|
|
65322
65396
|
return { files: [], refused: "target-inside-vault" };
|
|
65323
65397
|
const fs = options.fileSystem;
|
|
65324
65398
|
const files = [];
|
|
65325
65399
|
for (const page of index.pages) {
|
|
65326
|
-
const source =
|
|
65327
|
-
const destination =
|
|
65328
|
-
await fs.ensureDir(
|
|
65400
|
+
const source = join47(index.contentDir, page.path);
|
|
65401
|
+
const destination = join47(targetRoot, "content", page.path);
|
|
65402
|
+
await fs.ensureDir(dirname23(destination));
|
|
65329
65403
|
await fs.writeFile(destination, await fs.readFile(source));
|
|
65330
|
-
files.push(
|
|
65404
|
+
files.push(join47("content", page.path));
|
|
65331
65405
|
}
|
|
65332
65406
|
return { files: files.sort() };
|
|
65333
65407
|
}
|
|
@@ -65379,7 +65453,7 @@ function rankPages(index, prompt, options = {}) {
|
|
|
65379
65453
|
// ../../packages/kk-wiki/src/raw.ts
|
|
65380
65454
|
init_dist3();
|
|
65381
65455
|
import { createHash as createHash15 } from "crypto";
|
|
65382
|
-
import { dirname as
|
|
65456
|
+
import { dirname as dirname24, join as join48 } from "path";
|
|
65383
65457
|
var RAW_SOURCE_TYPES = ["url", "pdf", "html", "rss"];
|
|
65384
65458
|
function rawSnapshotId(sourceUri, body) {
|
|
65385
65459
|
return createHash15("sha256").update(`${sourceUri}
|
|
@@ -65408,13 +65482,13 @@ async function writeRawSnapshot(input, fileSystem = createNodeFileSystem()) {
|
|
|
65408
65482
|
const id = rawSnapshotId(input.sourceUri, input.body);
|
|
65409
65483
|
const snapshot = {
|
|
65410
65484
|
id,
|
|
65411
|
-
path:
|
|
65485
|
+
path: join48(input.dir, input.type, `${id}.md`),
|
|
65412
65486
|
type: input.type,
|
|
65413
65487
|
title: input.title,
|
|
65414
65488
|
sourceUri: input.sourceUri,
|
|
65415
65489
|
ingestedAt
|
|
65416
65490
|
};
|
|
65417
|
-
await fileSystem.ensureDir(
|
|
65491
|
+
await fileSystem.ensureDir(dirname24(snapshot.path));
|
|
65418
65492
|
await fileSystem.writeFile(snapshot.path, renderRawSnapshot(snapshot, input.body));
|
|
65419
65493
|
return snapshot;
|
|
65420
65494
|
}
|
|
@@ -65536,7 +65610,7 @@ function synthesizePage(index, input) {
|
|
|
65536
65610
|
init_dist3();
|
|
65537
65611
|
|
|
65538
65612
|
// src/wiki/config.ts
|
|
65539
|
-
import { isAbsolute as isAbsolute14, join as
|
|
65613
|
+
import { isAbsolute as isAbsolute14, join as join49, resolve as resolve37 } from "path";
|
|
65540
65614
|
init_dist3();
|
|
65541
65615
|
var WIKI_CONFIG_FILE = "kk.config.json";
|
|
65542
65616
|
|
|
@@ -65623,7 +65697,7 @@ function parseBlock(raw) {
|
|
|
65623
65697
|
return block;
|
|
65624
65698
|
}
|
|
65625
65699
|
async function readConfigFile(cwd, fileSystem) {
|
|
65626
|
-
const path =
|
|
65700
|
+
const path = join49(cwd, WIKI_CONFIG_FILE);
|
|
65627
65701
|
if (!await fileSystem.exists(path))
|
|
65628
65702
|
return {};
|
|
65629
65703
|
let text;
|
|
@@ -65662,10 +65736,10 @@ async function resolveWikiConfig(options = {}) {
|
|
|
65662
65736
|
merged[key] = value;
|
|
65663
65737
|
}
|
|
65664
65738
|
Object.assign(merged, Object.fromEntries(Object.entries(options.overrides ?? {}).filter(([, v]) => v !== undefined)));
|
|
65665
|
-
merged.root =
|
|
65739
|
+
merged.root = resolve37(cwd, merged.root);
|
|
65666
65740
|
for (const key of ["raw", "content"]) {
|
|
65667
65741
|
if (!isAbsolute14(merged[key]))
|
|
65668
|
-
merged[key] =
|
|
65742
|
+
merged[key] = join49(merged.root, merged[key]);
|
|
65669
65743
|
}
|
|
65670
65744
|
return merged;
|
|
65671
65745
|
}
|
|
@@ -65716,7 +65790,7 @@ async function runIngest(args, deps = {}) {
|
|
|
65716
65790
|
const fs = deps.fileSystem ?? createNodeFileSystem();
|
|
65717
65791
|
const readStdinFn = deps.readStdin ?? readStdin;
|
|
65718
65792
|
const normalise = deps.markitdown ?? createMarkitdownRunner();
|
|
65719
|
-
const sourcePath = isAbsolute15(args.source) ? args.source :
|
|
65793
|
+
const sourcePath = isAbsolute15(args.source) ? args.source : join50(deps.cwd ?? process.cwd(), args.source);
|
|
65720
65794
|
let sourceText;
|
|
65721
65795
|
try {
|
|
65722
65796
|
if (fromStdin) {
|
|
@@ -65836,7 +65910,7 @@ function printLintOutcome(outcome, json) {
|
|
|
65836
65910
|
}
|
|
65837
65911
|
|
|
65838
65912
|
// src/wiki/maintenance.ts
|
|
65839
|
-
import { join as
|
|
65913
|
+
import { join as join51 } from "path";
|
|
65840
65914
|
init_dist3();
|
|
65841
65915
|
init_output2();
|
|
65842
65916
|
async function withConfig2(options, run) {
|
|
@@ -65858,12 +65932,12 @@ async function runMerge(options) {
|
|
|
65858
65932
|
if (merge.guard === "refused")
|
|
65859
65933
|
return { refused: true, path: merge.written };
|
|
65860
65934
|
const fs = createNodeFileSystem();
|
|
65861
|
-
await fs.writeFile(
|
|
65935
|
+
await fs.writeFile(join51(contentDir, merge.written), merge.targetText);
|
|
65862
65936
|
const sourcePage = index.pages.find((page) => page.slug === merge.sourceSlug);
|
|
65863
65937
|
if (sourcePage !== undefined)
|
|
65864
|
-
await fs.writeFile(
|
|
65938
|
+
await fs.writeFile(join51(contentDir, sourcePage.path), merge.sourceText);
|
|
65865
65939
|
for (const page of merge.rewrittenPages)
|
|
65866
|
-
await fs.writeFile(
|
|
65940
|
+
await fs.writeFile(join51(contentDir, page.path), page.text);
|
|
65867
65941
|
return {
|
|
65868
65942
|
refused: false,
|
|
65869
65943
|
path: merge.written,
|
|
@@ -65891,7 +65965,7 @@ async function runCompile(options) {
|
|
|
65891
65965
|
["index.md", compiled.index],
|
|
65892
65966
|
["MAP.md", compiled.map]
|
|
65893
65967
|
]) {
|
|
65894
|
-
const path =
|
|
65968
|
+
const path = join51(contentDir, name);
|
|
65895
65969
|
const current = await fs.exists(path) ? await fs.readFile(path) : null;
|
|
65896
65970
|
if (!needsWrite(current, rendered))
|
|
65897
65971
|
continue;
|
|
@@ -66031,7 +66105,7 @@ function printRetrievalOutcome(outcome, json) {
|
|
|
66031
66105
|
}
|
|
66032
66106
|
|
|
66033
66107
|
// src/wiki/write-verbs.ts
|
|
66034
|
-
import { isAbsolute as isAbsolute16, join as
|
|
66108
|
+
import { isAbsolute as isAbsolute16, join as join52 } from "path";
|
|
66035
66109
|
init_dist3();
|
|
66036
66110
|
init_output2();
|
|
66037
66111
|
async function readMaterial(options) {
|
|
@@ -66043,7 +66117,7 @@ async function readMaterial(options) {
|
|
|
66043
66117
|
chunks.push(chunk);
|
|
66044
66118
|
return Buffer.concat(chunks).toString("utf8");
|
|
66045
66119
|
}
|
|
66046
|
-
const path = isAbsolute16(options.from) ? options.from :
|
|
66120
|
+
const path = isAbsolute16(options.from) ? options.from : join52(options.cwd ?? process.cwd(), options.from);
|
|
66047
66121
|
return createNodeFileSystem().readFile(path);
|
|
66048
66122
|
}
|
|
66049
66123
|
async function resolveContext(options) {
|
|
@@ -66068,7 +66142,7 @@ async function runSummarize(options) {
|
|
|
66068
66142
|
const material = await readMaterial(options);
|
|
66069
66143
|
const date = options.date ?? new Date().toISOString().slice(0, 10);
|
|
66070
66144
|
const result = summarizePage(context.index, target, material, { date });
|
|
66071
|
-
await createNodeFileSystem().writeFile(
|
|
66145
|
+
await createNodeFileSystem().writeFile(join52(context.contentDir, result.path), result.text);
|
|
66072
66146
|
return { ok: true, code: 0, payload: { ok: true, path: result.path, guard: result.guard, links: result.links } };
|
|
66073
66147
|
}
|
|
66074
66148
|
async function runSynthesize(options) {
|
|
@@ -66079,7 +66153,7 @@ async function runSynthesize(options) {
|
|
|
66079
66153
|
const date = options.date ?? new Date().toISOString().slice(0, 10);
|
|
66080
66154
|
const type = options.type;
|
|
66081
66155
|
const result = synthesizePage(context.index, { target: options.target, material, type, date });
|
|
66082
|
-
await createNodeFileSystem().writeFile(
|
|
66156
|
+
await createNodeFileSystem().writeFile(join52(context.contentDir, result.path), result.text);
|
|
66083
66157
|
return {
|
|
66084
66158
|
ok: true,
|
|
66085
66159
|
code: 0,
|