nexarch 0.9.0 → 0.9.1

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.
@@ -76,10 +76,16 @@ function renderChecksTable(checks) {
76
76
  const lines = [hr, formatRow(headers), hr, ...rows.map(formatRow), hr];
77
77
  return lines.join("\n");
78
78
  }
79
+ function normalizeRefSegment(value) {
80
+ return value.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
81
+ }
82
+ function buildEntityRef(entityTypeCode, ...segments) {
83
+ return [normalizeRefSegment(entityTypeCode), ...segments.map(normalizeRefSegment).filter(Boolean)].join(":");
84
+ }
79
85
  function getDefaultAgentId() {
80
86
  const osUser = process.env.USERNAME || process.env.USER || userInfo().username || "unknown";
81
87
  const host = hostname() || "unknown-host";
82
- return `nexarch-cli:${osUser}@${host}`;
88
+ return `nexarch_cli_${normalizeRefSegment(osUser)}_${normalizeRefSegment(host)}`;
83
89
  }
84
90
  function getRuntimeMode() {
85
91
  if (process.env.CI)
@@ -519,6 +525,7 @@ export async function initAgent(args) {
519
525
  const capabilitiesArg = parseCsv(parseOptionValue(args, "--capabilities"));
520
526
  const notesArg = parseOptionValue(args, "--notes");
521
527
  const agentId = explicitAgentId ?? getDefaultAgentId();
528
+ const agentExternalKey = buildEntityRef("agent", agentId);
522
529
  const runtime = {
523
530
  osPlatform: platform(),
524
531
  osType: osType(),
@@ -635,7 +642,6 @@ export async function initAgent(args) {
635
642
  if (preflightPassed && policies.policyBundleHash && relForTechBinding) {
636
643
  const nowIso = new Date().toISOString();
637
644
  const agentRunId = `init-agent-${Date.now()}`;
638
- const agentExternalKey = `agent:${agentId}`;
639
645
  const upsertRaw = await callMcpTool("nexarch_upsert_entities", {
640
646
  entities: [
641
647
  {
@@ -713,9 +719,9 @@ export async function initAgent(args) {
713
719
  }
714
720
  if (registration.ok) {
715
721
  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}`;
722
+ const hostExternalKey = buildEntityRef("technology_component", "host", runtime.hostname, runtime.arch);
723
+ const osExternalKey = buildEntityRef("technology_component", "os", runtime.osPlatform, runtime.osRelease, runtime.arch);
724
+ const nodeExternalKey = buildEntityRef("technology_component", "runtime", "nodejs", runtime.nodeVersion);
719
725
  const techUpsertRaw = await callMcpTool("nexarch_upsert_entities", {
720
726
  entities: [
721
727
  {
@@ -886,7 +892,7 @@ export async function initAgent(args) {
886
892
  relationships: [
887
893
  {
888
894
  relationshipTypeCode: "accountable_for",
889
- fromEntityExternalKey: `organisation:${creds.companyId}`,
895
+ fromEntityExternalKey: buildEntityRef("organisation", creds.companyId),
890
896
  toEntityExternalKey: agentExternalKey,
891
897
  confidence: 1,
892
898
  attributes: { source: "nexarch-cli-init-agent", kind: "org_agent", createdAt: nowIso },
@@ -1065,7 +1071,7 @@ export async function initAgent(args) {
1065
1071
  // Save identity so check-in can find the agent key
1066
1072
  const identityDir = join(homedir(), ".nexarch");
1067
1073
  mkdirSync(identityDir, { recursive: true });
1068
- writeFileSync(join(identityDir, "identity.json"), JSON.stringify({ agentKey: `agent:${agentId}`, companyId: creds.companyId }, null, 2), { mode: 0o600 });
1074
+ writeFileSync(join(identityDir, "identity.json"), JSON.stringify({ agentKey: agentExternalKey, companyId: creds.companyId }, null, 2), { mode: 0o600 });
1069
1075
  }
1070
1076
  catch {
1071
1077
  // 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 {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexarch",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "Your architecture workspace for AI delivery.",
5
5
  "keywords": [
6
6
  "nexarch",