nexarch 0.2.4 → 0.2.5

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.
@@ -20,16 +20,19 @@ function parseToolText(result) {
20
20
  const text = result.content?.[0]?.text ?? "{}";
21
21
  return JSON.parse(text);
22
22
  }
23
- function loadStoredAgentKey() {
23
+ function loadIdentity() {
24
24
  const identityPath = join(homedir(), ".nexarch", "identity.json");
25
25
  if (!existsSync(identityPath))
26
- return null;
26
+ return { agentKey: null, projectKeys: [] };
27
27
  try {
28
28
  const data = JSON.parse(readFileSync(identityPath, "utf8"));
29
- return data.agentKey ?? null;
29
+ return {
30
+ agentKey: data.agentKey ?? null,
31
+ projectKeys: Array.isArray(data.projectKeys) ? data.projectKeys : [],
32
+ };
30
33
  }
31
34
  catch {
32
- return null;
35
+ return { agentKey: null, projectKeys: [] };
33
36
  }
34
37
  }
35
38
  const COMMAND_TYPE_HINTS = {
@@ -47,7 +50,10 @@ export async function checkIn(args) {
47
50
  const agentKeyArg = parseOptionValue(args, "--agent-key");
48
51
  const projectKey = parseOptionValue(args, "--project");
49
52
  const creds = requireCredentials();
50
- const agentKey = agentKeyArg ?? loadStoredAgentKey();
53
+ const identity = loadIdentity();
54
+ const agentKey = agentKeyArg ?? identity.agentKey;
55
+ // Use --project flag as a single override, otherwise send all stored keys
56
+ const resolvedProjectKeys = projectKey ? [projectKey] : identity.projectKeys;
51
57
  if (!agentKey) {
52
58
  if (asJson) {
53
59
  process.stdout.write(JSON.stringify({ command: null, reason: "no-agent-key" }) + "\n");
@@ -60,7 +66,7 @@ export async function checkIn(args) {
60
66
  const mcpOpts = { companyId: creds.companyId };
61
67
  const raw = await callMcpTool("nexarch_claim_command", {
62
68
  agentKey,
63
- ...(projectKey ? { projectKey } : {}),
69
+ ...(resolvedProjectKeys.length > 0 ? { projectKeys: resolvedProjectKeys } : {}),
64
70
  companyId: creds.companyId,
65
71
  }, mcpOpts);
66
72
  const result = parseToolText(raw);
@@ -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.2.3";
7
+ const CLI_VERSION = "0.2.5";
8
8
  const AGENT_ENTITY_TYPE = "agent";
9
9
  const TECH_COMPONENT_ENTITY_TYPE = "technology_component";
10
10
  function parseFlag(args, flag) {
@@ -1,6 +1,7 @@
1
1
  import process from "process";
2
- import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
2
+ import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
3
3
  import { basename, join, resolve as resolvePath } from "node:path";
4
+ import { homedir } from "node:os";
4
5
  import { requireCredentials } from "../lib/credentials.js";
5
6
  import { callMcpTool } from "../lib/mcp.js";
6
7
  // ─── Helpers ─────────────────────────────────────────────────────────────────
@@ -939,6 +940,30 @@ ${subPkgSection}${gapCheckSection}`;
939
940
  relationshipErrors: relsResult?.errors ?? [],
940
941
  enrichmentTask,
941
942
  };
943
+ // Persist all application entity keys to ~/.nexarch/identity.json so nexarch check-in
944
+ // can automatically claim commands targeted at any application in this project.
945
+ if (output.ok) {
946
+ try {
947
+ const allAppKeys = [
948
+ projectExternalKey,
949
+ ...subPackages
950
+ .filter((sp) => sp.entityType === "application" && sp.externalKey)
951
+ .map((sp) => sp.externalKey),
952
+ ];
953
+ const identityDir = join(homedir(), ".nexarch");
954
+ mkdirSync(identityDir, { recursive: true });
955
+ const identityPath = join(identityDir, "identity.json");
956
+ const existing = existsSync(identityPath)
957
+ ? JSON.parse(readFileSync(identityPath, "utf8"))
958
+ : {};
959
+ const stored = Array.isArray(existing.projectKeys) ? existing.projectKeys : [];
960
+ const merged = Array.from(new Set([...allAppKeys, ...stored]));
961
+ writeFileSync(identityPath, JSON.stringify({ ...existing, projectKeys: merged }, null, 2), { mode: 0o600 });
962
+ }
963
+ catch {
964
+ // non-fatal
965
+ }
966
+ }
942
967
  if (asJson) {
943
968
  process.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
944
969
  if (!output.ok)
package/dist/lib/mcp.js CHANGED
@@ -62,7 +62,7 @@ export async function mcpInitialize(options = {}) {
62
62
  return callMcpRpc("initialize", {
63
63
  protocolVersion: "2024-11-05",
64
64
  capabilities: {},
65
- clientInfo: { name: "nexarch-cli", version: "0.2.3" },
65
+ clientInfo: { name: "nexarch-cli", version: "0.2.5" },
66
66
  }, options);
67
67
  }
68
68
  export async function mcpListTools(options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexarch",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Connect AI coding tools to your Nexarch architecture workspace",
5
5
  "keywords": [
6
6
  "nexarch",