@hasna/configs 0.2.9 → 0.2.10

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 +50 -1
  2. package/package.json +1 -1
package/dist/cli/index.js CHANGED
@@ -2364,6 +2364,11 @@ function updateConfig(idOrSlug, input, db) {
2364
2364
  d.run(`UPDATE configs SET ${updates.join(", ")} WHERE id = ?`, params);
2365
2365
  return getConfigById(existing.id, d);
2366
2366
  }
2367
+ function deleteConfig(idOrSlug, db) {
2368
+ const d = db || getDatabase();
2369
+ const existing = getConfig(idOrSlug, d);
2370
+ d.run("DELETE FROM configs WHERE id = ?", [existing.id]);
2371
+ }
2367
2372
  function getConfigStats(db) {
2368
2373
  const d = db || getDatabase();
2369
2374
  const rows = d.query("SELECT category, COUNT(*) as count FROM configs GROUP BY category").all();
@@ -4083,15 +4088,59 @@ program.command("watch").description("Watch known config files for changes and a
4083
4088
  mtimes.set(abs, newMtime);
4084
4089
  }
4085
4090
  }
4091
+ const { readdirSync: rd } = await import("fs");
4092
+ for (const k of KNOWN_CONFIGS) {
4093
+ if (k.rulesDir) {
4094
+ const absDir = expandPath2(k.rulesDir);
4095
+ if (!existsSync7(absDir))
4096
+ continue;
4097
+ for (const f of rd(absDir).filter((f2) => f2.endsWith(".md"))) {
4098
+ const abs = join6(absDir, f);
4099
+ if (!mtimes.has(abs)) {
4100
+ mtimes.set(abs, st(abs).mtimeMs);
4101
+ changed++;
4102
+ }
4103
+ }
4104
+ } else {
4105
+ const abs = expandPath2(k.path);
4106
+ if (existsSync7(abs) && !mtimes.has(abs)) {
4107
+ mtimes.set(abs, st(abs).mtimeMs);
4108
+ changed++;
4109
+ }
4110
+ }
4111
+ }
4086
4112
  if (changed > 0) {
4087
4113
  const result = await syncKnown({});
4088
4114
  const ts = new Date().toLocaleTimeString();
4089
- console.log(`${chalk.dim(ts)} ${chalk.green("\u2713")} ${changed} file(s) changed \u2192 synced +${result.added} updated:${result.updated}`);
4115
+ console.log(`${chalk.dim(ts)} ${chalk.green("\u2713")} ${changed} file(s) changed/new \u2192 synced +${result.added} updated:${result.updated}`);
4090
4116
  }
4091
4117
  };
4092
4118
  setInterval(tick, interval);
4093
4119
  await new Promise(() => {});
4094
4120
  });
4121
+ program.command("clean").description("Remove configs from DB whose target files no longer exist on disk").option("--dry-run", "show what would be removed").action(async (opts) => {
4122
+ const configs = listConfigs({ kind: "file" });
4123
+ let removed = 0;
4124
+ for (const c of configs) {
4125
+ if (!c.target_path)
4126
+ continue;
4127
+ const abs = expandPath(c.target_path);
4128
+ if (!existsSync7(abs)) {
4129
+ if (opts.dryRun) {
4130
+ console.log(chalk.yellow(" would remove:") + ` ${c.slug} ${chalk.dim(`(${c.target_path})`)}`);
4131
+ } else {
4132
+ deleteConfig(c.id);
4133
+ console.log(chalk.red(" removed:") + ` ${c.slug} ${chalk.dim(`(${c.target_path})`)}`);
4134
+ }
4135
+ removed++;
4136
+ }
4137
+ }
4138
+ if (removed === 0)
4139
+ console.log(chalk.green("\u2713") + " All stored configs still exist on disk.");
4140
+ else
4141
+ console.log(chalk.dim(`
4142
+ ${removed} orphaned config(s) ${opts.dryRun ? "found" : "removed"}`));
4143
+ });
4095
4144
  program.command("bootstrap").description("Install the full @hasna ecosystem: CLI tools + MCP servers + configs").option("--dry-run", "show what would be installed without doing it").option("--skip-mcp", "skip MCP server registration").action(async (opts) => {
4096
4145
  const packages = [
4097
4146
  { name: "@hasna/todos", bin: "todos", mcp: "todos-mcp" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/configs",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
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",