@hasna/configs 0.2.26 → 0.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +36 -16
- package/dist/db/database.d.ts.map +1 -1
- package/dist/index.js +28 -8
- package/dist/mcp/index.js +31 -10
- package/dist/server/index.js +29 -9
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -2112,15 +2112,35 @@ var init_types = __esm(() => {
|
|
|
2112
2112
|
|
|
2113
2113
|
// src/db/database.ts
|
|
2114
2114
|
import { Database } from "bun:sqlite";
|
|
2115
|
-
import { existsSync, mkdirSync } from "fs";
|
|
2115
|
+
import { existsSync, mkdirSync, readdirSync, copyFileSync, statSync } from "fs";
|
|
2116
2116
|
import { dirname, join, resolve } from "path";
|
|
2117
2117
|
import { randomUUID } from "crypto";
|
|
2118
2118
|
function getDbPath() {
|
|
2119
|
+
if (process.env["HASNA_CONFIGS_DB_PATH"]) {
|
|
2120
|
+
return process.env["HASNA_CONFIGS_DB_PATH"];
|
|
2121
|
+
}
|
|
2119
2122
|
if (process.env["CONFIGS_DB_PATH"]) {
|
|
2120
2123
|
return process.env["CONFIGS_DB_PATH"];
|
|
2121
2124
|
}
|
|
2122
2125
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
2123
|
-
|
|
2126
|
+
const newDir = join(home, ".hasna", "configs");
|
|
2127
|
+
const oldDir = join(home, ".configs");
|
|
2128
|
+
if (existsSync(oldDir) && !existsSync(newDir)) {
|
|
2129
|
+
mkdirSync(newDir, { recursive: true });
|
|
2130
|
+
try {
|
|
2131
|
+
for (const file of readdirSync(oldDir)) {
|
|
2132
|
+
const oldPath = join(oldDir, file);
|
|
2133
|
+
const newPath = join(newDir, file);
|
|
2134
|
+
try {
|
|
2135
|
+
if (statSync(oldPath).isFile()) {
|
|
2136
|
+
copyFileSync(oldPath, newPath);
|
|
2137
|
+
}
|
|
2138
|
+
} catch {}
|
|
2139
|
+
}
|
|
2140
|
+
} catch {}
|
|
2141
|
+
}
|
|
2142
|
+
mkdirSync(newDir, { recursive: true });
|
|
2143
|
+
return join(newDir, "configs.db");
|
|
2124
2144
|
}
|
|
2125
2145
|
function ensureDir(filePath) {
|
|
2126
2146
|
if (filePath === ":memory:" || filePath.startsWith("file::memory:"))
|
|
@@ -2663,7 +2683,7 @@ var init_redact = __esm(() => {
|
|
|
2663
2683
|
});
|
|
2664
2684
|
|
|
2665
2685
|
// src/lib/sync-dir.ts
|
|
2666
|
-
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync2, statSync } from "fs";
|
|
2686
|
+
import { existsSync as existsSync3, readdirSync as readdirSync2, readFileSync as readFileSync2, statSync as statSync2 } from "fs";
|
|
2667
2687
|
import { join as join2, relative } from "path";
|
|
2668
2688
|
import { homedir as homedir2 } from "os";
|
|
2669
2689
|
function shouldSkip(p) {
|
|
@@ -2674,7 +2694,7 @@ async function syncFromDir(dir, opts = {}) {
|
|
|
2674
2694
|
const absDir = expandPath(dir);
|
|
2675
2695
|
if (!existsSync3(absDir))
|
|
2676
2696
|
return { added: 0, updated: 0, unchanged: 0, skipped: [`Not found: ${absDir}`] };
|
|
2677
|
-
const files = opts.recursive !== false ? walkDir(absDir) :
|
|
2697
|
+
const files = opts.recursive !== false ? walkDir(absDir) : readdirSync2(absDir).map((f) => join2(absDir, f)).filter((f) => statSync2(f).isFile());
|
|
2678
2698
|
const result = { added: 0, updated: 0, unchanged: 0, skipped: [] };
|
|
2679
2699
|
const home = homedir2();
|
|
2680
2700
|
const allConfigs = listConfigs(undefined, d);
|
|
@@ -2728,7 +2748,7 @@ async function syncToDir(dir, opts = {}) {
|
|
|
2728
2748
|
return result;
|
|
2729
2749
|
}
|
|
2730
2750
|
function walkDir(dir, files = []) {
|
|
2731
|
-
for (const entry of
|
|
2751
|
+
for (const entry of readdirSync2(dir, { withFileTypes: true })) {
|
|
2732
2752
|
const full = join2(dir, entry.name);
|
|
2733
2753
|
if (shouldSkip(full))
|
|
2734
2754
|
continue;
|
|
@@ -2763,7 +2783,7 @@ __export(exports_sync, {
|
|
|
2763
2783
|
PROJECT_CONFIG_FILES: () => PROJECT_CONFIG_FILES,
|
|
2764
2784
|
KNOWN_CONFIGS: () => KNOWN_CONFIGS
|
|
2765
2785
|
});
|
|
2766
|
-
import { existsSync as existsSync4, readdirSync as
|
|
2786
|
+
import { existsSync as existsSync4, readdirSync as readdirSync3, readFileSync as readFileSync3 } from "fs";
|
|
2767
2787
|
import { extname, join as join3 } from "path";
|
|
2768
2788
|
import { homedir as homedir3 } from "os";
|
|
2769
2789
|
async function syncProject(opts) {
|
|
@@ -2804,7 +2824,7 @@ async function syncProject(opts) {
|
|
|
2804
2824
|
}
|
|
2805
2825
|
const rulesDir = join3(absDir, ".claude", "rules");
|
|
2806
2826
|
if (existsSync4(rulesDir)) {
|
|
2807
|
-
const mdFiles =
|
|
2827
|
+
const mdFiles = readdirSync3(rulesDir).filter((f) => f.endsWith(".md"));
|
|
2808
2828
|
for (const f of mdFiles) {
|
|
2809
2829
|
const abs = join3(rulesDir, f);
|
|
2810
2830
|
const raw = readFileSync3(abs, "utf-8");
|
|
@@ -2845,7 +2865,7 @@ async function syncKnown(opts = {}) {
|
|
|
2845
2865
|
result.skipped.push(known.rulesDir);
|
|
2846
2866
|
continue;
|
|
2847
2867
|
}
|
|
2848
|
-
const mdFiles =
|
|
2868
|
+
const mdFiles = readdirSync3(absDir).filter((f) => f.endsWith(".md"));
|
|
2849
2869
|
for (const f of mdFiles) {
|
|
2850
2870
|
const abs2 = join3(absDir, f);
|
|
2851
2871
|
const targetPath = abs2.replace(home, "~");
|
|
@@ -3452,9 +3472,9 @@ program.command("sync").description("Sync known AI coding configs from disk into
|
|
|
3452
3472
|
if (opts.project) {
|
|
3453
3473
|
const dir = typeof opts.project === "string" ? opts.project : process.cwd();
|
|
3454
3474
|
if (opts.all) {
|
|
3455
|
-
const { readdirSync:
|
|
3475
|
+
const { readdirSync: readdirSync4, statSync: st } = await import("fs");
|
|
3456
3476
|
const absDir = expandPath(dir);
|
|
3457
|
-
const entries =
|
|
3477
|
+
const entries = readdirSync4(absDir, { withFileTypes: true });
|
|
3458
3478
|
let totalAdded = 0, totalUpdated = 0, totalUnchanged = 0, projects = 0;
|
|
3459
3479
|
for (const entry of entries) {
|
|
3460
3480
|
if (!entry.isDirectory())
|
|
@@ -3508,7 +3528,7 @@ program.command("import <file>").description("Import configs from a tar.gz bundl
|
|
|
3508
3528
|
}
|
|
3509
3529
|
});
|
|
3510
3530
|
program.command("whoami").description("Show setup summary").action(async () => {
|
|
3511
|
-
const dbPath = process.env["CONFIGS_DB_PATH"] || join6(homedir4(), ".configs", "configs.db");
|
|
3531
|
+
const dbPath = process.env["CONFIGS_DB_PATH"] || join6(homedir4(), ".hasna", "configs", "configs.db");
|
|
3512
3532
|
const stats = getConfigStats();
|
|
3513
3533
|
console.log(chalk.bold("@hasna/configs") + chalk.dim(" v" + pkg.version));
|
|
3514
3534
|
console.log(chalk.cyan("DB:") + " " + dbPath);
|
|
@@ -3839,7 +3859,7 @@ mcpCmd.command("uninstall").alias("remove").description("Remove configs MCP serv
|
|
|
3839
3859
|
}
|
|
3840
3860
|
});
|
|
3841
3861
|
program.command("init").description("First-time setup: sync all known configs, create default profile").option("--force", "delete existing DB and start fresh").action(async (opts) => {
|
|
3842
|
-
const dbPath = join6(homedir4(), ".configs", "configs.db");
|
|
3862
|
+
const dbPath = join6(homedir4(), ".hasna", "configs", "configs.db");
|
|
3843
3863
|
if (opts.force && existsSync7(dbPath)) {
|
|
3844
3864
|
const { rmSync: rmSync3 } = await import("fs");
|
|
3845
3865
|
rmSync3(dbPath);
|
|
@@ -3891,7 +3911,7 @@ DB stats:`));
|
|
|
3891
3911
|
DB: ${dbPath}`));
|
|
3892
3912
|
});
|
|
3893
3913
|
program.command("status").description("Health check: total configs, drift from disk, unredacted secrets").action(async () => {
|
|
3894
|
-
const dbPath = join6(homedir4(), ".configs", "configs.db");
|
|
3914
|
+
const dbPath = join6(homedir4(), ".hasna", "configs", "configs.db");
|
|
3895
3915
|
const stats = getConfigStats();
|
|
3896
3916
|
const { statSync: st } = await import("fs");
|
|
3897
3917
|
const dbSize = existsSync7(dbPath) ? st(dbPath).size : 0;
|
|
@@ -3928,7 +3948,7 @@ program.command("status").description("Health check: total configs, drift from d
|
|
|
3928
3948
|
});
|
|
3929
3949
|
program.command("backup").description("Export configs to a timestamped backup file").action(async () => {
|
|
3930
3950
|
const { mkdirSync: mk } = await import("fs");
|
|
3931
|
-
const backupDir = join6(homedir4(), ".configs", "backups");
|
|
3951
|
+
const backupDir = join6(homedir4(), ".hasna", "configs", "backups");
|
|
3932
3952
|
mk(backupDir, { recursive: true });
|
|
3933
3953
|
const ts = new Date().toISOString().replace(/[:.]/g, "-").replace("T", "-").slice(0, 19);
|
|
3934
3954
|
const outPath = join6(backupDir, `configs-${ts}.tar.gz`);
|
|
@@ -4084,8 +4104,8 @@ program.command("watch").description("Watch known config files for changes and a
|
|
|
4084
4104
|
const absDir = expandPath2(k.rulesDir);
|
|
4085
4105
|
if (!existsSync7(absDir))
|
|
4086
4106
|
continue;
|
|
4087
|
-
const { readdirSync:
|
|
4088
|
-
for (const f of
|
|
4107
|
+
const { readdirSync: readdirSync4 } = await import("fs");
|
|
4108
|
+
for (const f of readdirSync4(absDir).filter((f2) => f2.endsWith(".md"))) {
|
|
4089
4109
|
const abs = join6(absDir, f);
|
|
4090
4110
|
mtimes.set(abs, st(abs).mtimeMs);
|
|
4091
4111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/db/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/db/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAgDtC,wBAAgB,IAAI,IAAI,MAAM,CAE7B;AAED,wBAAgB,GAAG,IAAI,MAAM,CAE5B;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAK5C;AAiED,wBAAgB,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,CAUnD;AAED,wBAAgB,aAAa,IAAI,IAAI,CAEpC"}
|
package/dist/index.js
CHANGED
|
@@ -58,15 +58,35 @@ class TemplateRenderError extends Error {
|
|
|
58
58
|
}
|
|
59
59
|
// src/db/database.ts
|
|
60
60
|
import { Database } from "bun:sqlite";
|
|
61
|
-
import { existsSync, mkdirSync } from "fs";
|
|
61
|
+
import { existsSync, mkdirSync, readdirSync, copyFileSync, statSync } from "fs";
|
|
62
62
|
import { dirname, join, resolve } from "path";
|
|
63
63
|
import { randomUUID } from "crypto";
|
|
64
64
|
function getDbPath() {
|
|
65
|
+
if (process.env["HASNA_CONFIGS_DB_PATH"]) {
|
|
66
|
+
return process.env["HASNA_CONFIGS_DB_PATH"];
|
|
67
|
+
}
|
|
65
68
|
if (process.env["CONFIGS_DB_PATH"]) {
|
|
66
69
|
return process.env["CONFIGS_DB_PATH"];
|
|
67
70
|
}
|
|
68
71
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
69
|
-
|
|
72
|
+
const newDir = join(home, ".hasna", "configs");
|
|
73
|
+
const oldDir = join(home, ".configs");
|
|
74
|
+
if (existsSync(oldDir) && !existsSync(newDir)) {
|
|
75
|
+
mkdirSync(newDir, { recursive: true });
|
|
76
|
+
try {
|
|
77
|
+
for (const file of readdirSync(oldDir)) {
|
|
78
|
+
const oldPath = join(oldDir, file);
|
|
79
|
+
const newPath = join(newDir, file);
|
|
80
|
+
try {
|
|
81
|
+
if (statSync(oldPath).isFile()) {
|
|
82
|
+
copyFileSync(oldPath, newPath);
|
|
83
|
+
}
|
|
84
|
+
} catch {}
|
|
85
|
+
}
|
|
86
|
+
} catch {}
|
|
87
|
+
}
|
|
88
|
+
mkdirSync(newDir, { recursive: true });
|
|
89
|
+
return join(newDir, "configs.db");
|
|
70
90
|
}
|
|
71
91
|
function ensureDir(filePath) {
|
|
72
92
|
if (filePath === ":memory:" || filePath.startsWith("file::memory:"))
|
|
@@ -524,7 +544,7 @@ async function applyConfigs(configs, opts = {}) {
|
|
|
524
544
|
return results;
|
|
525
545
|
}
|
|
526
546
|
// src/lib/sync.ts
|
|
527
|
-
import { existsSync as existsSync4, readdirSync as
|
|
547
|
+
import { existsSync as existsSync4, readdirSync as readdirSync3, readFileSync as readFileSync3 } from "fs";
|
|
528
548
|
import { extname, join as join3 } from "path";
|
|
529
549
|
import { homedir as homedir3 } from "os";
|
|
530
550
|
|
|
@@ -709,7 +729,7 @@ function hasSecrets(content, format) {
|
|
|
709
729
|
}
|
|
710
730
|
|
|
711
731
|
// src/lib/sync-dir.ts
|
|
712
|
-
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync2, statSync } from "fs";
|
|
732
|
+
import { existsSync as existsSync3, readdirSync as readdirSync2, readFileSync as readFileSync2, statSync as statSync2 } from "fs";
|
|
713
733
|
import { join as join2, relative } from "path";
|
|
714
734
|
import { homedir as homedir2 } from "os";
|
|
715
735
|
var SKIP = [".db", ".db-shm", ".db-wal", ".log", ".lock", ".DS_Store", "node_modules", ".git"];
|
|
@@ -721,7 +741,7 @@ async function syncFromDir(dir, opts = {}) {
|
|
|
721
741
|
const absDir = expandPath(dir);
|
|
722
742
|
if (!existsSync3(absDir))
|
|
723
743
|
return { added: 0, updated: 0, unchanged: 0, skipped: [`Not found: ${absDir}`] };
|
|
724
|
-
const files = opts.recursive !== false ? walkDir(absDir) :
|
|
744
|
+
const files = opts.recursive !== false ? walkDir(absDir) : readdirSync2(absDir).map((f) => join2(absDir, f)).filter((f) => statSync2(f).isFile());
|
|
725
745
|
const result = { added: 0, updated: 0, unchanged: 0, skipped: [] };
|
|
726
746
|
const home = homedir2();
|
|
727
747
|
const allConfigs = listConfigs(undefined, d);
|
|
@@ -775,7 +795,7 @@ async function syncToDir(dir, opts = {}) {
|
|
|
775
795
|
return result;
|
|
776
796
|
}
|
|
777
797
|
function walkDir(dir, files = []) {
|
|
778
|
-
for (const entry of
|
|
798
|
+
for (const entry of readdirSync2(dir, { withFileTypes: true })) {
|
|
779
799
|
const full = join2(dir, entry.name);
|
|
780
800
|
if (shouldSkip(full))
|
|
781
801
|
continue;
|
|
@@ -855,7 +875,7 @@ async function syncProject(opts) {
|
|
|
855
875
|
}
|
|
856
876
|
const rulesDir = join3(absDir, ".claude", "rules");
|
|
857
877
|
if (existsSync4(rulesDir)) {
|
|
858
|
-
const mdFiles =
|
|
878
|
+
const mdFiles = readdirSync3(rulesDir).filter((f) => f.endsWith(".md"));
|
|
859
879
|
for (const f of mdFiles) {
|
|
860
880
|
const abs = join3(rulesDir, f);
|
|
861
881
|
const raw = readFileSync3(abs, "utf-8");
|
|
@@ -896,7 +916,7 @@ async function syncKnown(opts = {}) {
|
|
|
896
916
|
result.skipped.push(known.rulesDir);
|
|
897
917
|
continue;
|
|
898
918
|
}
|
|
899
|
-
const mdFiles =
|
|
919
|
+
const mdFiles = readdirSync3(absDir).filter((f) => f.endsWith(".md"));
|
|
900
920
|
for (const f of mdFiles) {
|
|
901
921
|
const abs2 = join3(absDir, f);
|
|
902
922
|
const targetPath = abs2.replace(home, "~");
|
package/dist/mcp/index.js
CHANGED
|
@@ -49,15 +49,35 @@ var init_types = __esm(() => {
|
|
|
49
49
|
|
|
50
50
|
// src/db/database.ts
|
|
51
51
|
import { Database } from "bun:sqlite";
|
|
52
|
-
import { existsSync, mkdirSync } from "fs";
|
|
52
|
+
import { existsSync, mkdirSync, readdirSync, copyFileSync, statSync } from "fs";
|
|
53
53
|
import { dirname, join, resolve } from "path";
|
|
54
54
|
import { randomUUID } from "crypto";
|
|
55
55
|
function getDbPath() {
|
|
56
|
+
if (process.env["HASNA_CONFIGS_DB_PATH"]) {
|
|
57
|
+
return process.env["HASNA_CONFIGS_DB_PATH"];
|
|
58
|
+
}
|
|
56
59
|
if (process.env["CONFIGS_DB_PATH"]) {
|
|
57
60
|
return process.env["CONFIGS_DB_PATH"];
|
|
58
61
|
}
|
|
59
62
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
60
|
-
|
|
63
|
+
const newDir = join(home, ".hasna", "configs");
|
|
64
|
+
const oldDir = join(home, ".configs");
|
|
65
|
+
if (existsSync(oldDir) && !existsSync(newDir)) {
|
|
66
|
+
mkdirSync(newDir, { recursive: true });
|
|
67
|
+
try {
|
|
68
|
+
for (const file of readdirSync(oldDir)) {
|
|
69
|
+
const oldPath = join(oldDir, file);
|
|
70
|
+
const newPath = join(newDir, file);
|
|
71
|
+
try {
|
|
72
|
+
if (statSync(oldPath).isFile()) {
|
|
73
|
+
copyFileSync(oldPath, newPath);
|
|
74
|
+
}
|
|
75
|
+
} catch {}
|
|
76
|
+
}
|
|
77
|
+
} catch {}
|
|
78
|
+
}
|
|
79
|
+
mkdirSync(newDir, { recursive: true });
|
|
80
|
+
return join(newDir, "configs.db");
|
|
61
81
|
}
|
|
62
82
|
function ensureDir(filePath) {
|
|
63
83
|
if (filePath === ":memory:" || filePath.startsWith("file::memory:"))
|
|
@@ -616,7 +636,7 @@ var init_redact = __esm(() => {
|
|
|
616
636
|
});
|
|
617
637
|
|
|
618
638
|
// src/lib/sync-dir.ts
|
|
619
|
-
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync2, statSync } from "fs";
|
|
639
|
+
import { existsSync as existsSync3, readdirSync as readdirSync2, readFileSync as readFileSync2, statSync as statSync2 } from "fs";
|
|
620
640
|
import { join as join2, relative } from "path";
|
|
621
641
|
import { homedir as homedir2 } from "os";
|
|
622
642
|
function shouldSkip(p) {
|
|
@@ -627,7 +647,7 @@ async function syncFromDir(dir, opts = {}) {
|
|
|
627
647
|
const absDir = expandPath(dir);
|
|
628
648
|
if (!existsSync3(absDir))
|
|
629
649
|
return { added: 0, updated: 0, unchanged: 0, skipped: [`Not found: ${absDir}`] };
|
|
630
|
-
const files = opts.recursive !== false ? walkDir(absDir) :
|
|
650
|
+
const files = opts.recursive !== false ? walkDir(absDir) : readdirSync2(absDir).map((f) => join2(absDir, f)).filter((f) => statSync2(f).isFile());
|
|
631
651
|
const result = { added: 0, updated: 0, unchanged: 0, skipped: [] };
|
|
632
652
|
const home = homedir2();
|
|
633
653
|
const allConfigs = listConfigs(undefined, d);
|
|
@@ -681,7 +701,7 @@ async function syncToDir(dir, opts = {}) {
|
|
|
681
701
|
return result;
|
|
682
702
|
}
|
|
683
703
|
function walkDir(dir, files = []) {
|
|
684
|
-
for (const entry of
|
|
704
|
+
for (const entry of readdirSync2(dir, { withFileTypes: true })) {
|
|
685
705
|
const full = join2(dir, entry.name);
|
|
686
706
|
if (shouldSkip(full))
|
|
687
707
|
continue;
|
|
@@ -716,7 +736,7 @@ __export(exports_sync, {
|
|
|
716
736
|
PROJECT_CONFIG_FILES: () => PROJECT_CONFIG_FILES,
|
|
717
737
|
KNOWN_CONFIGS: () => KNOWN_CONFIGS
|
|
718
738
|
});
|
|
719
|
-
import { existsSync as existsSync4, readdirSync as
|
|
739
|
+
import { existsSync as existsSync4, readdirSync as readdirSync3, readFileSync as readFileSync3 } from "fs";
|
|
720
740
|
import { extname, join as join3 } from "path";
|
|
721
741
|
import { homedir as homedir3 } from "os";
|
|
722
742
|
async function syncProject(opts) {
|
|
@@ -757,7 +777,7 @@ async function syncProject(opts) {
|
|
|
757
777
|
}
|
|
758
778
|
const rulesDir = join3(absDir, ".claude", "rules");
|
|
759
779
|
if (existsSync4(rulesDir)) {
|
|
760
|
-
const mdFiles =
|
|
780
|
+
const mdFiles = readdirSync3(rulesDir).filter((f) => f.endsWith(".md"));
|
|
761
781
|
for (const f of mdFiles) {
|
|
762
782
|
const abs = join3(rulesDir, f);
|
|
763
783
|
const raw = readFileSync3(abs, "utf-8");
|
|
@@ -798,7 +818,7 @@ async function syncKnown(opts = {}) {
|
|
|
798
818
|
result.skipped.push(known.rulesDir);
|
|
799
819
|
continue;
|
|
800
820
|
}
|
|
801
|
-
const mdFiles =
|
|
821
|
+
const mdFiles = readdirSync3(absDir).filter((f) => f.endsWith(".md"));
|
|
802
822
|
for (const f of mdFiles) {
|
|
803
823
|
const abs2 = join3(absDir, f);
|
|
804
824
|
const targetPath = abs2.replace(home, "~");
|
|
@@ -1001,7 +1021,7 @@ var init_sync = __esm(() => {
|
|
|
1001
1021
|
var require_package = __commonJS((exports, module) => {
|
|
1002
1022
|
module.exports = {
|
|
1003
1023
|
name: "@hasna/configs",
|
|
1004
|
-
version: "0.2.
|
|
1024
|
+
version: "0.2.27",
|
|
1005
1025
|
description: "AI coding agent configuration manager \u2014 store, version, apply, and share all your AI coding configs. CLI + MCP + REST API + Dashboard.",
|
|
1006
1026
|
type: "module",
|
|
1007
1027
|
main: "dist/index.js",
|
|
@@ -1048,6 +1068,7 @@ var require_package = __commonJS((exports, module) => {
|
|
|
1048
1068
|
"dashboard"
|
|
1049
1069
|
],
|
|
1050
1070
|
publishConfig: {
|
|
1071
|
+
registry: "https://registry.npmjs.org",
|
|
1051
1072
|
access: "public"
|
|
1052
1073
|
},
|
|
1053
1074
|
repository: {
|
|
@@ -1340,7 +1361,7 @@ server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
|
1340
1361
|
drifted,
|
|
1341
1362
|
drifted_configs: driftedSlugs.slice(0, 5),
|
|
1342
1363
|
missing,
|
|
1343
|
-
db_path: process.env["CONFIGS_DB_PATH"] || "~/.configs/configs.db"
|
|
1364
|
+
db_path: process.env["CONFIGS_DB_PATH"] || "~/.hasna/configs/configs.db"
|
|
1344
1365
|
});
|
|
1345
1366
|
}
|
|
1346
1367
|
case "sync_known": {
|
package/dist/server/index.js
CHANGED
|
@@ -48,15 +48,35 @@ var init_types = __esm(() => {
|
|
|
48
48
|
|
|
49
49
|
// src/db/database.ts
|
|
50
50
|
import { Database } from "bun:sqlite";
|
|
51
|
-
import { existsSync, mkdirSync } from "fs";
|
|
51
|
+
import { existsSync, mkdirSync, readdirSync, copyFileSync, statSync } from "fs";
|
|
52
52
|
import { dirname, join, resolve } from "path";
|
|
53
53
|
import { randomUUID } from "crypto";
|
|
54
54
|
function getDbPath() {
|
|
55
|
+
if (process.env["HASNA_CONFIGS_DB_PATH"]) {
|
|
56
|
+
return process.env["HASNA_CONFIGS_DB_PATH"];
|
|
57
|
+
}
|
|
55
58
|
if (process.env["CONFIGS_DB_PATH"]) {
|
|
56
59
|
return process.env["CONFIGS_DB_PATH"];
|
|
57
60
|
}
|
|
58
61
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
59
|
-
|
|
62
|
+
const newDir = join(home, ".hasna", "configs");
|
|
63
|
+
const oldDir = join(home, ".configs");
|
|
64
|
+
if (existsSync(oldDir) && !existsSync(newDir)) {
|
|
65
|
+
mkdirSync(newDir, { recursive: true });
|
|
66
|
+
try {
|
|
67
|
+
for (const file of readdirSync(oldDir)) {
|
|
68
|
+
const oldPath = join(oldDir, file);
|
|
69
|
+
const newPath = join(newDir, file);
|
|
70
|
+
try {
|
|
71
|
+
if (statSync(oldPath).isFile()) {
|
|
72
|
+
copyFileSync(oldPath, newPath);
|
|
73
|
+
}
|
|
74
|
+
} catch {}
|
|
75
|
+
}
|
|
76
|
+
} catch {}
|
|
77
|
+
}
|
|
78
|
+
mkdirSync(newDir, { recursive: true });
|
|
79
|
+
return join(newDir, "configs.db");
|
|
60
80
|
}
|
|
61
81
|
function ensureDir(filePath) {
|
|
62
82
|
if (filePath === ":memory:" || filePath.startsWith("file::memory:"))
|
|
@@ -595,7 +615,7 @@ var init_redact = __esm(() => {
|
|
|
595
615
|
});
|
|
596
616
|
|
|
597
617
|
// src/lib/sync-dir.ts
|
|
598
|
-
import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync2, statSync } from "fs";
|
|
618
|
+
import { existsSync as existsSync3, readdirSync as readdirSync2, readFileSync as readFileSync2, statSync as statSync2 } from "fs";
|
|
599
619
|
import { join as join2, relative } from "path";
|
|
600
620
|
import { homedir as homedir2 } from "os";
|
|
601
621
|
function shouldSkip(p) {
|
|
@@ -606,7 +626,7 @@ async function syncFromDir(dir, opts = {}) {
|
|
|
606
626
|
const absDir = expandPath(dir);
|
|
607
627
|
if (!existsSync3(absDir))
|
|
608
628
|
return { added: 0, updated: 0, unchanged: 0, skipped: [`Not found: ${absDir}`] };
|
|
609
|
-
const files = opts.recursive !== false ? walkDir(absDir) :
|
|
629
|
+
const files = opts.recursive !== false ? walkDir(absDir) : readdirSync2(absDir).map((f) => join2(absDir, f)).filter((f) => statSync2(f).isFile());
|
|
610
630
|
const result = { added: 0, updated: 0, unchanged: 0, skipped: [] };
|
|
611
631
|
const home = homedir2();
|
|
612
632
|
const allConfigs = listConfigs(undefined, d);
|
|
@@ -660,7 +680,7 @@ async function syncToDir(dir, opts = {}) {
|
|
|
660
680
|
return result;
|
|
661
681
|
}
|
|
662
682
|
function walkDir(dir, files = []) {
|
|
663
|
-
for (const entry of
|
|
683
|
+
for (const entry of readdirSync2(dir, { withFileTypes: true })) {
|
|
664
684
|
const full = join2(dir, entry.name);
|
|
665
685
|
if (shouldSkip(full))
|
|
666
686
|
continue;
|
|
@@ -695,7 +715,7 @@ __export(exports_sync, {
|
|
|
695
715
|
PROJECT_CONFIG_FILES: () => PROJECT_CONFIG_FILES,
|
|
696
716
|
KNOWN_CONFIGS: () => KNOWN_CONFIGS
|
|
697
717
|
});
|
|
698
|
-
import { existsSync as existsSync4, readdirSync as
|
|
718
|
+
import { existsSync as existsSync4, readdirSync as readdirSync3, readFileSync as readFileSync3 } from "fs";
|
|
699
719
|
import { extname, join as join3 } from "path";
|
|
700
720
|
import { homedir as homedir3 } from "os";
|
|
701
721
|
async function syncProject(opts) {
|
|
@@ -736,7 +756,7 @@ async function syncProject(opts) {
|
|
|
736
756
|
}
|
|
737
757
|
const rulesDir = join3(absDir, ".claude", "rules");
|
|
738
758
|
if (existsSync4(rulesDir)) {
|
|
739
|
-
const mdFiles =
|
|
759
|
+
const mdFiles = readdirSync3(rulesDir).filter((f) => f.endsWith(".md"));
|
|
740
760
|
for (const f of mdFiles) {
|
|
741
761
|
const abs = join3(rulesDir, f);
|
|
742
762
|
const raw2 = readFileSync3(abs, "utf-8");
|
|
@@ -777,7 +797,7 @@ async function syncKnown(opts = {}) {
|
|
|
777
797
|
result.skipped.push(known.rulesDir);
|
|
778
798
|
continue;
|
|
779
799
|
}
|
|
780
|
-
const mdFiles =
|
|
800
|
+
const mdFiles = readdirSync3(absDir).filter((f) => f.endsWith(".md"));
|
|
781
801
|
for (const f of mdFiles) {
|
|
782
802
|
const abs2 = join3(absDir, f);
|
|
783
803
|
const targetPath = abs2.replace(home, "~");
|
|
@@ -2785,7 +2805,7 @@ app.get("/api/status", (c) => {
|
|
|
2785
2805
|
total: stats["total"] || 0,
|
|
2786
2806
|
by_category: Object.fromEntries(Object.entries(stats).filter(([k]) => k !== "total")),
|
|
2787
2807
|
templates,
|
|
2788
|
-
db_path: process.env["CONFIGS_DB_PATH"] || "~/.configs/configs.db"
|
|
2808
|
+
db_path: process.env["CONFIGS_DB_PATH"] || "~/.hasna/configs/configs.db"
|
|
2789
2809
|
});
|
|
2790
2810
|
});
|
|
2791
2811
|
app.post("/api/sync-known", async (c) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hasna/configs",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.27",
|
|
4
4
|
"description": "AI coding agent configuration manager — store, version, apply, and share all your AI coding configs. CLI + MCP + REST API + Dashboard.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|