nexarch 0.5.3 → 0.5.4

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.
@@ -5,7 +5,7 @@ import process from "process";
5
5
  import { requireCredentials } from "../lib/credentials.js";
6
6
  import { fetchAgentRegistryOrThrow } from "../lib/agent-registry.js";
7
7
  import { callMcpTool, mcpInitialize, mcpListTools } from "../lib/mcp.js";
8
- const CLI_VERSION = "0.5.3";
8
+ const CLI_VERSION = "0.5.4";
9
9
  const AGENT_ENTITY_TYPE = "agent";
10
10
  const TECH_COMPONENT_ENTITY_TYPE = "technology_component";
11
11
  function parseFlag(args, flag) {
@@ -271,6 +271,7 @@ function injectGenericAgentConfig(registry) {
271
271
  export async function initAgent(args) {
272
272
  const asJson = parseFlag(args, "--json");
273
273
  const strict = parseFlag(args, "--strict");
274
+ const fromSetup = parseFlag(args, "--from-setup");
274
275
  const redactHostname = parseFlag(args, "--redact-hostname");
275
276
  const explicitAgentId = parseOptionValue(args, "--agent-id");
276
277
  const bindToExternalKey = parseOptionValue(args, "--bind-to-external-key");
@@ -313,13 +314,23 @@ export async function initAgent(args) {
313
314
  });
314
315
  const policiesRaw = await callMcpTool("nexarch_get_applied_policies", {}, { companyId: selectedCompanyId });
315
316
  const policies = parseToolText(policiesRaw);
317
+ const onboardingReady = Boolean(policies.policyBundleHash);
316
318
  checks.push({
317
319
  name: "governance.bootstrap",
318
- ok: Boolean(policies.policyBundleHash),
320
+ ok: onboardingReady,
319
321
  detail: policies.policyBundleHash
320
- ? `policyBundleHash=${policies.policyBundleHash.slice(0, 12)}… policyCount=${policies.policyCount ?? 0}`
322
+ ? `policyBundleHash=${policies.policyBundleHash.slice(0, 12)}…`
321
323
  : "missing policyBundleHash",
322
324
  });
325
+ if (!onboardingReady) {
326
+ const onboardingMessage = "Company onboarding is incomplete (missing policy bootstrap). Complete onboarding before running init-agent or init-project.";
327
+ if (asJson) {
328
+ process.stdout.write(`${JSON.stringify({ ok: false, error: "COMPANY_ONBOARDING_INCOMPLETE", message: onboardingMessage }, null, 2)}\n`);
329
+ process.exitCode = 1;
330
+ return;
331
+ }
332
+ throw new Error(onboardingMessage);
333
+ }
323
334
  const contractRaw = await callMcpTool("nexarch_get_ingest_contract", {}, { companyId: selectedCompanyId });
324
335
  const contract = parseToolText(contractRaw);
325
336
  checks.push({
@@ -822,21 +833,17 @@ export async function initAgent(args) {
822
833
  }
823
834
  const hasInjectedAgentInstructions = agentConfigResults.some((r) => r.status === "injected" || r.status === "updated");
824
835
  if (hasInjectedAgentInstructions) {
825
- console.log("\n➡ Next step: in your coding agent, run:");
826
- console.log("\nrun npx nexarch@latest init-agent\n");
827
- console.log(" (Registration instructions were already written into your agent config file.)");
836
+ if (!fromSetup) {
837
+ console.log("\n➡ Next step: in your coding agent, run:");
838
+ console.log("\nrun npx nexarch@latest init-agent\n");
839
+ console.log(" (Registration instructions were already written into your agent config file.)");
840
+ }
828
841
  }
829
842
  else {
830
843
  console.log("\n➡ Next step (required): complete agent identity in your coding agent");
831
844
  console.log(" Paste this and fill in real values:");
832
845
  console.log(`\nrun npx nexarch@latest agent identify --agent-id \"${agentId}\" --provider \"<provider>\" --model \"<model>\" --client \"<client>\" --framework \"<openclaw|n8n|m365-agent-framework|other>\" --tool-version \"<tool-version>\" --capabilities \"<capability1,capability2>\" --json\n`);
833
846
  }
834
- if (appDetection.detected) {
835
- console.log("\n➡ Optional next step: likely application detected in current directory.");
836
- console.log(` Detected manifests: ${appDetection.evidence.join(", ")}`);
837
- console.log(" Ask the user: 'I found a likely application here. Do you want me to run init-project next?'");
838
- console.log(" Suggested command: npx nexarch@latest init-project --dir . --json");
839
- }
840
847
  }
841
848
  else {
842
849
  console.log("⚠ Handshake/registration completed with issues.");
@@ -816,6 +816,15 @@ export async function initProject(args) {
816
816
  const policiesRaw = await callMcpTool("nexarch_get_applied_policies", {}, mcpOpts);
817
817
  const policies = parseToolText(policiesRaw);
818
818
  const policyBundleHash = policies.policyBundleHash ?? null;
819
+ if (!policyBundleHash) {
820
+ const message = "Company onboarding is incomplete (missing policy bootstrap). Complete onboarding before running init-project.";
821
+ if (asJson) {
822
+ process.stdout.write(`${JSON.stringify({ ok: false, error: "COMPANY_ONBOARDING_INCOMPLETE", message }, null, 2)}\n`);
823
+ process.exitCode = 1;
824
+ return;
825
+ }
826
+ throw new Error(message);
827
+ }
819
828
  const nowIso = new Date().toISOString();
820
829
  const repoRef = repoRefOverride ?? detectedRepo?.rawRef ?? dir;
821
830
  const repoPath = repoPathOverride ?? dir;
@@ -59,6 +59,9 @@ export async function setup(args) {
59
59
  console.log("\nDone. Restart your MCP client for the changes to take effect.");
60
60
  }
61
61
  console.log("\nRegistering this runtime as a Nexarch agent…\n");
62
- await initAgent(args.includes("--strict") ? args : [...args, "--strict"]);
62
+ const initAgentArgs = args.includes("--strict") ? [...args] : [...args, "--strict"];
63
+ if (!initAgentArgs.includes("--from-setup"))
64
+ initAgentArgs.push("--from-setup");
65
+ await initAgent(initAgentArgs);
63
66
  console.log("\nSetup complete: MCP client config + agent registration are now in place.");
64
67
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexarch",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Your architecture workspace for AI delivery.",
5
5
  "keywords": [
6
6
  "nexarch",