nexarch 0.1.22 → 0.1.23
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.
|
|
7
|
+
const CLI_VERSION = "0.1.23";
|
|
8
8
|
const AGENT_ENTITY_TYPE = "agent";
|
|
9
9
|
const TECH_COMPONENT_ENTITY_TYPE = "technology_component";
|
|
10
10
|
function parseFlag(args, flag) {
|
|
@@ -25,7 +25,7 @@ function slugify(name) {
|
|
|
25
25
|
}
|
|
26
26
|
// ─── Project scanning ─────────────────────────────────────────────────────────
|
|
27
27
|
// Noise patterns for env var keys that are internal config, not external service references
|
|
28
|
-
const ENV_KEY_NOISE = /^(NODE_ENV|PORT|HOST|DEBUG|LOG_LEVEL|TZ|LANG|PATH|HOME|USER|SHELL|TERM)$|(_LOG_LEVEL|_MAX_|_MIN_|_DEFAULT_|_TIMEOUT|_DELAY|_JOBS|_INTERVAL|_LIMIT|_RETRIES|_CONCURREN|_WORKERS)$|^NEXT_PUBLIC_(APP|ADMIN|API|SITE|BASE|WEB)_URL$/;
|
|
28
|
+
const ENV_KEY_NOISE = /^(NODE_ENV|PORT|HOST|DEBUG|LOG_LEVEL|TZ|LANG|PATH|HOME|USER|SHELL|TERM)$|(_LOG_LEVEL|_MAX_|_MIN_|_DEFAULT_|_TIMEOUT|_DELAY|_JOBS|_INTERVAL|_LIMIT|_RETRIES|_CONCURREN|_WORKERS)$|^NEXT_PUBLIC_(APP|ADMIN|API|SITE|BASE|WEB)_URL$|(_URL|_SECRET|_TOKEN|_KEY|_PASSWORD|_CREDENTIAL|_DSN|_URI)$/;
|
|
29
29
|
function parseEnvKeys(content) {
|
|
30
30
|
return content
|
|
31
31
|
.split("\n")
|
|
@@ -97,9 +97,9 @@ const SKIP_DIRS = new Set(["node_modules", "dist", ".next", ".turbo", "build", "
|
|
|
97
97
|
function collectPackageDeps(pkgPath) {
|
|
98
98
|
try {
|
|
99
99
|
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
100
|
+
// devDependencies are build/test/type tooling — no architectural value
|
|
100
101
|
return Object.keys({
|
|
101
102
|
...pkg.dependencies,
|
|
102
|
-
...pkg.devDependencies,
|
|
103
103
|
...pkg.peerDependencies,
|
|
104
104
|
});
|
|
105
105
|
}
|
|
@@ -465,7 +465,7 @@ ${subPackages.map((sp) => ` • ${sp.name} (${sp.relativePath})`).join("\n")
|
|
|
465
465
|
Type definitions or utility package with no runtime
|
|
466
466
|
→ --entity-type technology_component --subtype tech_library
|
|
467
467
|
|
|
468
|
-
For each sub-package, run:
|
|
468
|
+
For each sub-package, run update-entity to register it:
|
|
469
469
|
|
|
470
470
|
npx nexarch update-entity \\
|
|
471
471
|
--key "<entity-type>:<slugified-package-name>" \\
|
|
@@ -474,12 +474,28 @@ ${subPackages.map((sp) => ` • ${sp.name} (${sp.relativePath})`).join("\n")
|
|
|
474
474
|
--name "<human readable name>" \\
|
|
475
475
|
--description "<what this package does and its role in the project>"
|
|
476
476
|
|
|
477
|
-
Then
|
|
478
|
-
• Deployable apps → relationship type: part_of
|
|
479
|
-
• Shared libraries → relationship type: depends_on (parent depends on the library)
|
|
477
|
+
Then register it as a resolvable alias so future scans don't re-surface it as a candidate:
|
|
480
478
|
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
479
|
+
npx nexarch register-alias \\
|
|
480
|
+
--alias "<original package name e.g. @scope/name>" \\
|
|
481
|
+
--key "<same entity-type>:<slugified-package-name>" \\
|
|
482
|
+
--name "<same human readable name>" \\
|
|
483
|
+
--entity-type "<same entity type>"
|
|
484
|
+
|
|
485
|
+
⚠️ DIRECTION MATTERS — wire relationships as follows:
|
|
486
|
+
|
|
487
|
+
Deployable sub-apps (apps/*) are PART OF the parent — child points to parent:
|
|
488
|
+
npx nexarch add-relationship \\
|
|
489
|
+
--from "<sub-app-key>" \\
|
|
490
|
+
--to "${projectExternalKey}" \\
|
|
491
|
+
--type "part_of"
|
|
492
|
+
(FROM = the sub-app, TO = ${projectExternalKey})
|
|
493
|
+
|
|
494
|
+
Shared libraries (packages/*) are depended on by the parent — parent points to library:
|
|
495
|
+
npx nexarch add-relationship \\
|
|
496
|
+
--from "${projectExternalKey}" \\
|
|
497
|
+
--to "<library-key>" \\
|
|
498
|
+
--type "depends_on"
|
|
499
|
+
(FROM = ${projectExternalKey}, TO = the library)
|
|
484
500
|
` : ""}`);
|
|
485
501
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import process from "process";
|
|
2
|
+
import { requireCredentials } from "../lib/credentials.js";
|
|
3
|
+
import { callMcpTool } from "../lib/mcp.js";
|
|
4
|
+
function parseFlag(args, flag) {
|
|
5
|
+
return args.includes(flag);
|
|
6
|
+
}
|
|
7
|
+
function parseOptionValue(args, option) {
|
|
8
|
+
const idx = args.indexOf(option);
|
|
9
|
+
if (idx === -1)
|
|
10
|
+
return null;
|
|
11
|
+
const value = args[idx + 1];
|
|
12
|
+
if (!value || value.startsWith("--"))
|
|
13
|
+
return null;
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
function parseToolText(result) {
|
|
17
|
+
const text = result.content?.[0]?.text ?? "{}";
|
|
18
|
+
return JSON.parse(text);
|
|
19
|
+
}
|
|
20
|
+
export async function registerAlias(args) {
|
|
21
|
+
const asJson = parseFlag(args, "--json");
|
|
22
|
+
const alias = parseOptionValue(args, "--alias");
|
|
23
|
+
const key = parseOptionValue(args, "--key");
|
|
24
|
+
const name = parseOptionValue(args, "--name");
|
|
25
|
+
const entityTypeCode = parseOptionValue(args, "--entity-type");
|
|
26
|
+
const entitySubtypeCode = parseOptionValue(args, "--subtype");
|
|
27
|
+
const description = parseOptionValue(args, "--description");
|
|
28
|
+
if (!alias) {
|
|
29
|
+
console.error("error: --alias <value> is required");
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
if (!key) {
|
|
33
|
+
console.error("error: --key <externalKey> is required");
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
if (!name) {
|
|
37
|
+
console.error("error: --name <name> is required");
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
if (!entityTypeCode) {
|
|
41
|
+
console.error("error: --entity-type <code> is required");
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
const creds = requireCredentials();
|
|
45
|
+
const mcpOpts = { companyId: creds.companyId };
|
|
46
|
+
const raw = await callMcpTool("nexarch_register_alias", {
|
|
47
|
+
alias,
|
|
48
|
+
canonicalExternalKey: key,
|
|
49
|
+
canonicalName: name,
|
|
50
|
+
entityTypeCode,
|
|
51
|
+
...(entitySubtypeCode ? { entitySubtypeCode } : {}),
|
|
52
|
+
...(description ? { description } : {}),
|
|
53
|
+
companyId: creds.companyId,
|
|
54
|
+
}, mcpOpts);
|
|
55
|
+
const result = parseToolText(raw);
|
|
56
|
+
if (asJson) {
|
|
57
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
console.log(`Registered alias "${result.alias}" → ${result.canonicalExternalKey}`);
|
|
61
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { agentIdentify } from "./commands/agent-identify.js";
|
|
|
13
13
|
import { initProject } from "./commands/init-project.js";
|
|
14
14
|
import { updateEntity } from "./commands/update-entity.js";
|
|
15
15
|
import { addRelationship } from "./commands/add-relationship.js";
|
|
16
|
+
import { registerAlias } from "./commands/register-alias.js";
|
|
16
17
|
const [, , command, ...args] = process.argv;
|
|
17
18
|
const commands = {
|
|
18
19
|
login,
|
|
@@ -26,6 +27,7 @@ const commands = {
|
|
|
26
27
|
"init-project": initProject,
|
|
27
28
|
"update-entity": updateEntity,
|
|
28
29
|
"add-relationship": addRelationship,
|
|
30
|
+
"register-alias": registerAlias,
|
|
29
31
|
};
|
|
30
32
|
async function main() {
|
|
31
33
|
if (command === "agent") {
|
|
@@ -101,6 +103,17 @@ Usage:
|
|
|
101
103
|
--to <externalKey> (required)
|
|
102
104
|
--type <code> (required, e.g. part_of, depends_on)
|
|
103
105
|
--json
|
|
106
|
+
nexarch register-alias
|
|
107
|
+
Register a company-scoped alias for an entity so future
|
|
108
|
+
scans resolve it instead of logging it as a candidate.
|
|
109
|
+
Use after enriching internal monorepo packages.
|
|
110
|
+
Options: --alias <value> (required, e.g. @scope/name)
|
|
111
|
+
--key <externalKey> (required)
|
|
112
|
+
--name <name> (required)
|
|
113
|
+
--entity-type <code> (required)
|
|
114
|
+
--subtype <code>
|
|
115
|
+
--description <text>
|
|
116
|
+
--json
|
|
104
117
|
`);
|
|
105
118
|
process.exit(command ? 1 : 0);
|
|
106
119
|
}
|