@hasna/configs 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/dist/cli/index.js +51 -0
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -2394,6 +2394,12 @@ var init_snapshots = __esm(() => {
2394
2394
  });
2395
2395
 
2396
2396
  // src/lib/apply.ts
2397
+ var exports_apply = {};
2398
+ __export(exports_apply, {
2399
+ expandPath: () => expandPath,
2400
+ applyConfigs: () => applyConfigs,
2401
+ applyConfig: () => applyConfig
2402
+ });
2397
2403
  import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync, writeFileSync } from "fs";
2398
2404
  import { dirname as dirname2, resolve as resolve2 } from "path";
2399
2405
  import { homedir } from "os";
@@ -3882,5 +3888,50 @@ _configs_completions() {
3882
3888
  complete -F _configs_completions configs`);
3883
3889
  }
3884
3890
  });
3891
+ program.command("watch").description("Watch known config files for changes and auto-sync to DB").option("-i, --interval <ms>", "poll interval in milliseconds", "3000").action(async (opts) => {
3892
+ const interval = Number(opts.interval);
3893
+ const { statSync: st } = await import("fs");
3894
+ const { expandPath: expandPath2 } = await Promise.resolve().then(() => (init_apply(), exports_apply));
3895
+ console.log(chalk.bold("@hasna/configs watch") + chalk.dim(` \u2014 polling every ${interval}ms`));
3896
+ console.log(chalk.dim(`Watching known config files for changes\u2026
3897
+ `));
3898
+ const mtimes = new Map;
3899
+ for (const k of KNOWN_CONFIGS) {
3900
+ if (k.rulesDir) {
3901
+ const absDir = expandPath2(k.rulesDir);
3902
+ if (!existsSync7(absDir))
3903
+ continue;
3904
+ const { readdirSync: readdirSync3 } = await import("fs");
3905
+ for (const f of readdirSync3(absDir).filter((f2) => f2.endsWith(".md"))) {
3906
+ const abs = join6(absDir, f);
3907
+ mtimes.set(abs, st(abs).mtimeMs);
3908
+ }
3909
+ } else {
3910
+ const abs = expandPath2(k.path);
3911
+ if (existsSync7(abs))
3912
+ mtimes.set(abs, st(abs).mtimeMs);
3913
+ }
3914
+ }
3915
+ console.log(chalk.dim(`Tracking ${mtimes.size} files`));
3916
+ const tick = async () => {
3917
+ let changed = 0;
3918
+ for (const [abs, oldMtime] of mtimes) {
3919
+ if (!existsSync7(abs))
3920
+ continue;
3921
+ const newMtime = st(abs).mtimeMs;
3922
+ if (newMtime !== oldMtime) {
3923
+ changed++;
3924
+ mtimes.set(abs, newMtime);
3925
+ }
3926
+ }
3927
+ if (changed > 0) {
3928
+ const result = await syncKnown({});
3929
+ const ts = new Date().toLocaleTimeString();
3930
+ console.log(`${chalk.dim(ts)} ${chalk.green("\u2713")} ${changed} file(s) changed \u2192 synced +${result.added} updated:${result.updated}`);
3931
+ }
3932
+ };
3933
+ setInterval(tick, interval);
3934
+ await new Promise(() => {});
3935
+ });
3885
3936
  program.version(pkg.version).name("configs");
3886
3937
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/configs",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
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",