nexarch 0.8.19 → 0.8.20
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.
- package/dist/commands/init-agent.js +16 -2
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { arch, homedir, hostname, platform, release, type as osType, userInfo } from "os";
|
|
2
2
|
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "fs";
|
|
3
|
-
import { join } from "path";
|
|
3
|
+
import { join, resolve } from "path";
|
|
4
4
|
import * as readline from "node:readline/promises";
|
|
5
5
|
import process from "process";
|
|
6
6
|
import { requireCredentials } from "../lib/credentials.js";
|
|
@@ -8,7 +8,7 @@ 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.
|
|
11
|
+
const CLI_VERSION = "0.8.20";
|
|
12
12
|
const AGENT_ENTITY_TYPE = "agent";
|
|
13
13
|
const TECH_COMPONENT_ENTITY_TYPE = "technology_component";
|
|
14
14
|
function parseFlag(args, flag) {
|
|
@@ -320,10 +320,15 @@ function replaceInjectedSection(existing, sectionHeading, sectionBody) {
|
|
|
320
320
|
replaced = replaced.replace(/\n{3,}/g, "\n\n").trimEnd();
|
|
321
321
|
return `${replaced}${replaced ? "\n\n" : ""}${canonicalBlock}`;
|
|
322
322
|
}
|
|
323
|
+
function canonicalTargetKey(filePath) {
|
|
324
|
+
const abs = resolve(filePath);
|
|
325
|
+
return process.platform === "win32" || process.platform === "darwin" ? abs.toLowerCase() : abs;
|
|
326
|
+
}
|
|
323
327
|
function injectAgentConfigs(registry) {
|
|
324
328
|
const templateByCode = new Map(registry.instructionTemplates.map((t) => [t.code, t]));
|
|
325
329
|
const targets = [...registry.instructionTargets].sort((a, b) => a.sortOrder - b.sortOrder || a.filePathPattern.localeCompare(b.filePathPattern));
|
|
326
330
|
const results = [];
|
|
331
|
+
const seenTargets = new Set();
|
|
327
332
|
for (const target of targets) {
|
|
328
333
|
if (target.matchMode !== "exact")
|
|
329
334
|
continue;
|
|
@@ -331,6 +336,10 @@ function injectAgentConfigs(registry) {
|
|
|
331
336
|
if (!template)
|
|
332
337
|
continue;
|
|
333
338
|
const filePath = join(process.cwd(), target.filePathPattern);
|
|
339
|
+
const targetKey = canonicalTargetKey(filePath);
|
|
340
|
+
if (seenTargets.has(targetKey))
|
|
341
|
+
continue;
|
|
342
|
+
seenTargets.add(targetKey);
|
|
334
343
|
if (!existsSync(filePath))
|
|
335
344
|
continue;
|
|
336
345
|
const existing = readFileSync(filePath, "utf8");
|
|
@@ -425,11 +434,16 @@ function injectGenericAgentConfig(registry) {
|
|
|
425
434
|
const genericTargets = [...registry.instructionTargets]
|
|
426
435
|
.filter((t) => t.runtimeCode === "generic" && t.matchMode === "exact")
|
|
427
436
|
.sort((a, b) => a.sortOrder - b.sortOrder || a.filePathPattern.localeCompare(b.filePathPattern));
|
|
437
|
+
const seenTargets = new Set();
|
|
428
438
|
for (const target of genericTargets) {
|
|
429
439
|
const template = templateByCode.get(target.templateCode);
|
|
430
440
|
if (!template)
|
|
431
441
|
continue;
|
|
432
442
|
const filePath = join(process.cwd(), target.filePathPattern);
|
|
443
|
+
const targetKey = canonicalTargetKey(filePath);
|
|
444
|
+
if (seenTargets.has(targetKey))
|
|
445
|
+
continue;
|
|
446
|
+
seenTargets.add(targetKey);
|
|
433
447
|
const sectionBody = template.body.trim();
|
|
434
448
|
const sectionHeading = target.sectionHeading ?? "## Nexarch Agent Registration";
|
|
435
449
|
const managedBody = wrapManagedSection("agent-registration", sectionBody);
|