slopbrick 0.11.1 → 0.11.2

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/index.cjs CHANGED
@@ -36,7 +36,7 @@ var VERSION, AI_SECURITY_NUMERIC, REPOSITORY_HEALTH_WEIGHTS;
36
36
  var init_types = __esm({
37
37
  "src/types.ts"() {
38
38
  "use strict";
39
- VERSION = "0.11.1";
39
+ VERSION = "0.11.2";
40
40
  AI_SECURITY_NUMERIC = {
41
41
  low: 100,
42
42
  medium: 75,
@@ -3486,7 +3486,7 @@ function discoverTestFiles(cwd) {
3486
3486
  }
3487
3487
  return found;
3488
3488
  }
3489
- function walk(dir, out, readdirSync6, statSync7) {
3489
+ function walk(dir, out, readdirSync6, statSync8) {
3490
3490
  let entries;
3491
3491
  try {
3492
3492
  entries = readdirSync6(dir);
@@ -3498,12 +3498,12 @@ function walk(dir, out, readdirSync6, statSync7) {
3498
3498
  const full = `${dir}/${entry}`;
3499
3499
  let stat;
3500
3500
  try {
3501
- stat = statSync7(full);
3501
+ stat = statSync8(full);
3502
3502
  } catch {
3503
3503
  continue;
3504
3504
  }
3505
3505
  if (stat.isDirectory()) {
3506
- walk(full, out, readdirSync6, statSync7);
3506
+ walk(full, out, readdirSync6, statSync8);
3507
3507
  } else if (stat.isFile()) {
3508
3508
  if (/\.(test|spec)\.[jt]sx?$/.test(entry) || /\.stories\.[jt]sx?$/.test(entry)) {
3509
3509
  out.push(full);
@@ -9412,8 +9412,8 @@ function hasExtendedSibling(filePath) {
9412
9412
  const base = (0, import_node_path7.basename)(filePath);
9413
9413
  for (const ext of SOURCE_EXTENSIONS) {
9414
9414
  try {
9415
- const { statSync: statSync7 } = require("fs");
9416
- statSync7((0, import_node_path7.join)(dir, base + ext));
9415
+ const { statSync: statSync8 } = require("fs");
9416
+ statSync8((0, import_node_path7.join)(dir, base + ext));
9417
9417
  return true;
9418
9418
  } catch {
9419
9419
  }
@@ -9571,8 +9571,8 @@ var init_git = __esm({
9571
9571
  });
9572
9572
 
9573
9573
  // src/engine/cache-incremental.ts
9574
- function loadCache(cachePath6) {
9575
- const abs = (0, import_node_path8.isAbsolute)(cachePath6) ? cachePath6 : (0, import_node_path8.resolve)(process.cwd(), cachePath6);
9574
+ function loadCache(cachePath4) {
9575
+ const abs = (0, import_node_path8.isAbsolute)(cachePath4) ? cachePath4 : (0, import_node_path8.resolve)(process.cwd(), cachePath4);
9576
9576
  if (!(0, import_node_fs9.existsSync)(abs)) return void 0;
9577
9577
  try {
9578
9578
  const raw = (0, import_node_fs9.readFileSync)(abs, "utf-8");
@@ -9583,8 +9583,8 @@ function loadCache(cachePath6) {
9583
9583
  return void 0;
9584
9584
  }
9585
9585
  }
9586
- function saveCache(cachePath6, cache) {
9587
- const abs = (0, import_node_path8.isAbsolute)(cachePath6) ? cachePath6 : (0, import_node_path8.resolve)(process.cwd(), cachePath6);
9586
+ function saveCache(cachePath4, cache) {
9587
+ const abs = (0, import_node_path8.isAbsolute)(cachePath4) ? cachePath4 : (0, import_node_path8.resolve)(process.cwd(), cachePath4);
9588
9588
  (0, import_node_fs9.mkdirSync)((0, import_node_path8.dirname)(abs), { recursive: true });
9589
9589
  const tmp = abs + ".tmp";
9590
9590
  if ((0, import_node_fs9.existsSync)(tmp)) {
@@ -12889,12 +12889,41 @@ var init_heatmap = __esm({
12889
12889
  }
12890
12890
  });
12891
12891
 
12892
- // src/engine/memory.ts
12893
- async function saveInventory(workspaceDir, inventory, computeHash = computeFileHash) {
12894
- const { saveInventory: coreSave } = await import("@usebrick/core");
12895
- coreSave(workspaceDir, inventory);
12896
- (0, import_core4.writeCacheFromInventory)(workspaceDir, inventory, computeHash);
12892
+ // ../core/dist/index.js
12893
+ function inventoryPath(workspaceDir) {
12894
+ return (0, import_path.join)(workspaceDir, ".slopbrick", INVENTORY_FILENAME);
12895
+ }
12896
+ function constitutionPath(workspaceDir) {
12897
+ return (0, import_path.join)(workspaceDir, ".slopbrick", CONSTITUTION_FILENAME);
12898
+ }
12899
+ function ensureSlopbrickDir(workspaceDir) {
12900
+ (0, import_fs.mkdirSync)((0, import_path.join)(workspaceDir, ".slopbrick"), { recursive: true });
12901
+ }
12902
+ function writeJsonAtomic(filePath, payload) {
12903
+ ensureSlopbrickDir((0, import_path.dirname)(filePath));
12904
+ const tmp = `${filePath}.tmp`;
12905
+ (0, import_fs.writeFileSync)(tmp, JSON.stringify(payload, null, 2), "utf-8");
12906
+ (0, import_fs.renameSync)(tmp, filePath);
12907
+ }
12908
+ function saveInventory(workspaceDir, inventory) {
12909
+ writeJsonAtomic(inventoryPath(workspaceDir), inventory);
12910
+ }
12911
+ function saveConstitution(workspaceDir, constitution) {
12912
+ writeJsonAtomic(constitutionPath(workspaceDir), constitution);
12897
12913
  }
12914
+ var import_fs, import_path, MEMORY_SCHEMA_VERSION, INVENTORY_FILENAME, CONSTITUTION_FILENAME;
12915
+ var init_dist = __esm({
12916
+ "../core/dist/index.js"() {
12917
+ "use strict";
12918
+ import_fs = require("fs");
12919
+ import_path = require("path");
12920
+ MEMORY_SCHEMA_VERSION = "2";
12921
+ INVENTORY_FILENAME = "inventory.json";
12922
+ CONSTITUTION_FILENAME = "constitution.json";
12923
+ }
12924
+ });
12925
+
12926
+ // src/engine/memory.ts
12898
12927
  function telemetryPath(cwd) {
12899
12928
  return (0, import_node_path17.join)(cwd, TELEMETRY_FILE);
12900
12929
  }
@@ -12969,7 +12998,7 @@ async function buildInventoryFromScan(scanResult, config, durationMs) {
12969
12998
  );
12970
12999
  const components = buildComponentFingerprints(scanResult.results);
12971
13000
  return {
12972
- version: import_core4.MEMORY_SCHEMA_VERSION,
13001
+ version: MEMORY_SCHEMA_VERSION,
12973
13002
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
12974
13003
  workspace: scanResult.cwd,
12975
13004
  scannedFiles: inventory.scannedFiles,
@@ -13004,7 +13033,7 @@ function buildConstitutionFromConfig(config, workspace) {
13004
13033
  const forbidden = forbiddenList.filter((e) => !e.endsWith("/"));
13005
13034
  const forbiddenPrefixes = forbiddenList.filter((e) => e.endsWith("/"));
13006
13035
  return {
13007
- version: import_core4.MEMORY_SCHEMA_VERSION,
13036
+ version: MEMORY_SCHEMA_VERSION,
13008
13037
  generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
13009
13038
  workspace,
13010
13039
  declared,
@@ -13050,7 +13079,7 @@ function buildComponentFingerprints(results) {
13050
13079
  }
13051
13080
  return [...byName.values()].sort((a, b) => a.name.localeCompare(b.name));
13052
13081
  }
13053
- var import_node_fs16, import_node_path17, import_node_crypto6, import_core4, import_core5, TELEMETRY_FILE, MAX_RUNS;
13082
+ var import_node_fs16, import_node_path17, import_node_crypto6, TELEMETRY_FILE, MAX_RUNS;
13054
13083
  var init_memory = __esm({
13055
13084
  "src/engine/memory.ts"() {
13056
13085
  "use strict";
@@ -13060,8 +13089,7 @@ var init_memory = __esm({
13060
13089
  init_types();
13061
13090
  init_patterns();
13062
13091
  init_cache_incremental();
13063
- import_core4 = require("@usebrick/core");
13064
- import_core5 = require("@usebrick/core");
13092
+ init_dist();
13065
13093
  TELEMETRY_FILE = (0, import_node_path17.join)(".slopbrick", "memory.json");
13066
13094
  MAX_RUNS = 1e3;
13067
13095
  }
@@ -15508,8 +15536,8 @@ async function runScan(options, explicitPaths) {
15508
15536
  }
15509
15537
  let incrementalSummary;
15510
15538
  if (options.incremental) {
15511
- const cachePath6 = options.cachePath ?? ".slopbrick-cache.json";
15512
- const existing = loadCache(cachePath6);
15539
+ const cachePath4 = options.cachePath ?? ".slopbrick-cache.json";
15540
+ const existing = loadCache(cachePath4);
15513
15541
  const { toScan, unchanged } = partitionByCache(files, existing);
15514
15542
  files = toScan;
15515
15543
  incrementalSummary = { skipped: unchanged.length, rescanned: toScan.length };
@@ -15928,8 +15956,8 @@ async function runScan(options, explicitPaths) {
15928
15956
  appendRun(cwd, report, thresholdExceeded(report, config));
15929
15957
  }
15930
15958
  if (options.incremental) {
15931
- const cachePath6 = options.cachePath ?? ".slopbrick-cache.json";
15932
- const existing = loadCache(cachePath6) ?? emptyCache();
15959
+ const cachePath4 = options.cachePath ?? ".slopbrick-cache.json";
15960
+ const existing = loadCache(cachePath4) ?? emptyCache();
15933
15961
  const next = { ...existing, generatedAt: (/* @__PURE__ */ new Date()).toISOString() };
15934
15962
  for (const result of results) {
15935
15963
  try {
@@ -15943,7 +15971,7 @@ async function runScan(options, explicitPaths) {
15943
15971
  } catch {
15944
15972
  }
15945
15973
  }
15946
- saveCache(cachePath6, next);
15974
+ saveCache(cachePath4, next);
15947
15975
  if (incrementalSummary && !options.quiet) {
15948
15976
  logger.info(
15949
15977
  `Incremental: re-scanned ${incrementalSummary.rescanned}, skipped ${incrementalSummary.skipped} (unchanged).`
@@ -15995,7 +16023,7 @@ async function runScan(options, explicitPaths) {
15995
16023
  );
15996
16024
  await saveInventory(cwd, inventory);
15997
16025
  const constitution = buildConstitutionFromConfig(config, cwd);
15998
- await (0, import_core5.saveConstitution)(cwd, constitution);
16026
+ await saveConstitution(cwd, constitution);
15999
16027
  if (!options.quiet && !machineReadableStdout) {
16000
16028
  logger.info(`Memory persisted to .slopbrick/ (${inventory.patterns.length} patterns, ${inventory.components.length} components).`);
16001
16029
  }
@@ -16313,6 +16341,7 @@ var init_scan = __esm({
16313
16341
  init_unified_diff();
16314
16342
  init_heatmap();
16315
16343
  init_memory();
16344
+ init_dist();
16316
16345
  init_telemetry();
16317
16346
  init_flywheel();
16318
16347
  init_logger();
@@ -16764,14 +16793,14 @@ async function runBusinessLogicScore(args, ctx) {
16764
16793
  const maxFiles = typeof maxFilesRaw === "number" && Number.isFinite(maxFilesRaw) && maxFilesRaw > 0 ? Math.min(2e3, Math.floor(maxFilesRaw)) : 500;
16765
16794
  try {
16766
16795
  const { discoverFiles: discoverFiles2 } = await Promise.resolve().then(() => (init_discover(), discover_exports));
16767
- const { readFileSync: readFileSync38 } = await import("fs");
16796
+ const { readFileSync: readFileSync39 } = await import("fs");
16768
16797
  const allFiles = await discoverFiles2(ctx.cwd, ctx.config);
16769
16798
  const limited = allFiles.slice(0, maxFiles);
16770
16799
  const issues = [];
16771
16800
  for (const absPath of limited) {
16772
16801
  let source;
16773
16802
  try {
16774
- source = readFileSync38(absPath, "utf-8");
16803
+ source = readFileSync39(absPath, "utf-8");
16775
16804
  } catch {
16776
16805
  continue;
16777
16806
  }
@@ -17216,17 +17245,11 @@ var init_migrate = __esm({
17216
17245
  var src_exports = {};
17217
17246
  __export(src_exports, {
17218
17247
  AI_SECURITY_NUMERIC: () => AI_SECURITY_NUMERIC,
17219
- CACHE_FILENAME: () => import_core6.CACHE_FILENAME,
17220
- CONSTITUTION_FILENAME: () => import_core6.CONSTITUTION_FILENAME,
17221
17248
  DEFAULT_CONFIG: () => DEFAULT_CONFIG,
17222
- INVENTORY_FILENAME: () => import_core6.INVENTORY_FILENAME,
17223
- MEMORY_SCHEMA_VERSION: () => import_core6.MEMORY_SCHEMA_VERSION,
17224
17249
  REPOSITORY_HEALTH_WEIGHTS: () => REPOSITORY_HEALTH_WEIGHTS,
17225
17250
  VERSION: () => VERSION,
17226
17251
  baselineStatusMessage: () => baselineStatusMessage,
17227
- cachePath: () => import_core6.cachePath,
17228
17252
  colorForSlop: () => colorForSlop,
17229
- constitutionPath: () => import_core6.constitutionPath,
17230
17253
  extractSignatures: () => extractSignatures,
17231
17254
  failedThresholdCount: () => failedThresholdCount,
17232
17255
  filterByDisabledDirectives: () => filterByDisabledDirectives,
@@ -17236,22 +17259,10 @@ __export(src_exports, {
17236
17259
  formatBadge: () => formatBadge,
17237
17260
  formatReportFromFile: () => formatReportFromFile,
17238
17261
  formatSparkline: () => formatSparkline,
17239
- invalidateFile: () => import_core6.invalidateFile,
17240
- inventoryPath: () => import_core6.inventoryPath,
17241
- isComponentFingerprint: () => import_core6.isComponentFingerprint,
17242
- isConstitutionFile: () => import_core6.isConstitutionFile,
17243
- isFileMtimeEntry: () => import_core6.isFileMtimeEntry,
17244
- isInventoryFile: () => import_core6.isInventoryFile,
17245
- isInventoryFresh: () => import_core6.isInventoryFresh,
17246
- isMemoryPattern: () => import_core6.isMemoryPattern,
17247
17262
  loadConfig: () => loadConfig,
17248
- loadConstitution: () => import_core6.loadConstitution,
17249
- loadInventory: () => import_core6.loadInventory,
17250
17263
  readReportFile: () => readReportFile,
17251
17264
  runCli: () => runCli,
17252
17265
  runInitWizard: () => runInitWizard,
17253
- saveConstitution: () => import_core6.saveConstitution,
17254
- saveInventory: () => import_core6.saveInventory,
17255
17266
  scanProject: () => scanProject,
17256
17267
  serializeConfig: () => serializeConfig,
17257
17268
  signatureSimilarity: () => signatureSimilarity,
@@ -18674,11 +18685,11 @@ var shadcn_registry_default = {
18674
18685
  // src/rules/registry-loader.ts
18675
18686
  var REGISTRY_URL = "https://ui.shadcn.com/registry.json";
18676
18687
  var BUNDLED_REGISTRY_VERSION = shadcn_registry_default.version;
18677
- function cachePath4(cwd) {
18688
+ function cachePath3(cwd) {
18678
18689
  return (0, import_node_path28.join)(cwd, ".slopbrick", "cache", "registry-snapshot.json");
18679
18690
  }
18680
18691
  function ensureCacheDir(cwd) {
18681
- const dir = (0, import_node_path28.dirname)(cachePath4(cwd));
18692
+ const dir = (0, import_node_path28.dirname)(cachePath3(cwd));
18682
18693
  if (!(0, import_node_fs27.existsSync)(dir)) {
18683
18694
  (0, import_node_fs27.mkdirSync)(dir, { recursive: true });
18684
18695
  }
@@ -18691,7 +18702,7 @@ function isValidSnapshot(value) {
18691
18702
  return true;
18692
18703
  }
18693
18704
  function isRegistryFresh(cwd) {
18694
- const cached = cachePath4(cwd);
18705
+ const cached = cachePath3(cwd);
18695
18706
  if (!(0, import_node_fs27.existsSync)(cached)) return false;
18696
18707
  try {
18697
18708
  const parsed = JSON.parse((0, import_node_fs27.readFileSync)(cached, "utf8"));
@@ -18728,7 +18739,7 @@ async function refreshRegistrySnapshot(cwd, url = REGISTRY_URL, timeoutMs = 5e3)
18728
18739
  };
18729
18740
  }
18730
18741
  ensureCacheDir(cwd);
18731
- (0, import_node_fs27.writeFileSync)(cachePath4(cwd), JSON.stringify(fetched, null, 2));
18742
+ (0, import_node_fs27.writeFileSync)(cachePath3(cwd), JSON.stringify(fetched, null, 2));
18732
18743
  const fresh = fetched.version === BUNDLED_REGISTRY_VERSION;
18733
18744
  return {
18734
18745
  ok: true,
@@ -18738,7 +18749,7 @@ async function refreshRegistrySnapshot(cwd, url = REGISTRY_URL, timeoutMs = 5e3)
18738
18749
  }
18739
18750
  function copyBundledSnapshotToCache(cwd) {
18740
18751
  ensureCacheDir(cwd);
18741
- (0, import_node_fs27.writeFileSync)(cachePath4(cwd), JSON.stringify(shadcn_registry_default, null, 2));
18752
+ (0, import_node_fs27.writeFileSync)(cachePath3(cwd), JSON.stringify(shadcn_registry_default, null, 2));
18742
18753
  }
18743
18754
 
18744
18755
  // src/cli/init.ts
@@ -21657,7 +21668,6 @@ ${formatMarkdown3(result.report)}`);
21657
21668
  init_threshold();
21658
21669
  init_render();
21659
21670
  init_find_similar();
21660
- var import_core6 = require("@usebrick/core");
21661
21671
  process.on("uncaughtException", (err) => {
21662
21672
  const { logger: logger6 } = (init_logger(), __toCommonJS(logger_exports));
21663
21673
  logger6.error(`Unexpected error: ${err.message}`);
@@ -21666,17 +21676,11 @@ process.on("uncaughtException", (err) => {
21666
21676
  // Annotate the CommonJS export names for ESM import in node:
21667
21677
  0 && (module.exports = {
21668
21678
  AI_SECURITY_NUMERIC,
21669
- CACHE_FILENAME,
21670
- CONSTITUTION_FILENAME,
21671
21679
  DEFAULT_CONFIG,
21672
- INVENTORY_FILENAME,
21673
- MEMORY_SCHEMA_VERSION,
21674
21680
  REPOSITORY_HEALTH_WEIGHTS,
21675
21681
  VERSION,
21676
21682
  baselineStatusMessage,
21677
- cachePath,
21678
21683
  colorForSlop,
21679
- constitutionPath,
21680
21684
  extractSignatures,
21681
21685
  failedThresholdCount,
21682
21686
  filterByDisabledDirectives,
@@ -21686,22 +21690,10 @@ process.on("uncaughtException", (err) => {
21686
21690
  formatBadge,
21687
21691
  formatReportFromFile,
21688
21692
  formatSparkline,
21689
- invalidateFile,
21690
- inventoryPath,
21691
- isComponentFingerprint,
21692
- isConstitutionFile,
21693
- isFileMtimeEntry,
21694
- isInventoryFile,
21695
- isInventoryFresh,
21696
- isMemoryPattern,
21697
21693
  loadConfig,
21698
- loadConstitution,
21699
- loadInventory,
21700
21694
  readReportFile,
21701
21695
  runCli,
21702
21696
  runInitWizard,
21703
- saveConstitution,
21704
- saveInventory,
21705
21697
  scanProject,
21706
21698
  serializeConfig,
21707
21699
  signatureSimilarity,
package/dist/index.d.cts CHANGED
@@ -1,5 +1,3 @@
1
- export { CACHE_FILENAME, CONSTITUTION_FILENAME, ComponentFingerprint, ConstitutionFile, FileMtimeEntry, INVENTORY_FILENAME, InventoryFile, MEMORY_SCHEMA_VERSION, MemoryCategory, MemoryPattern, cachePath, constitutionPath, invalidateFile, inventoryPath, isComponentFingerprint, isConstitutionFile, isFileMtimeEntry, isInventoryFile, isInventoryFresh, isMemoryPattern, loadConstitution, loadInventory, saveConstitution, saveInventory } from '@usebrick/core';
2
-
3
1
  /**
4
2
  * Constitution declared by the user (or auto-detected from package.json).
5
3
  * Each allow-list field is a list of canonical names — agents and
@@ -272,7 +270,7 @@ interface SignalStrength {
272
270
  defaultOff?: boolean;
273
271
  }
274
272
 
275
- declare const VERSION = "0.11.1";
273
+ declare const VERSION = "0.11.2";
276
274
  /**
277
275
  * Categorical bucket for the AI Maintenance Cost score.
278
276
  *
package/dist/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- export { CACHE_FILENAME, CONSTITUTION_FILENAME, ComponentFingerprint, ConstitutionFile, FileMtimeEntry, INVENTORY_FILENAME, InventoryFile, MEMORY_SCHEMA_VERSION, MemoryCategory, MemoryPattern, cachePath, constitutionPath, invalidateFile, inventoryPath, isComponentFingerprint, isConstitutionFile, isFileMtimeEntry, isInventoryFile, isInventoryFresh, isMemoryPattern, loadConstitution, loadInventory, saveConstitution, saveInventory } from '@usebrick/core';
2
-
3
1
  /**
4
2
  * Constitution declared by the user (or auto-detected from package.json).
5
3
  * Each allow-list field is a list of canonical names — agents and
@@ -272,7 +270,7 @@ interface SignalStrength {
272
270
  defaultOff?: boolean;
273
271
  }
274
272
 
275
- declare const VERSION = "0.11.1";
273
+ declare const VERSION = "0.11.2";
276
274
  /**
277
275
  * Categorical bucket for the AI Maintenance Cost score.
278
276
  *