neuronlayer 0.1.9 → 0.2.0

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 (81) hide show
  1. package/README.md +3 -2
  2. package/dist/index.js +172 -90
  3. package/dist/index.js.map +7 -0
  4. package/package.json +6 -1
  5. package/esbuild.config.js +0 -26
  6. package/src/cli/commands.ts +0 -573
  7. package/src/core/adr-exporter.ts +0 -253
  8. package/src/core/architecture/architecture-enforcement.ts +0 -228
  9. package/src/core/architecture/duplicate-detector.ts +0 -288
  10. package/src/core/architecture/index.ts +0 -6
  11. package/src/core/architecture/pattern-learner.ts +0 -306
  12. package/src/core/architecture/pattern-library.ts +0 -403
  13. package/src/core/architecture/pattern-validator.ts +0 -324
  14. package/src/core/change-intelligence/bug-correlator.ts +0 -544
  15. package/src/core/change-intelligence/change-intelligence.ts +0 -264
  16. package/src/core/change-intelligence/change-tracker.ts +0 -334
  17. package/src/core/change-intelligence/fix-suggester.ts +0 -340
  18. package/src/core/change-intelligence/index.ts +0 -5
  19. package/src/core/code-verifier.ts +0 -843
  20. package/src/core/confidence/confidence-scorer.ts +0 -251
  21. package/src/core/confidence/conflict-checker.ts +0 -289
  22. package/src/core/confidence/index.ts +0 -5
  23. package/src/core/confidence/source-tracker.ts +0 -263
  24. package/src/core/confidence/warning-detector.ts +0 -241
  25. package/src/core/context-rot/compaction.ts +0 -284
  26. package/src/core/context-rot/context-health.ts +0 -243
  27. package/src/core/context-rot/context-rot-prevention.ts +0 -213
  28. package/src/core/context-rot/critical-context.ts +0 -221
  29. package/src/core/context-rot/drift-detector.ts +0 -255
  30. package/src/core/context-rot/index.ts +0 -7
  31. package/src/core/context.ts +0 -263
  32. package/src/core/decision-extractor.ts +0 -339
  33. package/src/core/decisions.ts +0 -69
  34. package/src/core/deja-vu.ts +0 -421
  35. package/src/core/engine.ts +0 -1646
  36. package/src/core/feature-context.ts +0 -726
  37. package/src/core/ghost-mode.ts +0 -465
  38. package/src/core/learning.ts +0 -519
  39. package/src/core/living-docs/activity-tracker.ts +0 -296
  40. package/src/core/living-docs/architecture-generator.ts +0 -428
  41. package/src/core/living-docs/changelog-generator.ts +0 -348
  42. package/src/core/living-docs/component-generator.ts +0 -230
  43. package/src/core/living-docs/doc-engine.ts +0 -134
  44. package/src/core/living-docs/doc-validator.ts +0 -282
  45. package/src/core/living-docs/index.ts +0 -8
  46. package/src/core/project-manager.ts +0 -301
  47. package/src/core/refresh/activity-gate.ts +0 -256
  48. package/src/core/refresh/git-staleness-checker.ts +0 -108
  49. package/src/core/refresh/index.ts +0 -27
  50. package/src/core/summarizer.ts +0 -290
  51. package/src/core/test-awareness/change-validator.ts +0 -499
  52. package/src/core/test-awareness/index.ts +0 -5
  53. package/src/index.ts +0 -90
  54. package/src/indexing/ast.ts +0 -868
  55. package/src/indexing/embeddings.ts +0 -85
  56. package/src/indexing/indexer.ts +0 -270
  57. package/src/indexing/watcher.ts +0 -78
  58. package/src/server/gateways/aggregator.ts +0 -374
  59. package/src/server/gateways/index.ts +0 -473
  60. package/src/server/gateways/memory-ghost.ts +0 -343
  61. package/src/server/gateways/memory-query.ts +0 -452
  62. package/src/server/gateways/memory-record.ts +0 -346
  63. package/src/server/gateways/memory-review.ts +0 -410
  64. package/src/server/gateways/memory-status.ts +0 -517
  65. package/src/server/gateways/memory-verify.ts +0 -392
  66. package/src/server/gateways/router.ts +0 -434
  67. package/src/server/gateways/types.ts +0 -610
  68. package/src/server/http.ts +0 -228
  69. package/src/server/mcp.ts +0 -154
  70. package/src/server/resources.ts +0 -85
  71. package/src/server/tools.ts +0 -2460
  72. package/src/storage/database.ts +0 -271
  73. package/src/storage/tier1.ts +0 -135
  74. package/src/storage/tier2.ts +0 -972
  75. package/src/storage/tier3.ts +0 -123
  76. package/src/types/documentation.ts +0 -619
  77. package/src/types/index.ts +0 -222
  78. package/src/utils/config.ts +0 -194
  79. package/src/utils/files.ts +0 -117
  80. package/src/utils/time.ts +0 -37
  81. package/src/utils/tokens.ts +0 -52
package/dist/index.js CHANGED
@@ -20822,7 +20822,7 @@ var StdioServerTransport = class {
20822
20822
 
20823
20823
  // src/core/engine.ts
20824
20824
  import { join as join13, basename as basename6 } from "path";
20825
- import { existsSync as existsSync13, mkdirSync as mkdirSync6, readFileSync as readFileSync10, renameSync } from "fs";
20825
+ import { existsSync as existsSync14, mkdirSync as mkdirSync7, readFileSync as readFileSync11, renameSync } from "fs";
20826
20826
 
20827
20827
  // src/storage/database.ts
20828
20828
  import Database from "better-sqlite3";
@@ -21999,7 +21999,7 @@ var Tier3Storage = class {
21999
21999
  };
22000
22000
 
22001
22001
  // src/indexing/indexer.ts
22002
- import { readFileSync as readFileSync2, statSync } from "fs";
22002
+ import { readFileSync as readFileSync3, statSync } from "fs";
22003
22003
  import { glob } from "glob";
22004
22004
  import { relative as relative2 } from "path";
22005
22005
  import { EventEmitter as EventEmitter2 } from "events";
@@ -22072,6 +22072,9 @@ var EmbeddingGenerator = class {
22072
22072
  };
22073
22073
 
22074
22074
  // src/indexing/ast.ts
22075
+ import Parser from "web-tree-sitter";
22076
+ import { readFileSync as readFileSync2, existsSync as existsSync3 } from "fs";
22077
+ import { fileURLToPath } from "url";
22075
22078
  var LANGUAGE_CONFIGS = {
22076
22079
  typescript: {
22077
22080
  wasmFile: "tree-sitter-typescript.wasm",
@@ -22170,10 +22173,33 @@ var ASTParser = class {
22170
22173
  }
22171
22174
  async initialize() {
22172
22175
  if (this.initialized) return;
22173
- this.initialized = true;
22176
+ try {
22177
+ await Parser.init();
22178
+ this.initialized = true;
22179
+ } catch (error2) {
22180
+ console.warn("Failed to initialize tree-sitter, will fall back to regex:", error2);
22181
+ }
22174
22182
  }
22175
- async loadLanguage(_langName) {
22176
- return null;
22183
+ async loadLanguage(langName) {
22184
+ if (this.languages.has(langName)) {
22185
+ return this.languages.get(langName);
22186
+ }
22187
+ const config2 = LANGUAGE_CONFIGS[langName];
22188
+ if (!config2 || !this.initialized) return null;
22189
+ try {
22190
+ const wasmPath = fileURLToPath(import.meta.resolve(`tree-sitter-wasms/out/${config2.wasmFile}`));
22191
+ if (!existsSync3(wasmPath)) {
22192
+ console.warn(`WASM file not found for ${langName}: ${wasmPath}`);
22193
+ return null;
22194
+ }
22195
+ const wasmData = readFileSync2(wasmPath);
22196
+ const language = await Parser.Language.load(wasmData);
22197
+ this.languages.set(langName, language);
22198
+ return language;
22199
+ } catch (error2) {
22200
+ console.warn(`Failed to load tree-sitter language ${langName}:`, error2);
22201
+ return null;
22202
+ }
22177
22203
  }
22178
22204
  getLanguageForFile(filePath) {
22179
22205
  const ext = filePath.slice(filePath.lastIndexOf(".")).toLowerCase();
@@ -22188,7 +22214,63 @@ var ASTParser = class {
22188
22214
  if (!this.initialized) {
22189
22215
  await this.initialize();
22190
22216
  }
22191
- return this.parseWithRegex(filePath, content);
22217
+ let { symbols, imports, exports } = this.parseWithRegex(filePath, content);
22218
+ const lang = this.getLanguageForFile(filePath);
22219
+ if (lang && this.initialized) {
22220
+ const language = await this.loadLanguage(lang);
22221
+ if (language) {
22222
+ try {
22223
+ const tsResult = this.parseWithTreeSitter(filePath, content, language, lang);
22224
+ if (tsResult.symbols.length > 0) {
22225
+ symbols = tsResult.symbols;
22226
+ }
22227
+ } catch (error2) {
22228
+ console.warn(`Tree-sitter parsing failed for ${filePath}, falling back to regex:`, error2);
22229
+ }
22230
+ }
22231
+ }
22232
+ return { symbols, imports, exports };
22233
+ }
22234
+ parseWithTreeSitter(filePath, content, language, langName) {
22235
+ const parser = new Parser();
22236
+ parser.setLanguage(language);
22237
+ const tree = parser.parse(content);
22238
+ const config2 = LANGUAGE_CONFIGS[langName];
22239
+ const symbols = [];
22240
+ const imports = [];
22241
+ const exports = [];
22242
+ if (!config2) return { symbols, imports, exports };
22243
+ const runQuery = (queryString, kind) => {
22244
+ try {
22245
+ const query = language.query(queryString);
22246
+ const matches = query.matches(tree.rootNode);
22247
+ for (const match of matches) {
22248
+ const nameCapture = match.captures.find((c) => c.name === "name");
22249
+ if (nameCapture) {
22250
+ const node = nameCapture.node;
22251
+ const defNode = match.captures[0]?.node || node.parent || node;
22252
+ symbols.push({
22253
+ fileId: 0,
22254
+ filePath,
22255
+ kind,
22256
+ name: node.text,
22257
+ lineStart: defNode.startPosition.row + 1,
22258
+ lineEnd: defNode.endPosition.row + 1,
22259
+ // Check if parent or grandparent is an export statement, typical in TS/JS
22260
+ exported: defNode.parent?.type === "export_statement" || defNode.parent?.parent?.type === "export_statement",
22261
+ signature: content.slice(defNode.startIndex, defNode.endIndex).split("\\n")[0]
22262
+ });
22263
+ }
22264
+ }
22265
+ } catch (err) {
22266
+ console.warn(`Query error for ${kind} in ${langName}:`, err);
22267
+ }
22268
+ };
22269
+ if (config2.queries.functions) runQuery(config2.queries.functions, "function");
22270
+ if (config2.queries.classes) runQuery(config2.queries.classes, "class");
22271
+ if (config2.queries.interfaces) runQuery(config2.queries.interfaces, "interface");
22272
+ if (config2.queries.types) runQuery(config2.queries.types, "type");
22273
+ return { symbols, imports, exports };
22192
22274
  }
22193
22275
  // Regex-based parsing for symbol extraction
22194
22276
  // Handles: functions, classes, interfaces, types, imports, exports
@@ -23002,7 +23084,7 @@ var Indexer = class extends EventEmitter2 {
23002
23084
  }
23003
23085
  async indexFile(absolutePath) {
23004
23086
  try {
23005
- const content = readFileSync2(absolutePath, "utf-8");
23087
+ const content = readFileSync3(absolutePath, "utf-8");
23006
23088
  const stats = statSync(absolutePath);
23007
23089
  const relativePath = relative2(this.config.projectPath, absolutePath);
23008
23090
  const contentHash = hashContent(content);
@@ -23460,7 +23542,7 @@ ${tags.join(" ")}`;
23460
23542
 
23461
23543
  // src/core/decision-extractor.ts
23462
23544
  import { execSync } from "child_process";
23463
- import { readFileSync as readFileSync3, existsSync as existsSync3 } from "fs";
23545
+ import { readFileSync as readFileSync4, existsSync as existsSync4 } from "fs";
23464
23546
  import { join as join3 } from "path";
23465
23547
  import { glob as glob2 } from "glob";
23466
23548
  import { randomUUID as randomUUID2 } from "crypto";
@@ -23501,7 +23583,7 @@ var DecisionExtractor = class {
23501
23583
  isGitRepo;
23502
23584
  constructor(projectPath) {
23503
23585
  this.projectPath = projectPath;
23504
- this.isGitRepo = existsSync3(join3(projectPath, ".git"));
23586
+ this.isGitRepo = existsSync4(join3(projectPath, ".git"));
23505
23587
  }
23506
23588
  async extractAll() {
23507
23589
  const decisions = [];
@@ -23575,7 +23657,7 @@ ${body}`.trim();
23575
23657
  });
23576
23658
  for (const file2 of files.slice(0, 100)) {
23577
23659
  try {
23578
- const content = readFileSync3(file2, "utf-8");
23660
+ const content = readFileSync4(file2, "utf-8");
23579
23661
  const lines = content.split("\n");
23580
23662
  for (let i = 0; i < lines.length; i++) {
23581
23663
  const line = lines[i] || "";
@@ -23621,7 +23703,7 @@ ${body}`.trim();
23621
23703
  });
23622
23704
  for (const file2 of files) {
23623
23705
  try {
23624
- const content = readFileSync3(file2, "utf-8");
23706
+ const content = readFileSync4(file2, "utf-8");
23625
23707
  const title = this.extractADRTitle(content);
23626
23708
  const status = this.extractADRStatus(content);
23627
23709
  if (title && status !== "superseded" && status !== "deprecated") {
@@ -24325,7 +24407,7 @@ var FileSummarizer = class {
24325
24407
  };
24326
24408
 
24327
24409
  // src/core/project-manager.ts
24328
- import { existsSync as existsSync4, mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync2, readdirSync } from "fs";
24410
+ import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync3, readdirSync } from "fs";
24329
24411
  import { join as join4, basename as basename2, resolve } from "path";
24330
24412
  import { createHash as createHash3 } from "crypto";
24331
24413
  import { homedir } from "os";
@@ -24337,15 +24419,15 @@ var ProjectManager = class {
24337
24419
  constructor() {
24338
24420
  this.baseDataDir = join4(homedir(), ".memorylayer");
24339
24421
  this.registryPath = join4(this.baseDataDir, "registry.json");
24340
- if (!existsSync4(this.baseDataDir)) {
24341
- mkdirSync3(this.baseDataDir, { recursive: true });
24422
+ if (!existsSync5(this.baseDataDir)) {
24423
+ mkdirSync4(this.baseDataDir, { recursive: true });
24342
24424
  }
24343
24425
  this.registry = this.loadRegistry();
24344
24426
  }
24345
24427
  loadRegistry() {
24346
24428
  try {
24347
- if (existsSync4(this.registryPath)) {
24348
- const data = JSON.parse(readFileSync4(this.registryPath, "utf-8"));
24429
+ if (existsSync5(this.registryPath)) {
24430
+ const data = JSON.parse(readFileSync5(this.registryPath, "utf-8"));
24349
24431
  return data;
24350
24432
  }
24351
24433
  } catch (error2) {
@@ -24359,7 +24441,7 @@ var ProjectManager = class {
24359
24441
  }
24360
24442
  saveRegistry() {
24361
24443
  try {
24362
- writeFileSync2(this.registryPath, JSON.stringify(this.registry, null, 2));
24444
+ writeFileSync3(this.registryPath, JSON.stringify(this.registry, null, 2));
24363
24445
  } catch (error2) {
24364
24446
  console.error("Error saving registry:", error2);
24365
24447
  }
@@ -24378,7 +24460,7 @@ var ProjectManager = class {
24378
24460
  const normalizedPath = resolve(projectPath);
24379
24461
  const projectId = this.generateProjectId(normalizedPath);
24380
24462
  const dataDir = this.getProjectDataDir(normalizedPath);
24381
- if (!existsSync4(normalizedPath)) {
24463
+ if (!existsSync5(normalizedPath)) {
24382
24464
  throw new Error(`Project path does not exist: ${normalizedPath}`);
24383
24465
  }
24384
24466
  const existingProject = this.registry.projects[projectId];
@@ -24498,7 +24580,7 @@ var ProjectManager = class {
24498
24580
  join4(homeDir, "Documents")
24499
24581
  ];
24500
24582
  for (const searchDir of searchDirs) {
24501
- if (!existsSync4(searchDir)) continue;
24583
+ if (!existsSync5(searchDir)) continue;
24502
24584
  try {
24503
24585
  const entries = readdirSync(searchDir, { withFileTypes: true });
24504
24586
  for (const entry of entries) {
@@ -24515,7 +24597,7 @@ var ProjectManager = class {
24515
24597
  ".git"
24516
24598
  ];
24517
24599
  const isProject = projectIndicators.some(
24518
- (indicator) => existsSync4(join4(projectPath, indicator))
24600
+ (indicator) => existsSync5(join4(projectPath, indicator))
24519
24601
  );
24520
24602
  if (isProject) {
24521
24603
  discovered.push(projectPath);
@@ -24531,10 +24613,10 @@ var ProjectManager = class {
24531
24613
  const result = [];
24532
24614
  for (const project of this.listProjects()) {
24533
24615
  let dbPath = join4(project.dataDir, "neuronlayer.db");
24534
- if (!existsSync4(dbPath)) {
24616
+ if (!existsSync5(dbPath)) {
24535
24617
  dbPath = join4(project.dataDir, "memorylayer.db");
24536
24618
  }
24537
- if (existsSync4(dbPath)) {
24619
+ if (existsSync5(dbPath)) {
24538
24620
  try {
24539
24621
  const db = new Database2(dbPath, { readonly: true });
24540
24622
  result.push({ project, db });
@@ -24556,7 +24638,7 @@ var ProjectManager = class {
24556
24638
  };
24557
24639
 
24558
24640
  // src/core/adr-exporter.ts
24559
- import { existsSync as existsSync5, mkdirSync as mkdirSync4, writeFileSync as writeFileSync3 } from "fs";
24641
+ import { existsSync as existsSync6, mkdirSync as mkdirSync5, writeFileSync as writeFileSync4 } from "fs";
24560
24642
  import { join as join5 } from "path";
24561
24643
  var ADRExporter = class {
24562
24644
  projectPath;
@@ -24567,8 +24649,8 @@ var ADRExporter = class {
24567
24649
  exportDecision(decision, options = {}) {
24568
24650
  const outputDir = options.outputDir || join5(this.projectPath, "docs", "decisions");
24569
24651
  const format = options.format || "madr";
24570
- if (!existsSync5(outputDir)) {
24571
- mkdirSync4(outputDir, { recursive: true });
24652
+ if (!existsSync6(outputDir)) {
24653
+ mkdirSync5(outputDir, { recursive: true });
24572
24654
  }
24573
24655
  const existingFiles = this.getExistingADRFiles(outputDir);
24574
24656
  const nextNumber = this.getNextADRNumber(existingFiles);
@@ -24588,7 +24670,7 @@ var ADRExporter = class {
24588
24670
  content = this.formatSimple(decision, nextNumber);
24589
24671
  break;
24590
24672
  }
24591
- writeFileSync3(filePath, content);
24673
+ writeFileSync4(filePath, content);
24592
24674
  return filePath;
24593
24675
  }
24594
24676
  // Export all decisions
@@ -24635,7 +24717,7 @@ var ADRExporter = class {
24635
24717
  lines.push("---");
24636
24718
  lines.push("");
24637
24719
  lines.push("*Generated by NeuronLayer*");
24638
- writeFileSync3(indexPath, lines.join("\n"));
24720
+ writeFileSync4(indexPath, lines.join("\n"));
24639
24721
  return indexPath;
24640
24722
  }
24641
24723
  // MADR format (Markdown Any Decision Records)
@@ -24741,7 +24823,7 @@ ${decision.files.map((f) => `- \`${f}\``).join("\n")}
24741
24823
  `;
24742
24824
  }
24743
24825
  getExistingADRFiles(dir) {
24744
- if (!existsSync5(dir)) return [];
24826
+ if (!existsSync6(dir)) return [];
24745
24827
  try {
24746
24828
  const { readdirSync: readdirSync4 } = __require("fs");
24747
24829
  return readdirSync4(dir).filter((f) => /^\d{4}-.*\.md$/.test(f)).sort();
@@ -24761,7 +24843,7 @@ ${decision.files.map((f) => `- \`${f}\``).join("\n")}
24761
24843
 
24762
24844
  // src/core/feature-context.ts
24763
24845
  import { EventEmitter as EventEmitter3 } from "events";
24764
- import { readFileSync as readFileSync6, writeFileSync as writeFileSync4, existsSync as existsSync6, mkdirSync as mkdirSync5 } from "fs";
24846
+ import { readFileSync as readFileSync7, writeFileSync as writeFileSync5, existsSync as existsSync7, mkdirSync as mkdirSync6 } from "fs";
24765
24847
  import { dirname as dirname4, join as join6, basename as basename3 } from "path";
24766
24848
  import { randomUUID as randomUUID3 } from "crypto";
24767
24849
  var MAX_FILES = 20;
@@ -24861,7 +24943,7 @@ var FeatureContextManager = class extends EventEmitter3 {
24861
24943
  if (this.fileContents.has(relativePath)) return;
24862
24944
  try {
24863
24945
  const absolutePath = this.toAbsolutePath(relativePath);
24864
- const content = readFileSync6(absolutePath, "utf-8");
24946
+ const content = readFileSync7(absolutePath, "utf-8");
24865
24947
  this.fileContents.set(relativePath, content);
24866
24948
  if (this.fileContents.size > HOT_CACHE_MAX_FILES && this.current) {
24867
24949
  const filesInContext = new Set(this.current.files.map((f) => f.path));
@@ -25012,22 +25094,22 @@ var FeatureContextManager = class extends EventEmitter3 {
25012
25094
  save() {
25013
25095
  try {
25014
25096
  const dir = dirname4(this.persistPath);
25015
- if (!existsSync6(dir)) {
25016
- mkdirSync5(dir, { recursive: true });
25097
+ if (!existsSync7(dir)) {
25098
+ mkdirSync6(dir, { recursive: true });
25017
25099
  }
25018
25100
  const data = {
25019
25101
  current: this.current,
25020
25102
  recent: this.recent
25021
25103
  };
25022
- writeFileSync4(this.persistPath, JSON.stringify(data, null, 2));
25104
+ writeFileSync5(this.persistPath, JSON.stringify(data, null, 2));
25023
25105
  } catch (error2) {
25024
25106
  console.error("Error saving feature context:", error2);
25025
25107
  }
25026
25108
  }
25027
25109
  load() {
25028
25110
  try {
25029
- if (existsSync6(this.persistPath)) {
25030
- const data = JSON.parse(readFileSync6(this.persistPath, "utf-8"));
25111
+ if (existsSync7(this.persistPath)) {
25112
+ const data = JSON.parse(readFileSync7(this.persistPath, "utf-8"));
25031
25113
  if (data.current) {
25032
25114
  this.current = this.parseContext(data.current);
25033
25115
  }
@@ -25272,7 +25354,7 @@ var FeatureContextManager = class extends EventEmitter3 {
25272
25354
  };
25273
25355
 
25274
25356
  // src/core/living-docs/architecture-generator.ts
25275
- import { existsSync as existsSync7, readFileSync as readFileSync7, readdirSync as readdirSync2 } from "fs";
25357
+ import { existsSync as existsSync8, readFileSync as readFileSync8, readdirSync as readdirSync2 } from "fs";
25276
25358
  import { basename as basename4, join as join7 } from "path";
25277
25359
  var ArchitectureGenerator = class _ArchitectureGenerator {
25278
25360
  projectPath;
@@ -25351,7 +25433,7 @@ var ArchitectureGenerator = class _ArchitectureGenerator {
25351
25433
  detectLayers() {
25352
25434
  const layers = [];
25353
25435
  const layerMap = /* @__PURE__ */ new Map();
25354
- const srcDir = existsSync7(join7(this.projectPath, "src")) ? join7(this.projectPath, "src") : this.projectPath;
25436
+ const srcDir = existsSync8(join7(this.projectPath, "src")) ? join7(this.projectPath, "src") : this.projectPath;
25355
25437
  try {
25356
25438
  const entries = readdirSync2(srcDir, { withFileTypes: true });
25357
25439
  for (const entry of entries) {
@@ -25537,9 +25619,9 @@ var ArchitectureGenerator = class _ArchitectureGenerator {
25537
25619
  getProjectDependencies() {
25538
25620
  const deps = [];
25539
25621
  const packageJsonPath = join7(this.projectPath, "package.json");
25540
- if (existsSync7(packageJsonPath)) {
25622
+ if (existsSync8(packageJsonPath)) {
25541
25623
  try {
25542
- const pkg = JSON.parse(readFileSync7(packageJsonPath, "utf-8"));
25624
+ const pkg = JSON.parse(readFileSync8(packageJsonPath, "utf-8"));
25543
25625
  if (pkg.dependencies) {
25544
25626
  for (const [name, version2] of Object.entries(pkg.dependencies)) {
25545
25627
  deps.push({
@@ -25565,9 +25647,9 @@ var ArchitectureGenerator = class _ArchitectureGenerator {
25565
25647
  }
25566
25648
  }
25567
25649
  const requirementsPath = join7(this.projectPath, "requirements.txt");
25568
- if (existsSync7(requirementsPath)) {
25650
+ if (existsSync8(requirementsPath)) {
25569
25651
  try {
25570
- const content = readFileSync7(requirementsPath, "utf-8");
25652
+ const content = readFileSync8(requirementsPath, "utf-8");
25571
25653
  const lines = content.split("\n").filter((l) => l.trim() && !l.startsWith("#"));
25572
25654
  for (const line of lines.slice(0, 20)) {
25573
25655
  const match = line.match(/^([a-zA-Z0-9_-]+)(?:[=<>~!]+(.+))?/);
@@ -25608,7 +25690,7 @@ var ArchitectureGenerator = class _ArchitectureGenerator {
25608
25690
 
25609
25691
  // src/core/living-docs/component-generator.ts
25610
25692
  import { execSync as execSync2 } from "child_process";
25611
- import { existsSync as existsSync8 } from "fs";
25693
+ import { existsSync as existsSync9 } from "fs";
25612
25694
  import { basename as basename5, extname as extname2, join as join8 } from "path";
25613
25695
  var ComponentGenerator = class {
25614
25696
  projectPath;
@@ -25617,7 +25699,7 @@ var ComponentGenerator = class {
25617
25699
  constructor(projectPath, tier2) {
25618
25700
  this.projectPath = projectPath;
25619
25701
  this.tier2 = tier2;
25620
- this.isGitRepo = existsSync8(join8(projectPath, ".git"));
25702
+ this.isGitRepo = existsSync9(join8(projectPath, ".git"));
25621
25703
  }
25622
25704
  async generate(filePath) {
25623
25705
  const file2 = this.tier2.getFile(filePath);
@@ -25785,7 +25867,7 @@ var ComponentGenerator = class {
25785
25867
 
25786
25868
  // src/core/living-docs/changelog-generator.ts
25787
25869
  import { execSync as execSync3 } from "child_process";
25788
- import { existsSync as existsSync9 } from "fs";
25870
+ import { existsSync as existsSync10 } from "fs";
25789
25871
  import { join as join9 } from "path";
25790
25872
  var ChangelogGenerator = class {
25791
25873
  projectPath;
@@ -25794,7 +25876,7 @@ var ChangelogGenerator = class {
25794
25876
  constructor(projectPath, db) {
25795
25877
  this.projectPath = projectPath;
25796
25878
  this.db = db;
25797
- this.isGitRepo = existsSync9(join9(projectPath, ".git"));
25879
+ this.isGitRepo = existsSync10(join9(projectPath, ".git"));
25798
25880
  }
25799
25881
  async generate(options = {}) {
25800
25882
  if (!this.isGitRepo) {
@@ -26240,7 +26322,7 @@ var DocValidator = class {
26240
26322
 
26241
26323
  // src/core/living-docs/activity-tracker.ts
26242
26324
  import { execSync as execSync4 } from "child_process";
26243
- import { existsSync as existsSync10 } from "fs";
26325
+ import { existsSync as existsSync11 } from "fs";
26244
26326
  import { join as join10 } from "path";
26245
26327
  var ActivityTracker = class {
26246
26328
  projectPath;
@@ -26251,7 +26333,7 @@ var ActivityTracker = class {
26251
26333
  this.projectPath = projectPath;
26252
26334
  this.db = db;
26253
26335
  this.tier2 = tier2;
26254
- this.isGitRepo = existsSync10(join10(projectPath, ".git"));
26336
+ this.isGitRepo = existsSync11(join10(projectPath, ".git"));
26255
26337
  }
26256
26338
  async whatHappened(since, scope) {
26257
26339
  const sinceDate = this.parseSinceString(since);
@@ -30466,7 +30548,7 @@ ${category.toUpperCase()}:`);
30466
30548
  };
30467
30549
 
30468
30550
  // src/core/test-awareness/test-indexer.ts
30469
- import { existsSync as existsSync11, readFileSync as readFileSync8 } from "fs";
30551
+ import { existsSync as existsSync12, readFileSync as readFileSync9 } from "fs";
30470
30552
  import { join as join11 } from "path";
30471
30553
 
30472
30554
  // src/core/test-awareness/test-parser.ts
@@ -31030,9 +31112,9 @@ var TestIndexer = class {
31030
31112
  }
31031
31113
  detectFramework() {
31032
31114
  const packageJsonPath = join11(this.projectPath, "package.json");
31033
- if (existsSync11(packageJsonPath)) {
31115
+ if (existsSync12(packageJsonPath)) {
31034
31116
  try {
31035
- const pkg = JSON.parse(readFileSync8(packageJsonPath, "utf-8"));
31117
+ const pkg = JSON.parse(readFileSync9(packageJsonPath, "utf-8"));
31036
31118
  const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
31037
31119
  if (allDeps["vitest"]) return "vitest";
31038
31120
  if (allDeps["jest"]) return "jest";
@@ -31042,21 +31124,21 @@ var TestIndexer = class {
31042
31124
  }
31043
31125
  const pytestConfigs = ["pytest.ini", "pyproject.toml", "setup.cfg", "conftest.py"];
31044
31126
  for (const config2 of pytestConfigs) {
31045
- if (existsSync11(join11(this.projectPath, config2))) {
31046
- const content = readFileSync8(join11(this.projectPath, config2), "utf-8");
31127
+ if (existsSync12(join11(this.projectPath, config2))) {
31128
+ const content = readFileSync9(join11(this.projectPath, config2), "utf-8");
31047
31129
  if (content.includes("[pytest]") || content.includes("pytest") || config2 === "conftest.py") {
31048
31130
  return "pytest";
31049
31131
  }
31050
31132
  }
31051
31133
  }
31052
31134
  const goMod = join11(this.projectPath, "go.mod");
31053
- if (existsSync11(goMod)) {
31135
+ if (existsSync12(goMod)) {
31054
31136
  return "go";
31055
31137
  }
31056
31138
  const vitestConfigs = ["vitest.config.ts", "vitest.config.js", "vite.config.ts", "vite.config.js"];
31057
31139
  for (const config2 of vitestConfigs) {
31058
- if (existsSync11(join11(this.projectPath, config2))) {
31059
- const content = readFileSync8(join11(this.projectPath, config2), "utf-8");
31140
+ if (existsSync12(join11(this.projectPath, config2))) {
31141
+ const content = readFileSync9(join11(this.projectPath, config2), "utf-8");
31060
31142
  if (content.includes("vitest") || content.includes("test:")) {
31061
31143
  return "vitest";
31062
31144
  }
@@ -31064,7 +31146,7 @@ var TestIndexer = class {
31064
31146
  }
31065
31147
  const jestConfigs = ["jest.config.ts", "jest.config.js", "jest.config.json"];
31066
31148
  for (const config2 of jestConfigs) {
31067
- if (existsSync11(join11(this.projectPath, config2))) {
31149
+ if (existsSync12(join11(this.projectPath, config2))) {
31068
31150
  return "jest";
31069
31151
  }
31070
31152
  }
@@ -31117,7 +31199,7 @@ var TestIndexer = class {
31117
31199
  const cached2 = this.testCache.get(relativePath);
31118
31200
  if (cached2) return cached2;
31119
31201
  try {
31120
- const content = readFileSync8(absolutePath, "utf-8");
31202
+ const content = readFileSync9(absolutePath, "utf-8");
31121
31203
  const tests = this.parser.parseFile(content, relativePath, this.framework);
31122
31204
  this.testCache.set(relativePath, tests);
31123
31205
  return tests;
@@ -32868,7 +32950,7 @@ var DejaVuDetector = class {
32868
32950
  };
32869
32951
 
32870
32952
  // src/core/code-verifier.ts
32871
- import { existsSync as existsSync12, readFileSync as readFileSync9 } from "fs";
32953
+ import { existsSync as existsSync13, readFileSync as readFileSync10 } from "fs";
32872
32954
  import { join as join12, dirname as dirname6, extname as extname4 } from "path";
32873
32955
  var SECURITY_PATTERNS2 = [
32874
32956
  // SQL Injection
@@ -33119,9 +33201,9 @@ var CodeVerifier = class {
33119
33201
  }
33120
33202
  loadPackageJson() {
33121
33203
  const packageJsonPath = join12(this.projectPath, "package.json");
33122
- if (existsSync12(packageJsonPath)) {
33204
+ if (existsSync13(packageJsonPath)) {
33123
33205
  try {
33124
- this.packageJson = JSON.parse(readFileSync9(packageJsonPath, "utf-8"));
33206
+ this.packageJson = JSON.parse(readFileSync10(packageJsonPath, "utf-8"));
33125
33207
  } catch {
33126
33208
  this.packageJson = null;
33127
33209
  }
@@ -33272,7 +33354,7 @@ var CodeVerifier = class {
33272
33354
  const packageName = this.getPackageName(importPath);
33273
33355
  if (!packages.has(packageName)) {
33274
33356
  const nodeModulePath = join12(this.nodeModulesPath, packageName);
33275
- if (existsSync12(nodeModulePath)) {
33357
+ if (existsSync13(nodeModulePath)) {
33276
33358
  issues.push({
33277
33359
  package: packageName,
33278
33360
  type: "unlisted",
@@ -33320,16 +33402,16 @@ var CodeVerifier = class {
33320
33402
  let found = false;
33321
33403
  for (const ext of possibleExtensions) {
33322
33404
  const fullPath = join12(baseDir, importPath + ext);
33323
- if (existsSync12(fullPath)) {
33405
+ if (existsSync13(fullPath)) {
33324
33406
  found = true;
33325
33407
  break;
33326
33408
  }
33327
33409
  }
33328
33410
  if (!found) {
33329
33411
  const dirPath = join12(baseDir, importPath);
33330
- if (existsSync12(dirPath)) {
33412
+ if (existsSync13(dirPath)) {
33331
33413
  for (const indexFile of possibleIndexes) {
33332
- if (existsSync12(join12(dirPath, indexFile))) {
33414
+ if (existsSync13(join12(dirPath, indexFile))) {
33333
33415
  found = true;
33334
33416
  break;
33335
33417
  }
@@ -33348,7 +33430,7 @@ var CodeVerifier = class {
33348
33430
  verifyPackageImport(importPath, issues, warnings) {
33349
33431
  const packageName = this.getPackageName(importPath);
33350
33432
  const nodeModulePath = join12(this.nodeModulesPath, packageName);
33351
- if (!existsSync12(nodeModulePath)) {
33433
+ if (!existsSync13(nodeModulePath)) {
33352
33434
  issues.push({
33353
33435
  import: importPath,
33354
33436
  type: "missing_package",
@@ -33363,15 +33445,15 @@ var CodeVerifier = class {
33363
33445
  const possibleExtensions = [".js", ".json", ""];
33364
33446
  let found = false;
33365
33447
  for (const ext of possibleExtensions) {
33366
- if (existsSync12(subpathFull + ext)) {
33448
+ if (existsSync13(subpathFull + ext)) {
33367
33449
  found = true;
33368
33450
  break;
33369
33451
  }
33370
33452
  }
33371
33453
  const pkgJsonPath = join12(nodeModulePath, "package.json");
33372
- if (!found && existsSync12(pkgJsonPath)) {
33454
+ if (!found && existsSync13(pkgJsonPath)) {
33373
33455
  try {
33374
- const pkgJson = JSON.parse(readFileSync9(pkgJsonPath, "utf-8"));
33456
+ const pkgJson = JSON.parse(readFileSync10(pkgJsonPath, "utf-8"));
33375
33457
  if (pkgJson.exports) {
33376
33458
  const exportKey = "./" + subpath;
33377
33459
  if (pkgJson.exports[exportKey] || pkgJson.exports["./" + subpath + ".js"]) {
@@ -33790,12 +33872,12 @@ var NeuronLayerEngine = class {
33790
33872
  indexingProgress = { indexed: 0, total: 0 };
33791
33873
  constructor(config2) {
33792
33874
  this.config = config2;
33793
- if (!existsSync13(config2.dataDir)) {
33794
- mkdirSync6(config2.dataDir, { recursive: true });
33875
+ if (!existsSync14(config2.dataDir)) {
33876
+ mkdirSync7(config2.dataDir, { recursive: true });
33795
33877
  }
33796
33878
  let dbPath = join13(config2.dataDir, "neuronlayer.db");
33797
33879
  const oldDbPath = join13(config2.dataDir, "memorylayer.db");
33798
- if (!existsSync13(dbPath) && existsSync13(oldDbPath)) {
33880
+ if (!existsSync14(dbPath) && existsSync14(oldDbPath)) {
33799
33881
  try {
33800
33882
  console.error("Migrating database from memorylayer.db to neuronlayer.db...");
33801
33883
  renameSync(oldDbPath, dbPath);
@@ -34130,13 +34212,13 @@ ${description}`,
34130
34212
  async getFileContext(filePath) {
34131
34213
  this.activityGate.recordActivity();
34132
34214
  const absolutePath = join13(this.config.projectPath, filePath);
34133
- if (!existsSync13(absolutePath)) {
34215
+ if (!existsSync14(absolutePath)) {
34134
34216
  return null;
34135
34217
  }
34136
34218
  try {
34137
34219
  let content = this.learningEngine.getFromHotCache(filePath);
34138
34220
  if (!content) {
34139
- content = readFileSync10(absolutePath, "utf-8");
34221
+ content = readFileSync11(absolutePath, "utf-8");
34140
34222
  this.learningEngine.addToHotCache(filePath, content);
34141
34223
  }
34142
34224
  const language = detectLanguage(filePath);
@@ -34216,7 +34298,7 @@ ${decision.description}`;
34216
34298
  const commonDirs = ["src", "lib", "app", "pages", "components", "api", "server", "client", "core"];
34217
34299
  const found = [];
34218
34300
  for (const dir of commonDirs) {
34219
- if (existsSync13(join13(this.config.projectPath, dir))) {
34301
+ if (existsSync14(join13(this.config.projectPath, dir))) {
34220
34302
  found.push(dir);
34221
34303
  }
34222
34304
  }
@@ -34225,9 +34307,9 @@ ${decision.description}`;
34225
34307
  detectDependencies() {
34226
34308
  const deps = [];
34227
34309
  const packageJsonPath = join13(this.config.projectPath, "package.json");
34228
- if (existsSync13(packageJsonPath)) {
34310
+ if (existsSync14(packageJsonPath)) {
34229
34311
  try {
34230
- const pkg = JSON.parse(readFileSync10(packageJsonPath, "utf-8"));
34312
+ const pkg = JSON.parse(readFileSync11(packageJsonPath, "utf-8"));
34231
34313
  const allDeps = {
34232
34314
  ...pkg.dependencies,
34233
34315
  ...pkg.devDependencies
@@ -34237,9 +34319,9 @@ ${decision.description}`;
34237
34319
  }
34238
34320
  }
34239
34321
  const requirementsPath = join13(this.config.projectPath, "requirements.txt");
34240
- if (existsSync13(requirementsPath)) {
34322
+ if (existsSync14(requirementsPath)) {
34241
34323
  try {
34242
- const content = readFileSync10(requirementsPath, "utf-8");
34324
+ const content = readFileSync11(requirementsPath, "utf-8");
34243
34325
  const lines = content.split("\n").map((l) => l.trim()).filter((l) => l && !l.startsWith("#")).map((l) => l.split(/[=<>]/)[0]?.trim()).filter((l) => !!l);
34244
34326
  deps.push(...lines.slice(0, 20));
34245
34327
  } catch {
@@ -34302,9 +34384,9 @@ ${decision.description}`;
34302
34384
  for (const filePath of predicted) {
34303
34385
  if (!this.learningEngine.isInHotCache(filePath)) {
34304
34386
  const absolutePath = join13(this.config.projectPath, filePath);
34305
- if (existsSync13(absolutePath)) {
34387
+ if (existsSync14(absolutePath)) {
34306
34388
  try {
34307
- const content = readFileSync10(absolutePath, "utf-8");
34389
+ const content = readFileSync11(absolutePath, "utf-8");
34308
34390
  this.learningEngine.addToHotCache(filePath, content);
34309
34391
  fetched++;
34310
34392
  } catch {
@@ -38971,7 +39053,7 @@ function parseArgs(args) {
38971
39053
 
38972
39054
  // src/cli/commands.ts
38973
39055
  import { join as join15 } from "path";
38974
- import { existsSync as existsSync14, readFileSync as readFileSync11, writeFileSync as writeFileSync5, mkdirSync as mkdirSync7 } from "fs";
39056
+ import { existsSync as existsSync15, readFileSync as readFileSync12, writeFileSync as writeFileSync6, mkdirSync as mkdirSync8 } from "fs";
38975
39057
  import { homedir as homedir2 } from "os";
38976
39058
  var projectManager = new ProjectManager();
38977
39059
  function listProjects() {
@@ -39087,9 +39169,9 @@ function exportDecisions(projectPath, options = {}) {
39087
39169
  };
39088
39170
  }
39089
39171
  let dbPath = join15(projectInfo.dataDir, "neuronlayer.db");
39090
- if (!existsSync14(dbPath)) {
39172
+ if (!existsSync15(dbPath)) {
39091
39173
  const oldDbPath = join15(projectInfo.dataDir, "memorylayer.db");
39092
- if (existsSync14(oldDbPath)) {
39174
+ if (existsSync15(oldDbPath)) {
39093
39175
  dbPath = oldDbPath;
39094
39176
  } else {
39095
39177
  return {
@@ -39152,13 +39234,13 @@ function showProject(projectId) {
39152
39234
  function configureMCPClient(clientName, configPath, serverName, projectPath) {
39153
39235
  let config2 = { mcpServers: {} };
39154
39236
  try {
39155
- if (existsSync14(configPath)) {
39156
- const content = readFileSync11(configPath, "utf-8");
39237
+ if (existsSync15(configPath)) {
39238
+ const content = readFileSync12(configPath, "utf-8");
39157
39239
  config2 = JSON.parse(content);
39158
39240
  } else {
39159
39241
  const sep = process.platform === "win32" ? "\\" : "/";
39160
39242
  const configDir = configPath.substring(0, configPath.lastIndexOf(sep));
39161
- mkdirSync7(configDir, { recursive: true });
39243
+ mkdirSync8(configDir, { recursive: true });
39162
39244
  }
39163
39245
  } catch {
39164
39246
  }
@@ -39170,7 +39252,7 @@ function configureMCPClient(clientName, configPath, serverName, projectPath) {
39170
39252
  args: ["-y", "neuronlayer", "--project", projectPath]
39171
39253
  };
39172
39254
  try {
39173
- writeFileSync5(configPath, JSON.stringify(config2, null, 2));
39255
+ writeFileSync6(configPath, JSON.stringify(config2, null, 2));
39174
39256
  return { success: true, message: `${clientName}: ${configPath}` };
39175
39257
  } catch (err) {
39176
39258
  return { success: false, message: `${clientName}: Failed - ${err instanceof Error ? err.message : String(err)}` };
@@ -39179,8 +39261,8 @@ function configureMCPClient(clientName, configPath, serverName, projectPath) {
39179
39261
  function configureProjectMCP(configPath, projectPath) {
39180
39262
  let config2 = { mcpServers: {} };
39181
39263
  try {
39182
- if (existsSync14(configPath)) {
39183
- const content = readFileSync11(configPath, "utf-8");
39264
+ if (existsSync15(configPath)) {
39265
+ const content = readFileSync12(configPath, "utf-8");
39184
39266
  config2 = JSON.parse(content);
39185
39267
  }
39186
39268
  } catch {
@@ -39193,7 +39275,7 @@ function configureProjectMCP(configPath, projectPath) {
39193
39275
  args: ["-y", "neuronlayer", "--project", "."]
39194
39276
  };
39195
39277
  try {
39196
- writeFileSync5(configPath, JSON.stringify(config2, null, 2));
39278
+ writeFileSync6(configPath, JSON.stringify(config2, null, 2));
39197
39279
  return { success: true, message: `Claude Code: ${configPath} (project-local)` };
39198
39280
  } catch (err) {
39199
39281
  return { success: false, message: `Claude Code: Failed - ${err instanceof Error ? err.message : String(err)}` };