nexarch 0.9.0 → 0.9.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.
@@ -8,7 +8,15 @@ import { fetchAgentRegistryOrThrow } from "../lib/agent-registry.js";
8
8
  import { callMcpTool, mcpInitialize, mcpListTools } from "../lib/mcp.js";
9
9
  import { buildVersionAttributes } from "../lib/version-normalization.js";
10
10
  import { requestTrustAttestation } from "../lib/trust.js";
11
- const CLI_VERSION = "0.8.21";
11
+ const CLI_VERSION = (() => {
12
+ try {
13
+ const pkg = JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8"));
14
+ return typeof pkg.version === "string" && pkg.version.trim() ? pkg.version.trim() : "unknown";
15
+ }
16
+ catch {
17
+ return "unknown";
18
+ }
19
+ })();
12
20
  const AGENT_ENTITY_TYPE = "agent";
13
21
  const TECH_COMPONENT_ENTITY_TYPE = "technology_component";
14
22
  function parseFlag(args, flag) {
@@ -76,10 +84,16 @@ function renderChecksTable(checks) {
76
84
  const lines = [hr, formatRow(headers), hr, ...rows.map(formatRow), hr];
77
85
  return lines.join("\n");
78
86
  }
87
+ function normalizeRefSegment(value) {
88
+ return value.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
89
+ }
90
+ function buildEntityRef(entityTypeCode, ...segments) {
91
+ return [normalizeRefSegment(entityTypeCode), ...segments.map(normalizeRefSegment).filter(Boolean)].join(":");
92
+ }
79
93
  function getDefaultAgentId() {
80
94
  const osUser = process.env.USERNAME || process.env.USER || userInfo().username || "unknown";
81
95
  const host = hostname() || "unknown-host";
82
- return `nexarch-cli:${osUser}@${host}`;
96
+ return `nexarch_cli_${normalizeRefSegment(osUser)}_${normalizeRefSegment(host)}`;
83
97
  }
84
98
  function getRuntimeMode() {
85
99
  if (process.env.CI)
@@ -519,6 +533,7 @@ export async function initAgent(args) {
519
533
  const capabilitiesArg = parseCsv(parseOptionValue(args, "--capabilities"));
520
534
  const notesArg = parseOptionValue(args, "--notes");
521
535
  const agentId = explicitAgentId ?? getDefaultAgentId();
536
+ const agentExternalKey = buildEntityRef("agent", agentId);
522
537
  const runtime = {
523
538
  osPlatform: platform(),
524
539
  osType: osType(),
@@ -635,7 +650,6 @@ export async function initAgent(args) {
635
650
  if (preflightPassed && policies.policyBundleHash && relForTechBinding) {
636
651
  const nowIso = new Date().toISOString();
637
652
  const agentRunId = `init-agent-${Date.now()}`;
638
- const agentExternalKey = `agent:${agentId}`;
639
653
  const upsertRaw = await callMcpTool("nexarch_upsert_entities", {
640
654
  entities: [
641
655
  {
@@ -713,9 +727,9 @@ export async function initAgent(args) {
713
727
  }
714
728
  if (registration.ok) {
715
729
  techComponents.attempted = true;
716
- const hostExternalKey = `tech:host:${runtime.hostname}:${runtime.arch}`;
717
- const osExternalKey = `tech:os:${runtime.osPlatform}:${runtime.osRelease}:${runtime.arch}`;
718
- const nodeExternalKey = `tech:runtime:nodejs:${runtime.nodeVersion}`;
730
+ const hostExternalKey = buildEntityRef("technology_component", "host", runtime.hostname, runtime.arch);
731
+ const osExternalKey = buildEntityRef("technology_component", "os", runtime.osPlatform, runtime.osRelease, runtime.arch);
732
+ const nodeExternalKey = buildEntityRef("technology_component", "runtime", "nodejs", runtime.nodeVersion);
719
733
  const techUpsertRaw = await callMcpTool("nexarch_upsert_entities", {
720
734
  entities: [
721
735
  {
@@ -886,7 +900,7 @@ export async function initAgent(args) {
886
900
  relationships: [
887
901
  {
888
902
  relationshipTypeCode: "accountable_for",
889
- fromEntityExternalKey: `organisation:${creds.companyId}`,
903
+ fromEntityExternalKey: buildEntityRef("organisation", creds.companyId),
890
904
  toEntityExternalKey: agentExternalKey,
891
905
  confidence: 1,
892
906
  attributes: { source: "nexarch-cli-init-agent", kind: "org_agent", createdAt: nowIso },
@@ -1065,7 +1079,7 @@ export async function initAgent(args) {
1065
1079
  // Save identity so check-in can find the agent key
1066
1080
  const identityDir = join(homedir(), ".nexarch");
1067
1081
  mkdirSync(identityDir, { recursive: true });
1068
- writeFileSync(join(identityDir, "identity.json"), JSON.stringify({ agentKey: `agent:${agentId}`, companyId: creds.companyId }, null, 2), { mode: 0o600 });
1082
+ writeFileSync(join(identityDir, "identity.json"), JSON.stringify({ agentKey: agentExternalKey, companyId: creds.companyId }, null, 2), { mode: 0o600 });
1069
1083
  }
1070
1084
  catch {
1071
1085
  // non-fatal
@@ -24,7 +24,7 @@ function parseToolText(result) {
24
24
  return JSON.parse(text);
25
25
  }
26
26
  function slugify(name) {
27
- return name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
27
+ return name.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
28
28
  }
29
29
  function safeExec(command, args, cwd) {
30
30
  try {
@@ -978,11 +978,11 @@ export async function initProject(args) {
978
978
  for (const sp of subPackages) {
979
979
  const nameSlug = slugify(sp.name);
980
980
  const needsPrefix = !sp.name.includes("/") && !nameSlug.startsWith(projectSlug);
981
- let keySlug = needsPrefix ? `${projectSlug}-${nameSlug}` : nameSlug;
981
+ let keySlug = needsPrefix ? `${projectSlug}_${nameSlug}` : nameSlug;
982
982
  // Avoid key collision with the top-level project (e.g. sub-package named "nexarch").
983
983
  if (`${sp.entityType}:${keySlug}` === projectExternalKey) {
984
- const relSlug = slugify(sp.relativePath.replace(/\//g, "-"));
985
- keySlug = relSlug ? `${projectSlug}-${relSlug}` : `${projectSlug}-${nameSlug}-sub`;
984
+ const relSlug = slugify(sp.relativePath.replace(/\//g, "_"));
985
+ keySlug = relSlug ? `${projectSlug}_${relSlug}` : `${projectSlug}_${nameSlug}_sub`;
986
986
  }
987
987
  sp.externalKey = `${sp.entityType}:${keySlug}`;
988
988
  }
@@ -1091,7 +1091,7 @@ export async function initProject(args) {
1091
1091
  .sort((a, b) => b.score - a.score);
1092
1092
  const suggested = matches.length > 0 ? matches[0] : null;
1093
1093
  const highConfidence = suggested && suggested.score >= 0.85;
1094
- const interactiveAllowed = !asJson && !nonInteractive && process.stdin.isTTY;
1094
+ const interactiveAllowed = !nonInteractive && process.stdin.isTTY;
1095
1095
  if (autoMapApplication && highConfidence) {
1096
1096
  projectExternalKey = suggested.entityRef;
1097
1097
  if (!asJson)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexarch",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Your architecture workspace for AI delivery.",
5
5
  "keywords": [
6
6
  "nexarch",