@hasna/configs 0.2.25 → 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/LICENSE +170 -0
- 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 +2 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
48
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
49
|
+
authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submitted" means any form of electronic, verbal,
|
|
51
|
+
or written communication sent to the Licensor or its representatives,
|
|
52
|
+
including but not limited to communication on electronic mailing lists,
|
|
53
|
+
source code control systems, and issue tracking systems that are managed
|
|
54
|
+
by, or on behalf of, the Licensor for the purpose of recording and
|
|
55
|
+
discussing the Work, but excluding communication that is conspicuously
|
|
56
|
+
marked or designated in writing by the copyright owner as "Not a
|
|
57
|
+
Contribution."
|
|
58
|
+
|
|
59
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
60
|
+
whom a Contribution has been received by the Licensor and included
|
|
61
|
+
within the Work.
|
|
62
|
+
|
|
63
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
64
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
65
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
66
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
67
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
68
|
+
Work and such Derivative Works in Source or Object form.
|
|
69
|
+
|
|
70
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
71
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
72
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
73
|
+
(except as stated in this section) patent license to make, have made,
|
|
74
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
75
|
+
where such license applies only to those patent contributions
|
|
76
|
+
Licensors can make available under this License.
|
|
77
|
+
|
|
78
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
79
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
80
|
+
modifications, and in Source or Object form, provided that You
|
|
81
|
+
meet the following conditions:
|
|
82
|
+
|
|
83
|
+
(a) You must give any other recipients of the Work or Derivative Works
|
|
84
|
+
a copy of this License; and
|
|
85
|
+
|
|
86
|
+
(b) You must cause any modified files to carry prominent notices
|
|
87
|
+
stating that You changed the files; and
|
|
88
|
+
|
|
89
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
90
|
+
that You distribute, all copyright, patent, trademark, and
|
|
91
|
+
attribution notices from the Source form of the Work,
|
|
92
|
+
excluding those notices that do not pertain to any part of
|
|
93
|
+
the Derivative Works; and
|
|
94
|
+
|
|
95
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
96
|
+
distribution, You must include a readable copy of the attribution
|
|
97
|
+
notices contained within such NOTICE file, in at least one
|
|
98
|
+
of the following places: within a NOTICE text file distributed
|
|
99
|
+
as part of the Derivative Works; within the Source form or
|
|
100
|
+
documentation, if provided along with the Derivative Works; or,
|
|
101
|
+
within a display generated by the Derivative Works, if and
|
|
102
|
+
wherever such third-party notices normally appear. The contents
|
|
103
|
+
of the NOTICE file are for informational purposes only and
|
|
104
|
+
do not modify the License. You may add Your own attribution
|
|
105
|
+
notices within Derivative Works that You distribute, alongside
|
|
106
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
107
|
+
that such additional attribution notices cannot be construed
|
|
108
|
+
as modifying the License.
|
|
109
|
+
|
|
110
|
+
You may add Your own license statement for Your modifications and
|
|
111
|
+
may provide additional grant of rights to use, copy, modify, merge,
|
|
112
|
+
publish, distribute, sublicense, and/or sell copies of the Software.
|
|
113
|
+
|
|
114
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
115
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
116
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
117
|
+
this License, without any additional terms or conditions.
|
|
118
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
119
|
+
the terms of any separate license agreement you may have executed
|
|
120
|
+
with Licensor regarding such Contributions.
|
|
121
|
+
|
|
122
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
123
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
124
|
+
except as required for reasonable and customary use in describing the
|
|
125
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
126
|
+
|
|
127
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
128
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
129
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
130
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
131
|
+
implied, including, without limitation, any warranties or conditions
|
|
132
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
133
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
134
|
+
appropriateness of using or redistributing the Work and assume any
|
|
135
|
+
risks associated with Your exercise of permissions under this License.
|
|
136
|
+
|
|
137
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
138
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
139
|
+
unless required by applicable law (such as deliberate and grossly
|
|
140
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
141
|
+
liable to You for damages, including any direct, indirect, special,
|
|
142
|
+
incidental, or exemplary damages of any character arising as a
|
|
143
|
+
result of this License or out of the use or inability to use the
|
|
144
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
145
|
+
work stoppage, computer failure or malfunction, or all other
|
|
146
|
+
commercial damages or losses), even if such Contributor has been
|
|
147
|
+
advised of the possibility of such damages.
|
|
148
|
+
|
|
149
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
150
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
151
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
152
|
+
or other liability obligations and/or rights consistent with this
|
|
153
|
+
License. However, in accepting such obligations, You may offer only
|
|
154
|
+
conditions consistent with this License.
|
|
155
|
+
|
|
156
|
+
END OF TERMS AND CONDITIONS
|
|
157
|
+
|
|
158
|
+
Copyright 2024 hasna.com
|
|
159
|
+
|
|
160
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
161
|
+
you may not use this file except in compliance with the License.
|
|
162
|
+
You may obtain a copy of the License at
|
|
163
|
+
|
|
164
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
165
|
+
|
|
166
|
+
Unless required by applicable law or agreed to in writing, software
|
|
167
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
168
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
169
|
+
See the License for the specific language governing permissions and
|
|
170
|
+
limitations under the License.
|
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",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"dashboard"
|
|
48
48
|
],
|
|
49
49
|
"publishConfig": {
|
|
50
|
+
"registry": "https://registry.npmjs.org",
|
|
50
51
|
"access": "public"
|
|
51
52
|
},
|
|
52
53
|
"repository": {
|