@zabaca/lattice 1.2.1 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +368 -53
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -3460,15 +3460,328 @@ QuestionUnansweredCommand = __legacyDecorateClassTS([
|
|
|
3460
3460
|
typeof GraphService === "undefined" ? Object : GraphService
|
|
3461
3461
|
])
|
|
3462
3462
|
], QuestionUnansweredCommand);
|
|
3463
|
-
// src/commands/
|
|
3463
|
+
// src/commands/receive.command.ts
|
|
3464
3464
|
import { spawn } from "child_process";
|
|
3465
|
-
import { existsSync as existsSync6, readFileSync as readFileSync2, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
|
|
3466
|
-
import * as path2 from "path";
|
|
3467
3465
|
import { Injectable as Injectable17 } from "@nestjs/common";
|
|
3468
3466
|
import { Command as Command7, CommandRunner as CommandRunner7, Option as Option5 } from "nest-commander";
|
|
3469
|
-
|
|
3467
|
+
|
|
3468
|
+
// src/utils/croc-binary.ts
|
|
3469
|
+
import { execSync } from "child_process";
|
|
3470
|
+
import {
|
|
3471
|
+
chmodSync,
|
|
3472
|
+
createWriteStream,
|
|
3473
|
+
existsSync as existsSync6,
|
|
3474
|
+
mkdirSync as mkdirSync2,
|
|
3475
|
+
unlinkSync
|
|
3476
|
+
} from "fs";
|
|
3477
|
+
import { join as join3 } from "path";
|
|
3478
|
+
var CROC_VERSION = "10.3.1";
|
|
3479
|
+
function getBinPath() {
|
|
3480
|
+
return join3(getLatticeHome(), "bin");
|
|
3481
|
+
}
|
|
3482
|
+
function getCrocPath() {
|
|
3483
|
+
const binName = process.platform === "win32" ? "croc.exe" : "croc";
|
|
3484
|
+
return join3(getBinPath(), binName);
|
|
3485
|
+
}
|
|
3486
|
+
function getAssetName() {
|
|
3487
|
+
const platform = process.platform;
|
|
3488
|
+
const arch = process.arch;
|
|
3489
|
+
const assetMap = {
|
|
3490
|
+
"darwin-arm64": "macOS-ARM64",
|
|
3491
|
+
"darwin-x64": "macOS-64bit",
|
|
3492
|
+
"linux-x64": "Linux-64bit",
|
|
3493
|
+
"linux-arm64": "Linux-ARM64",
|
|
3494
|
+
"win32-x64": "Windows-64bit"
|
|
3495
|
+
};
|
|
3496
|
+
const key = `${platform}-${arch}`;
|
|
3497
|
+
return assetMap[key] || null;
|
|
3498
|
+
}
|
|
3499
|
+
async function downloadCroc() {
|
|
3500
|
+
const asset = getAssetName();
|
|
3501
|
+
if (!asset) {
|
|
3502
|
+
const key = `${process.platform}-${process.arch}`;
|
|
3503
|
+
console.error(`
|
|
3504
|
+
\u274C Unsupported platform: ${key}`);
|
|
3505
|
+
console.error(`
|
|
3506
|
+
Install croc manually: https://github.com/schollz/croc#install`);
|
|
3507
|
+
console.error(`Then place the binary at: ~/.lattice/bin/croc
|
|
3508
|
+
`);
|
|
3509
|
+
process.exit(1);
|
|
3510
|
+
}
|
|
3511
|
+
const binDir = getBinPath();
|
|
3512
|
+
if (!existsSync6(binDir)) {
|
|
3513
|
+
mkdirSync2(binDir, { recursive: true });
|
|
3514
|
+
}
|
|
3515
|
+
const ext = process.platform === "win32" ? "zip" : "tar.gz";
|
|
3516
|
+
const url = `https://github.com/schollz/croc/releases/download/v${CROC_VERSION}/croc_v${CROC_VERSION}_${asset}.${ext}`;
|
|
3517
|
+
console.log(`\uD83D\uDCE5 Downloading croc v${CROC_VERSION}...`);
|
|
3518
|
+
try {
|
|
3519
|
+
const response = await fetch(url);
|
|
3520
|
+
if (!response.ok) {
|
|
3521
|
+
throw new Error(`Failed to download: ${response.status} ${response.statusText}`);
|
|
3522
|
+
}
|
|
3523
|
+
const crocPath = getCrocPath();
|
|
3524
|
+
if (ext === "tar.gz") {
|
|
3525
|
+
const tempTarGz = join3(binDir, "croc.tar.gz");
|
|
3526
|
+
const fileStream = createWriteStream(tempTarGz);
|
|
3527
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
3528
|
+
const buffer = Buffer.from(arrayBuffer);
|
|
3529
|
+
fileStream.write(buffer);
|
|
3530
|
+
fileStream.end();
|
|
3531
|
+
await new Promise((resolve4, reject) => {
|
|
3532
|
+
fileStream.on("finish", resolve4);
|
|
3533
|
+
fileStream.on("error", reject);
|
|
3534
|
+
});
|
|
3535
|
+
execSync(`tar -xzf croc.tar.gz`, { cwd: binDir, stdio: "pipe" });
|
|
3536
|
+
unlinkSync(tempTarGz);
|
|
3537
|
+
chmodSync(crocPath, 493);
|
|
3538
|
+
} else {
|
|
3539
|
+
console.error(`
|
|
3540
|
+
\u274C Windows auto-download not yet implemented.`);
|
|
3541
|
+
console.error(`
|
|
3542
|
+
Install croc manually: https://github.com/schollz/croc#install`);
|
|
3543
|
+
console.error(`Then place the binary at: ~/.lattice/bin/croc.exe
|
|
3544
|
+
`);
|
|
3545
|
+
process.exit(1);
|
|
3546
|
+
}
|
|
3547
|
+
console.log(`\u2705 Installed croc to ${crocPath}
|
|
3548
|
+
`);
|
|
3549
|
+
} catch (error) {
|
|
3550
|
+
console.error(`
|
|
3551
|
+
\u274C Failed to download croc: ${error instanceof Error ? error.message : String(error)}`);
|
|
3552
|
+
console.error(`
|
|
3553
|
+
Install croc manually: https://github.com/schollz/croc#install`);
|
|
3554
|
+
console.error(`Then place the binary at: ${getCrocPath()}
|
|
3555
|
+
`);
|
|
3556
|
+
process.exit(1);
|
|
3557
|
+
}
|
|
3558
|
+
}
|
|
3559
|
+
async function ensureCroc() {
|
|
3560
|
+
const crocPath = getCrocPath();
|
|
3561
|
+
if (existsSync6(crocPath)) {
|
|
3562
|
+
return crocPath;
|
|
3563
|
+
}
|
|
3564
|
+
await downloadCroc();
|
|
3565
|
+
return crocPath;
|
|
3566
|
+
}
|
|
3567
|
+
|
|
3568
|
+
// src/commands/receive.command.ts
|
|
3569
|
+
class ReceiveCommand extends CommandRunner7 {
|
|
3570
|
+
syncService;
|
|
3571
|
+
constructor(syncService) {
|
|
3572
|
+
super();
|
|
3573
|
+
this.syncService = syncService;
|
|
3574
|
+
}
|
|
3575
|
+
async run([code], options) {
|
|
3576
|
+
if (!code) {
|
|
3577
|
+
console.error(`
|
|
3578
|
+
\u274C Please specify a share code
|
|
3579
|
+
`);
|
|
3580
|
+
console.error(`Usage: lattice receive <code>
|
|
3581
|
+
`);
|
|
3582
|
+
console.error("Example:");
|
|
3583
|
+
console.error(` lattice receive 7-actress-plural-pilgrim
|
|
3584
|
+
`);
|
|
3585
|
+
process.exit(1);
|
|
3586
|
+
}
|
|
3587
|
+
const docsDir = getDocsPath();
|
|
3588
|
+
console.log(`
|
|
3589
|
+
\uD83D\uDCE5 Receiving files to: ${docsDir}
|
|
3590
|
+
`);
|
|
3591
|
+
const crocPath = await ensureCroc();
|
|
3592
|
+
const receiveCode = await new Promise((resolve4, reject) => {
|
|
3593
|
+
const child = spawn(crocPath, ["--classic", "--yes", "--out", docsDir, code], {
|
|
3594
|
+
stdio: "inherit"
|
|
3595
|
+
});
|
|
3596
|
+
child.on("close", (code2) => {
|
|
3597
|
+
resolve4(code2 ?? 0);
|
|
3598
|
+
});
|
|
3599
|
+
child.on("error", (err) => {
|
|
3600
|
+
reject(err);
|
|
3601
|
+
});
|
|
3602
|
+
});
|
|
3603
|
+
if (receiveCode !== 0) {
|
|
3604
|
+
console.error(`
|
|
3605
|
+
\u274C Transfer failed
|
|
3606
|
+
`);
|
|
3607
|
+
process.exit(receiveCode);
|
|
3608
|
+
}
|
|
3609
|
+
if (!options.noSync) {
|
|
3610
|
+
console.log(`
|
|
3611
|
+
\uD83D\uDD04 Syncing received documents to knowledge graph...
|
|
3612
|
+
`);
|
|
3613
|
+
try {
|
|
3614
|
+
const result = await this.syncService.sync({
|
|
3615
|
+
verbose: false
|
|
3616
|
+
});
|
|
3617
|
+
console.log(`\uD83D\uDCCA Sync Results:
|
|
3618
|
+
`);
|
|
3619
|
+
console.log(` \u2705 Added: ${result.added}`);
|
|
3620
|
+
console.log(` \uD83D\uDD04 Updated: ${result.updated}`);
|
|
3621
|
+
console.log(` \u23ED\uFE0F Unchanged: ${result.unchanged}`);
|
|
3622
|
+
if (result.embeddingsGenerated > 0) {
|
|
3623
|
+
console.log(` \uD83E\uDDE0 Embeddings: ${result.embeddingsGenerated}`);
|
|
3624
|
+
}
|
|
3625
|
+
if (result.errors.length > 0) {
|
|
3626
|
+
console.log(`
|
|
3627
|
+
\u274C Errors (${result.errors.length}):
|
|
3628
|
+
`);
|
|
3629
|
+
result.errors.forEach((e) => {
|
|
3630
|
+
console.log(` ${e.path}: ${e.error}`);
|
|
3631
|
+
});
|
|
3632
|
+
}
|
|
3633
|
+
} catch (error) {
|
|
3634
|
+
console.error(`
|
|
3635
|
+
\u26A0\uFE0F Sync failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
3636
|
+
console.error("Files were received but not synced to the knowledge graph.");
|
|
3637
|
+
console.error(`Run 'lattice sync' manually to complete sync.
|
|
3638
|
+
`);
|
|
3639
|
+
}
|
|
3640
|
+
} else {
|
|
3641
|
+
console.log(`
|
|
3642
|
+
\u23ED\uFE0F Skipping sync (--no-sync specified)`);
|
|
3643
|
+
console.log(`Run 'lattice sync' to add documents to the knowledge graph.
|
|
3644
|
+
`);
|
|
3645
|
+
}
|
|
3646
|
+
console.log(`\u2705 Done!
|
|
3647
|
+
`);
|
|
3648
|
+
}
|
|
3649
|
+
parseNoSync() {
|
|
3650
|
+
return true;
|
|
3651
|
+
}
|
|
3652
|
+
}
|
|
3653
|
+
__legacyDecorateClassTS([
|
|
3654
|
+
Option5({
|
|
3655
|
+
flags: "--no-sync",
|
|
3656
|
+
description: "Skip running lattice sync after receiving"
|
|
3657
|
+
}),
|
|
3658
|
+
__legacyMetadataTS("design:type", Function),
|
|
3659
|
+
__legacyMetadataTS("design:paramtypes", []),
|
|
3660
|
+
__legacyMetadataTS("design:returntype", Boolean)
|
|
3661
|
+
], ReceiveCommand.prototype, "parseNoSync", null);
|
|
3662
|
+
ReceiveCommand = __legacyDecorateClassTS([
|
|
3663
|
+
Injectable17(),
|
|
3664
|
+
Command7({
|
|
3665
|
+
name: "receive",
|
|
3666
|
+
arguments: "<code>",
|
|
3667
|
+
description: "Receive shared documents via P2P transfer"
|
|
3668
|
+
}),
|
|
3669
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
3670
|
+
typeof SyncService === "undefined" ? Object : SyncService
|
|
3671
|
+
])
|
|
3672
|
+
], ReceiveCommand);
|
|
3673
|
+
// src/commands/share.command.ts
|
|
3674
|
+
import { spawn as spawn2 } from "child_process";
|
|
3675
|
+
import { existsSync as existsSync7, statSync } from "fs";
|
|
3676
|
+
import * as path2 from "path";
|
|
3677
|
+
import { Injectable as Injectable18 } from "@nestjs/common";
|
|
3678
|
+
import { Command as Command8, CommandRunner as CommandRunner8 } from "nest-commander";
|
|
3679
|
+
class ShareCommand extends CommandRunner8 {
|
|
3680
|
+
async run([docPath]) {
|
|
3681
|
+
if (!docPath) {
|
|
3682
|
+
console.error(`
|
|
3683
|
+
\u274C Please specify a path to share
|
|
3684
|
+
`);
|
|
3685
|
+
console.error(`Usage: lattice share <path>
|
|
3686
|
+
`);
|
|
3687
|
+
console.error("Examples:");
|
|
3688
|
+
console.error(" lattice share duckdb # Share ~/.lattice/docs/duckdb/");
|
|
3689
|
+
console.error(` lattice share duckdb/README.md # Share single file
|
|
3690
|
+
`);
|
|
3691
|
+
process.exit(1);
|
|
3692
|
+
}
|
|
3693
|
+
const fullPath = this.resolvePath(docPath);
|
|
3694
|
+
if (!existsSync7(fullPath)) {
|
|
3695
|
+
console.error(`
|
|
3696
|
+
\u274C Path not found: ${fullPath}
|
|
3697
|
+
`);
|
|
3698
|
+
process.exit(1);
|
|
3699
|
+
}
|
|
3700
|
+
const stat = statSync(fullPath);
|
|
3701
|
+
const isDir = stat.isDirectory();
|
|
3702
|
+
console.log(`
|
|
3703
|
+
\uD83D\uDCE4 Sharing ${isDir ? "directory" : "file"}: ${fullPath}
|
|
3704
|
+
`);
|
|
3705
|
+
const crocPath = await ensureCroc();
|
|
3706
|
+
const child = spawn2(crocPath, ["--classic", "--disable-clipboard", "send", fullPath], {
|
|
3707
|
+
stdio: ["inherit", "pipe", "pipe"]
|
|
3708
|
+
});
|
|
3709
|
+
let codeExtracted = false;
|
|
3710
|
+
let outputBuffer = "";
|
|
3711
|
+
const handleOutput = (data) => {
|
|
3712
|
+
const text = data.toString();
|
|
3713
|
+
outputBuffer += text;
|
|
3714
|
+
if (!codeExtracted) {
|
|
3715
|
+
const codeMatch = outputBuffer.match(/Code is:\s*(\S+)/);
|
|
3716
|
+
if (codeMatch) {
|
|
3717
|
+
codeExtracted = true;
|
|
3718
|
+
const code = codeMatch[1];
|
|
3719
|
+
const sendingMatches = outputBuffer.match(/Sending \d+ files? (?:and \d+ folders? )?\([^)]+\)/g);
|
|
3720
|
+
if (sendingMatches && sendingMatches.length > 0) {
|
|
3721
|
+
const lastMatch = sendingMatches[sendingMatches.length - 1];
|
|
3722
|
+
if (!lastMatch.includes("0 files")) {
|
|
3723
|
+
console.log(lastMatch);
|
|
3724
|
+
}
|
|
3725
|
+
}
|
|
3726
|
+
console.log(`
|
|
3727
|
+
\uD83D\uDD17 Share code: ${code}
|
|
3728
|
+
`);
|
|
3729
|
+
console.log("On the receiving machine, run:");
|
|
3730
|
+
console.log(` lattice receive ${code}
|
|
3731
|
+
`);
|
|
3732
|
+
console.log(`Waiting for recipient...
|
|
3733
|
+
`);
|
|
3734
|
+
outputBuffer = "";
|
|
3735
|
+
}
|
|
3736
|
+
return;
|
|
3737
|
+
}
|
|
3738
|
+
if (text.includes("On the other computer") || text.includes("(For Windows)") || text.includes("(For Linux/macOS)") || text.includes("CROC_SECRET=") || text.includes("Code copied to clipboard") || text.includes("croc ")) {
|
|
3739
|
+
return;
|
|
3740
|
+
}
|
|
3741
|
+
process.stdout.write(text);
|
|
3742
|
+
};
|
|
3743
|
+
child.stdout?.on("data", handleOutput);
|
|
3744
|
+
child.stderr?.on("data", handleOutput);
|
|
3745
|
+
child.on("close", (code) => {
|
|
3746
|
+
if (code === 0) {
|
|
3747
|
+
console.log(`
|
|
3748
|
+
\u2705 Transfer complete!
|
|
3749
|
+
`);
|
|
3750
|
+
}
|
|
3751
|
+
process.exit(code ?? 0);
|
|
3752
|
+
});
|
|
3753
|
+
child.on("error", (err) => {
|
|
3754
|
+
console.error(`
|
|
3755
|
+
\u274C Failed to run croc: ${err.message}
|
|
3756
|
+
`);
|
|
3757
|
+
process.exit(1);
|
|
3758
|
+
});
|
|
3759
|
+
}
|
|
3760
|
+
resolvePath(input) {
|
|
3761
|
+
if (path2.isAbsolute(input)) {
|
|
3762
|
+
return input;
|
|
3763
|
+
}
|
|
3764
|
+
const docsDir = getDocsPath();
|
|
3765
|
+
return path2.join(docsDir, input);
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3768
|
+
ShareCommand = __legacyDecorateClassTS([
|
|
3769
|
+
Injectable18(),
|
|
3770
|
+
Command8({
|
|
3771
|
+
name: "share",
|
|
3772
|
+
arguments: "<path>",
|
|
3773
|
+
description: "Share a document or topic directory via P2P transfer"
|
|
3774
|
+
})
|
|
3775
|
+
], ShareCommand);
|
|
3776
|
+
// src/commands/site.command.ts
|
|
3777
|
+
import { spawn as spawn3 } from "child_process";
|
|
3778
|
+
import { existsSync as existsSync8, readFileSync as readFileSync2, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
3779
|
+
import * as path3 from "path";
|
|
3780
|
+
import { Injectable as Injectable19 } from "@nestjs/common";
|
|
3781
|
+
import { Command as Command9, CommandRunner as CommandRunner9, Option as Option6 } from "nest-commander";
|
|
3782
|
+
class SiteCommand extends CommandRunner9 {
|
|
3470
3783
|
getPidFile() {
|
|
3471
|
-
return
|
|
3784
|
+
return path3.join(getLatticeHome(), "site.pid");
|
|
3472
3785
|
}
|
|
3473
3786
|
async run(_inputs, options) {
|
|
3474
3787
|
if (options.kill) {
|
|
@@ -3476,9 +3789,9 @@ class SiteCommand extends CommandRunner7 {
|
|
|
3476
3789
|
process.exit(0);
|
|
3477
3790
|
}
|
|
3478
3791
|
const latticeHome = getLatticeHome();
|
|
3479
|
-
const packageJsonPath =
|
|
3480
|
-
const nodeModulesPath =
|
|
3481
|
-
if (!
|
|
3792
|
+
const packageJsonPath = path3.join(latticeHome, "package.json");
|
|
3793
|
+
const nodeModulesPath = path3.join(latticeHome, "node_modules");
|
|
3794
|
+
if (!existsSync8(packageJsonPath)) {
|
|
3482
3795
|
console.error("Error: Site not initialized. Run 'lattice init' first.");
|
|
3483
3796
|
process.exit(1);
|
|
3484
3797
|
}
|
|
@@ -3487,7 +3800,7 @@ class SiteCommand extends CommandRunner7 {
|
|
|
3487
3800
|
console.error("Use 'lattice site --kill' to stop it first.");
|
|
3488
3801
|
process.exit(1);
|
|
3489
3802
|
}
|
|
3490
|
-
if (!
|
|
3803
|
+
if (!existsSync8(nodeModulesPath)) {
|
|
3491
3804
|
console.log("\uD83D\uDCE6 Installing dependencies...");
|
|
3492
3805
|
await this.runCommand("bun", ["install"], latticeHome);
|
|
3493
3806
|
console.log();
|
|
@@ -3514,7 +3827,7 @@ class SiteCommand extends CommandRunner7 {
|
|
|
3514
3827
|
}
|
|
3515
3828
|
runCommand(cmd, args, cwd) {
|
|
3516
3829
|
return new Promise((resolve4, reject) => {
|
|
3517
|
-
const child =
|
|
3830
|
+
const child = spawn3(cmd, args, {
|
|
3518
3831
|
cwd,
|
|
3519
3832
|
stdio: "pipe",
|
|
3520
3833
|
env: { ...process.env, FORCE_COLOR: "1" }
|
|
@@ -3539,7 +3852,7 @@ class SiteCommand extends CommandRunner7 {
|
|
|
3539
3852
|
}
|
|
3540
3853
|
runServerCommand(cmd, args, cwd) {
|
|
3541
3854
|
return new Promise((resolve4, reject) => {
|
|
3542
|
-
const child =
|
|
3855
|
+
const child = spawn3(cmd, args, {
|
|
3543
3856
|
cwd,
|
|
3544
3857
|
stdio: "inherit",
|
|
3545
3858
|
env: { ...process.env, FORCE_COLOR: "1" }
|
|
@@ -3549,7 +3862,7 @@ class SiteCommand extends CommandRunner7 {
|
|
|
3549
3862
|
}
|
|
3550
3863
|
const cleanup = () => {
|
|
3551
3864
|
try {
|
|
3552
|
-
|
|
3865
|
+
unlinkSync2(this.getPidFile());
|
|
3553
3866
|
} catch {}
|
|
3554
3867
|
};
|
|
3555
3868
|
child.on("close", (code) => {
|
|
@@ -3570,7 +3883,7 @@ class SiteCommand extends CommandRunner7 {
|
|
|
3570
3883
|
}
|
|
3571
3884
|
isRunning() {
|
|
3572
3885
|
const pidFile = this.getPidFile();
|
|
3573
|
-
if (!
|
|
3886
|
+
if (!existsSync8(pidFile)) {
|
|
3574
3887
|
return false;
|
|
3575
3888
|
}
|
|
3576
3889
|
try {
|
|
@@ -3579,14 +3892,14 @@ class SiteCommand extends CommandRunner7 {
|
|
|
3579
3892
|
return true;
|
|
3580
3893
|
} catch {
|
|
3581
3894
|
try {
|
|
3582
|
-
|
|
3895
|
+
unlinkSync2(pidFile);
|
|
3583
3896
|
} catch {}
|
|
3584
3897
|
return false;
|
|
3585
3898
|
}
|
|
3586
3899
|
}
|
|
3587
3900
|
killSiteProcess() {
|
|
3588
3901
|
const pidFile = this.getPidFile();
|
|
3589
|
-
if (!
|
|
3902
|
+
if (!existsSync8(pidFile)) {
|
|
3590
3903
|
console.log("No Lattice site process running");
|
|
3591
3904
|
return;
|
|
3592
3905
|
}
|
|
@@ -3597,11 +3910,11 @@ class SiteCommand extends CommandRunner7 {
|
|
|
3597
3910
|
} catch {
|
|
3598
3911
|
process.kill(pid, "SIGTERM");
|
|
3599
3912
|
}
|
|
3600
|
-
|
|
3913
|
+
unlinkSync2(pidFile);
|
|
3601
3914
|
console.log(`\u2705 Killed Lattice site process (PID: ${pid})`);
|
|
3602
3915
|
} catch (_err) {
|
|
3603
3916
|
try {
|
|
3604
|
-
|
|
3917
|
+
unlinkSync2(pidFile);
|
|
3605
3918
|
} catch {}
|
|
3606
3919
|
console.log("No Lattice site process running");
|
|
3607
3920
|
}
|
|
@@ -3620,7 +3933,7 @@ class SiteCommand extends CommandRunner7 {
|
|
|
3620
3933
|
}
|
|
3621
3934
|
}
|
|
3622
3935
|
__legacyDecorateClassTS([
|
|
3623
|
-
|
|
3936
|
+
Option6({
|
|
3624
3937
|
flags: "-b, --build",
|
|
3625
3938
|
description: "Build the site without starting the server"
|
|
3626
3939
|
}),
|
|
@@ -3629,7 +3942,7 @@ __legacyDecorateClassTS([
|
|
|
3629
3942
|
__legacyMetadataTS("design:returntype", Boolean)
|
|
3630
3943
|
], SiteCommand.prototype, "parseBuild", null);
|
|
3631
3944
|
__legacyDecorateClassTS([
|
|
3632
|
-
|
|
3945
|
+
Option6({
|
|
3633
3946
|
flags: "-d, --dev",
|
|
3634
3947
|
description: "Run in development mode (hot reload, no search)"
|
|
3635
3948
|
}),
|
|
@@ -3638,7 +3951,7 @@ __legacyDecorateClassTS([
|
|
|
3638
3951
|
__legacyMetadataTS("design:returntype", Boolean)
|
|
3639
3952
|
], SiteCommand.prototype, "parseDev", null);
|
|
3640
3953
|
__legacyDecorateClassTS([
|
|
3641
|
-
|
|
3954
|
+
Option6({
|
|
3642
3955
|
flags: "-p, --port <port>",
|
|
3643
3956
|
description: "Port to run the server on (default: 4321)"
|
|
3644
3957
|
}),
|
|
@@ -3649,7 +3962,7 @@ __legacyDecorateClassTS([
|
|
|
3649
3962
|
__legacyMetadataTS("design:returntype", String)
|
|
3650
3963
|
], SiteCommand.prototype, "parsePort", null);
|
|
3651
3964
|
__legacyDecorateClassTS([
|
|
3652
|
-
|
|
3965
|
+
Option6({
|
|
3653
3966
|
flags: "-k, --kill",
|
|
3654
3967
|
description: "Kill the running Lattice site process"
|
|
3655
3968
|
}),
|
|
@@ -3658,16 +3971,16 @@ __legacyDecorateClassTS([
|
|
|
3658
3971
|
__legacyMetadataTS("design:returntype", Boolean)
|
|
3659
3972
|
], SiteCommand.prototype, "parseKill", null);
|
|
3660
3973
|
SiteCommand = __legacyDecorateClassTS([
|
|
3661
|
-
|
|
3662
|
-
|
|
3974
|
+
Injectable19(),
|
|
3975
|
+
Command9({
|
|
3663
3976
|
name: "site",
|
|
3664
3977
|
description: "Build and run the Lattice documentation site"
|
|
3665
3978
|
})
|
|
3666
3979
|
], SiteCommand);
|
|
3667
3980
|
// src/commands/status.command.ts
|
|
3668
|
-
import { Injectable as
|
|
3669
|
-
import { Command as
|
|
3670
|
-
class StatusCommand extends
|
|
3981
|
+
import { Injectable as Injectable20 } from "@nestjs/common";
|
|
3982
|
+
import { Command as Command10, CommandRunner as CommandRunner10, Option as Option7 } from "nest-commander";
|
|
3983
|
+
class StatusCommand extends CommandRunner10 {
|
|
3671
3984
|
syncService;
|
|
3672
3985
|
dbChangeDetector;
|
|
3673
3986
|
constructor(syncService, dbChangeDetector) {
|
|
@@ -3733,7 +4046,7 @@ class StatusCommand extends CommandRunner8 {
|
|
|
3733
4046
|
}
|
|
3734
4047
|
}
|
|
3735
4048
|
__legacyDecorateClassTS([
|
|
3736
|
-
|
|
4049
|
+
Option7({
|
|
3737
4050
|
flags: "-v, --verbose",
|
|
3738
4051
|
description: "Show all documents including unchanged"
|
|
3739
4052
|
}),
|
|
@@ -3742,8 +4055,8 @@ __legacyDecorateClassTS([
|
|
|
3742
4055
|
__legacyMetadataTS("design:returntype", Boolean)
|
|
3743
4056
|
], StatusCommand.prototype, "parseVerbose", null);
|
|
3744
4057
|
StatusCommand = __legacyDecorateClassTS([
|
|
3745
|
-
|
|
3746
|
-
|
|
4058
|
+
Injectable20(),
|
|
4059
|
+
Command10({
|
|
3747
4060
|
name: "status",
|
|
3748
4061
|
description: "Show documents that need syncing (new or updated)"
|
|
3749
4062
|
}),
|
|
@@ -3754,12 +4067,12 @@ StatusCommand = __legacyDecorateClassTS([
|
|
|
3754
4067
|
], StatusCommand);
|
|
3755
4068
|
// src/commands/sync.command.ts
|
|
3756
4069
|
import { watch } from "fs";
|
|
3757
|
-
import { join as
|
|
3758
|
-
import { Injectable as
|
|
3759
|
-
import { Command as
|
|
4070
|
+
import { join as join6 } from "path";
|
|
4071
|
+
import { Injectable as Injectable22 } from "@nestjs/common";
|
|
4072
|
+
import { Command as Command11, CommandRunner as CommandRunner11, Option as Option8 } from "nest-commander";
|
|
3760
4073
|
|
|
3761
4074
|
// src/sync/graph-validator.service.ts
|
|
3762
|
-
import { Injectable as
|
|
4075
|
+
import { Injectable as Injectable21, Logger as Logger9 } from "@nestjs/common";
|
|
3763
4076
|
class GraphValidatorService {
|
|
3764
4077
|
graph;
|
|
3765
4078
|
logger = new Logger9(GraphValidatorService.name);
|
|
@@ -3878,15 +4191,15 @@ class GraphValidatorService {
|
|
|
3878
4191
|
});
|
|
3879
4192
|
}
|
|
3880
4193
|
}
|
|
3881
|
-
async validateDocument(
|
|
4194
|
+
async validateDocument(path4) {
|
|
3882
4195
|
const issues = [];
|
|
3883
4196
|
try {
|
|
3884
|
-
const result = await this.graph.query(`SELECT label, name, properties FROM nodes WHERE label = 'Document' AND name = '${this.escape(
|
|
4197
|
+
const result = await this.graph.query(`SELECT label, name, properties FROM nodes WHERE label = 'Document' AND name = '${this.escape(path4)}'`);
|
|
3885
4198
|
if (result.resultSet.length === 0) {
|
|
3886
4199
|
issues.push({
|
|
3887
4200
|
type: "error",
|
|
3888
4201
|
nodeLabel: "Document",
|
|
3889
|
-
nodeName:
|
|
4202
|
+
nodeName: path4,
|
|
3890
4203
|
field: "node",
|
|
3891
4204
|
message: "Document not found in graph",
|
|
3892
4205
|
suggestion: "Run 'lattice sync' to add this document"
|
|
@@ -3896,9 +4209,9 @@ class GraphValidatorService {
|
|
|
3896
4209
|
const row = result.resultSet[0];
|
|
3897
4210
|
const propertiesJson = row[2];
|
|
3898
4211
|
const properties = typeof propertiesJson === "string" ? JSON.parse(propertiesJson) : propertiesJson;
|
|
3899
|
-
this.validateDocumentNode(
|
|
4212
|
+
this.validateDocumentNode(path4, properties, issues);
|
|
3900
4213
|
} catch (error) {
|
|
3901
|
-
this.logger.error(`Failed to validate document ${
|
|
4214
|
+
this.logger.error(`Failed to validate document ${path4}: ${error instanceof Error ? error.message : String(error)}`);
|
|
3902
4215
|
throw error;
|
|
3903
4216
|
}
|
|
3904
4217
|
return issues;
|
|
@@ -3908,14 +4221,14 @@ class GraphValidatorService {
|
|
|
3908
4221
|
}
|
|
3909
4222
|
}
|
|
3910
4223
|
GraphValidatorService = __legacyDecorateClassTS([
|
|
3911
|
-
|
|
4224
|
+
Injectable21(),
|
|
3912
4225
|
__legacyMetadataTS("design:paramtypes", [
|
|
3913
4226
|
typeof GraphService === "undefined" ? Object : GraphService
|
|
3914
4227
|
])
|
|
3915
4228
|
], GraphValidatorService);
|
|
3916
4229
|
|
|
3917
4230
|
// src/commands/sync.command.ts
|
|
3918
|
-
class SyncCommand extends
|
|
4231
|
+
class SyncCommand extends CommandRunner11 {
|
|
3919
4232
|
syncService;
|
|
3920
4233
|
graphService;
|
|
3921
4234
|
_graphValidator;
|
|
@@ -4058,7 +4371,7 @@ class SyncCommand extends CommandRunner9 {
|
|
|
4058
4371
|
`);
|
|
4059
4372
|
this.watcher = watch(docsPath, { recursive: true }, (event, filename) => {
|
|
4060
4373
|
if (filename?.endsWith(".md")) {
|
|
4061
|
-
const fullPath =
|
|
4374
|
+
const fullPath = join6(docsPath, filename);
|
|
4062
4375
|
trackedFiles.add(fullPath);
|
|
4063
4376
|
debouncedSync();
|
|
4064
4377
|
}
|
|
@@ -4188,7 +4501,7 @@ class SyncCommand extends CommandRunner9 {
|
|
|
4188
4501
|
}
|
|
4189
4502
|
}
|
|
4190
4503
|
__legacyDecorateClassTS([
|
|
4191
|
-
|
|
4504
|
+
Option8({
|
|
4192
4505
|
flags: "-f, --force",
|
|
4193
4506
|
description: "Force re-sync specified documents (requires paths to be specified)"
|
|
4194
4507
|
}),
|
|
@@ -4197,7 +4510,7 @@ __legacyDecorateClassTS([
|
|
|
4197
4510
|
__legacyMetadataTS("design:returntype", Boolean)
|
|
4198
4511
|
], SyncCommand.prototype, "parseForce", null);
|
|
4199
4512
|
__legacyDecorateClassTS([
|
|
4200
|
-
|
|
4513
|
+
Option8({
|
|
4201
4514
|
flags: "-d, --dry-run",
|
|
4202
4515
|
description: "Show what would change without applying"
|
|
4203
4516
|
}),
|
|
@@ -4206,7 +4519,7 @@ __legacyDecorateClassTS([
|
|
|
4206
4519
|
__legacyMetadataTS("design:returntype", Boolean)
|
|
4207
4520
|
], SyncCommand.prototype, "parseDryRun", null);
|
|
4208
4521
|
__legacyDecorateClassTS([
|
|
4209
|
-
|
|
4522
|
+
Option8({
|
|
4210
4523
|
flags: "-v, --verbose",
|
|
4211
4524
|
description: "Show detailed output"
|
|
4212
4525
|
}),
|
|
@@ -4215,7 +4528,7 @@ __legacyDecorateClassTS([
|
|
|
4215
4528
|
__legacyMetadataTS("design:returntype", Boolean)
|
|
4216
4529
|
], SyncCommand.prototype, "parseVerbose", null);
|
|
4217
4530
|
__legacyDecorateClassTS([
|
|
4218
|
-
|
|
4531
|
+
Option8({
|
|
4219
4532
|
flags: "-w, --watch",
|
|
4220
4533
|
description: "Watch for file changes and sync automatically"
|
|
4221
4534
|
}),
|
|
@@ -4224,7 +4537,7 @@ __legacyDecorateClassTS([
|
|
|
4224
4537
|
__legacyMetadataTS("design:returntype", Boolean)
|
|
4225
4538
|
], SyncCommand.prototype, "parseWatch", null);
|
|
4226
4539
|
__legacyDecorateClassTS([
|
|
4227
|
-
|
|
4540
|
+
Option8({
|
|
4228
4541
|
flags: "--diff",
|
|
4229
4542
|
description: "Show only changed documents (alias for --dry-run)"
|
|
4230
4543
|
}),
|
|
@@ -4233,7 +4546,7 @@ __legacyDecorateClassTS([
|
|
|
4233
4546
|
__legacyMetadataTS("design:returntype", Boolean)
|
|
4234
4547
|
], SyncCommand.prototype, "parseDiff", null);
|
|
4235
4548
|
__legacyDecorateClassTS([
|
|
4236
|
-
|
|
4549
|
+
Option8({
|
|
4237
4550
|
flags: "--skip-cascade",
|
|
4238
4551
|
description: "Skip cascade analysis (faster for large repos)"
|
|
4239
4552
|
}),
|
|
@@ -4242,7 +4555,7 @@ __legacyDecorateClassTS([
|
|
|
4242
4555
|
__legacyMetadataTS("design:returntype", Boolean)
|
|
4243
4556
|
], SyncCommand.prototype, "parseSkipCascade", null);
|
|
4244
4557
|
__legacyDecorateClassTS([
|
|
4245
|
-
|
|
4558
|
+
Option8({
|
|
4246
4559
|
flags: "--no-embeddings",
|
|
4247
4560
|
description: "Disable embedding generation during sync"
|
|
4248
4561
|
}),
|
|
@@ -4251,7 +4564,7 @@ __legacyDecorateClassTS([
|
|
|
4251
4564
|
__legacyMetadataTS("design:returntype", Boolean)
|
|
4252
4565
|
], SyncCommand.prototype, "parseNoEmbeddings", null);
|
|
4253
4566
|
__legacyDecorateClassTS([
|
|
4254
|
-
|
|
4567
|
+
Option8({
|
|
4255
4568
|
flags: "--skip-extraction",
|
|
4256
4569
|
description: "Skip AI entity extraction (sync without re-extracting entities)"
|
|
4257
4570
|
}),
|
|
@@ -4260,8 +4573,8 @@ __legacyDecorateClassTS([
|
|
|
4260
4573
|
__legacyMetadataTS("design:returntype", Boolean)
|
|
4261
4574
|
], SyncCommand.prototype, "parseSkipExtraction", null);
|
|
4262
4575
|
SyncCommand = __legacyDecorateClassTS([
|
|
4263
|
-
|
|
4264
|
-
|
|
4576
|
+
Injectable22(),
|
|
4577
|
+
Command11({
|
|
4265
4578
|
name: "sync",
|
|
4266
4579
|
arguments: "[paths...]",
|
|
4267
4580
|
description: "Synchronize documents to the knowledge graph"
|
|
@@ -4300,7 +4613,7 @@ GraphModule = __legacyDecorateClassTS([
|
|
|
4300
4613
|
import { Module as Module3 } from "@nestjs/common";
|
|
4301
4614
|
|
|
4302
4615
|
// src/query/query.service.ts
|
|
4303
|
-
import { Injectable as
|
|
4616
|
+
import { Injectable as Injectable23, Logger as Logger10 } from "@nestjs/common";
|
|
4304
4617
|
class QueryService {
|
|
4305
4618
|
graphService;
|
|
4306
4619
|
logger = new Logger10(QueryService.name);
|
|
@@ -4313,7 +4626,7 @@ class QueryService {
|
|
|
4313
4626
|
}
|
|
4314
4627
|
}
|
|
4315
4628
|
QueryService = __legacyDecorateClassTS([
|
|
4316
|
-
|
|
4629
|
+
Injectable23(),
|
|
4317
4630
|
__legacyMetadataTS("design:paramtypes", [
|
|
4318
4631
|
typeof GraphService === "undefined" ? Object : GraphService
|
|
4319
4632
|
])
|
|
@@ -4388,6 +4701,8 @@ AppModule = __legacyDecorateClassTS([
|
|
|
4388
4701
|
InitCommand,
|
|
4389
4702
|
MigrateCommand,
|
|
4390
4703
|
SiteCommand,
|
|
4704
|
+
ShareCommand,
|
|
4705
|
+
ReceiveCommand,
|
|
4391
4706
|
QuestionAddCommand,
|
|
4392
4707
|
QuestionLinkCommand,
|
|
4393
4708
|
QuestionUnansweredCommand
|