nexarch 0.1.23 → 0.1.24

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.
@@ -4,7 +4,7 @@ import { join } from "path";
4
4
  import process from "process";
5
5
  import { requireCredentials } from "../lib/credentials.js";
6
6
  import { callMcpTool, mcpInitialize, mcpListTools } from "../lib/mcp.js";
7
- const CLI_VERSION = "0.1.23";
7
+ const CLI_VERSION = "0.1.24";
8
8
  const AGENT_ENTITY_TYPE = "agent";
9
9
  const TECH_COMPONENT_ENTITY_TYPE = "technology_component";
10
10
  function parseFlag(args, flag) {
@@ -205,13 +205,16 @@ function scanProject(dir) {
205
205
  const names = new Set();
206
206
  let projectName = basename(dir);
207
207
  const subPackages = [];
208
+ let rootDepNames = new Set();
208
209
  const pkgPaths = findPackageJsonPaths(dir);
209
210
  const rootPkgPath = join(dir, "package.json");
210
211
  for (const pkgPath of pkgPaths) {
211
212
  const pkg = readRootPackage(pkgPath);
213
+ const deps = collectPackageDeps(pkgPath);
212
214
  if (pkgPath === rootPkgPath) {
213
215
  if (pkg.name)
214
216
  projectName = pkg.name;
217
+ rootDepNames = new Set(deps);
215
218
  }
216
219
  else {
217
220
  // Record as a sub-package for enrichment task
@@ -220,9 +223,10 @@ function scanProject(dir) {
220
223
  name: pkg.name ?? relativePath,
221
224
  relativePath,
222
225
  packageJsonPath: pkgPath,
226
+ depNames: deps,
223
227
  });
224
228
  }
225
- for (const dep of collectPackageDeps(pkgPath))
229
+ for (const dep of deps)
226
230
  names.add(dep);
227
231
  }
228
232
  // .env files at root
@@ -241,7 +245,7 @@ function scanProject(dir) {
241
245
  names.add(name);
242
246
  for (const name of detectFromFilesystem(dir))
243
247
  names.add(name);
244
- return { projectName, packageJsonCount: pkgPaths.length, detectedNames: Array.from(names), subPackages };
248
+ return { projectName, packageJsonCount: pkgPaths.length, detectedNames: Array.from(names), rootDepNames, subPackages };
245
249
  }
246
250
  // ─── Relationship type selection ──────────────────────────────────────────────
247
251
  function pickRelationshipType(entityTypeCode) {
@@ -268,7 +272,7 @@ export async function initProject(args) {
268
272
  const mcpOpts = { companyId: creds.companyId };
269
273
  if (!asJson)
270
274
  console.log(`Scanning ${dir}…`);
271
- const { projectName, packageJsonCount, detectedNames, subPackages } = scanProject(dir);
275
+ const { projectName, packageJsonCount, detectedNames, rootDepNames, subPackages } = scanProject(dir);
272
276
  const displayName = nameOverride ?? projectName;
273
277
  const projectSlug = slugify(displayName);
274
278
  const projectExternalKey = `${entityTypeOverride}:${projectSlug}`;
@@ -358,12 +362,24 @@ export async function initProject(args) {
358
362
  confidence: 0.95,
359
363
  });
360
364
  }
361
- // Build relationships from project entity to each resolved dependency
365
+ // Build a lookup from input name to resolved result for enrichment task use
366
+ const resolvedByInput = new Map();
367
+ for (const r of resolvedItems) {
368
+ if (r.canonicalExternalRef)
369
+ resolvedByInput.set(r.input, r);
370
+ if (r.normalised && r.canonicalExternalRef)
371
+ resolvedByInput.set(r.normalised, r);
372
+ }
373
+ // Build relationships — only wire root-level deps to the project entity.
374
+ // Sub-package deps are wired during enrichment (the agent does it per sub-app).
362
375
  const relationships = [];
363
376
  const seenRelPairs = new Set();
364
377
  for (const r of resolvedItems) {
365
378
  if (!r.canonicalExternalRef || !r.entityTypeCode)
366
379
  continue;
380
+ // Skip deps that don't belong to the root package — only wire root-level deps here
381
+ if (!rootDepNames.has(r.input) && !rootDepNames.has(r.normalised))
382
+ continue;
367
383
  const relType = pickRelationshipType(r.entityTypeCode);
368
384
  const pairKey = `${relType}::${projectExternalKey}::${r.canonicalExternalRef}`;
369
385
  if (seenRelPairs.has(pairKey))
@@ -497,5 +513,23 @@ ${subPackages.map((sp) => ` • ${sp.name} (${sp.relativePath})`).join("\n")
497
513
  --to "<library-key>" \\
498
514
  --type "depends_on"
499
515
  (FROM = ${projectExternalKey}, TO = the library)
516
+
517
+ ⚠️ WIRE DEPENDENCIES TO THE SUB-APP THAT DECLARES THEM, NOT TO THE PARENT.
518
+ After registering each sub-app/library entity, wire its npm dependencies to IT:
519
+ npx nexarch add-relationship \\
520
+ --from "<sub-app-or-library-key>" \\
521
+ --to "<resolved-tech-ref>" \\
522
+ --type "depends_on"
523
+
524
+ Pre-resolved dependencies per sub-package (wire these after registering each entity):
525
+ ${subPackages.map((sp) => {
526
+ const resolved = sp.depNames
527
+ .map((d) => resolvedByInput.get(d))
528
+ .filter((r) => !!r?.canonicalExternalRef);
529
+ if (resolved.length === 0)
530
+ return ` • ${sp.name}: (no pre-resolved deps — check package.json manually)`;
531
+ const lines = resolved.map((r) => ` --to "${r.canonicalExternalRef}" # ${r.canonicalName}`);
532
+ return ` • ${sp.name} (<sub-app-key> depends_on):\n${lines.join("\n")}`;
533
+ }).join("\n\n")}
500
534
  ` : ""}`);
501
535
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexarch",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "description": "Connect AI coding tools to your Nexarch architecture workspace",
5
5
  "keywords": [
6
6
  "nexarch",