nexarch 0.4.4 ā 0.4.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.
- package/dist/commands/init-agent.js +44 -27
- package/dist/lib/mcp.js +1 -1
- package/package.json +1 -1
|
@@ -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.4.
|
|
8
|
+
const CLI_VERSION = "0.4.5";
|
|
9
9
|
const AGENT_ENTITY_TYPE = "agent";
|
|
10
10
|
const TECH_COMPONENT_ENTITY_TYPE = "technology_component";
|
|
11
11
|
function parseFlag(args, flag) {
|
|
@@ -214,6 +214,34 @@ function injectAgentConfigs(registry) {
|
|
|
214
214
|
}
|
|
215
215
|
return results;
|
|
216
216
|
}
|
|
217
|
+
function injectGenericAgentConfig(registry) {
|
|
218
|
+
const templateByCode = new Map(registry.instructionTemplates.map((t) => [t.code, t]));
|
|
219
|
+
const genericTargets = [...registry.instructionTargets]
|
|
220
|
+
.filter((t) => t.runtimeCode === "generic" && t.matchMode === "exact")
|
|
221
|
+
.sort((a, b) => a.sortOrder - b.sortOrder || a.filePathPattern.localeCompare(b.filePathPattern));
|
|
222
|
+
for (const target of genericTargets) {
|
|
223
|
+
const template = templateByCode.get(target.templateCode);
|
|
224
|
+
if (!template)
|
|
225
|
+
continue;
|
|
226
|
+
const filePath = join(process.cwd(), target.filePathPattern);
|
|
227
|
+
if (!existsSync(filePath))
|
|
228
|
+
continue;
|
|
229
|
+
const existing = readFileSync(filePath, "utf8");
|
|
230
|
+
const sectionBody = template.body.trim();
|
|
231
|
+
const sectionHeading = target.sectionHeading ?? "## Nexarch Agent Registration";
|
|
232
|
+
if (target.insertionMode === "replace_section") {
|
|
233
|
+
const replaced = replaceInjectedSection(existing, sectionHeading, sectionBody);
|
|
234
|
+
if (replaced !== existing) {
|
|
235
|
+
writeFileSync(filePath, replaced, "utf8");
|
|
236
|
+
return [{ path: filePath, status: "updated" }];
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const separator = existing.endsWith("\n") ? "" : "\n";
|
|
240
|
+
writeFileSync(filePath, existing + separator + sectionBody + "\n", "utf8");
|
|
241
|
+
return [{ path: filePath, status: "injected" }];
|
|
242
|
+
}
|
|
243
|
+
throw new Error("No runtime instruction target matched this repository, and no generic target could be applied. Add a matching instruction target in the agent registry (or create the expected target file in this repo).");
|
|
244
|
+
}
|
|
217
245
|
export async function initAgent(args) {
|
|
218
246
|
const asJson = parseFlag(args, "--json");
|
|
219
247
|
const strict = parseFlag(args, "--strict");
|
|
@@ -651,7 +679,6 @@ export async function initAgent(args) {
|
|
|
651
679
|
}
|
|
652
680
|
}
|
|
653
681
|
}
|
|
654
|
-
let bootstrapFilePath = null;
|
|
655
682
|
let agentConfigResults = [];
|
|
656
683
|
if (registration.ok) {
|
|
657
684
|
try {
|
|
@@ -663,24 +690,9 @@ export async function initAgent(args) {
|
|
|
663
690
|
catch {
|
|
664
691
|
// non-fatal
|
|
665
692
|
}
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
hostname: runtime.hostname,
|
|
670
|
-
osPlatform: runtime.osPlatform,
|
|
671
|
-
osRelease: runtime.osRelease,
|
|
672
|
-
nodeVersion: runtime.nodeVersion,
|
|
673
|
-
arch: runtime.arch,
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
catch {
|
|
677
|
-
// non-fatal
|
|
678
|
-
}
|
|
679
|
-
try {
|
|
680
|
-
agentConfigResults = injectAgentConfigs(registry);
|
|
681
|
-
}
|
|
682
|
-
catch {
|
|
683
|
-
// non-fatal
|
|
693
|
+
agentConfigResults = injectAgentConfigs(registry);
|
|
694
|
+
if (agentConfigResults.length === 0) {
|
|
695
|
+
agentConfigResults = injectGenericAgentConfig(registry);
|
|
684
696
|
}
|
|
685
697
|
}
|
|
686
698
|
checks.push({
|
|
@@ -742,7 +754,6 @@ export async function initAgent(args) {
|
|
|
742
754
|
},
|
|
743
755
|
companyId: creds.companyId,
|
|
744
756
|
registry: { version: registry.release.version, registryVersion: registry.registryVersion, publishedAt: registry.release.publishedAt },
|
|
745
|
-
bootstrapFile: bootstrapFilePath,
|
|
746
757
|
agentConfigs: agentConfigResults,
|
|
747
758
|
};
|
|
748
759
|
process.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
|
|
@@ -762,9 +773,7 @@ export async function initAgent(args) {
|
|
|
762
773
|
console.log("");
|
|
763
774
|
if (allPassed) {
|
|
764
775
|
console.log("ā
Agent handshake + registration completed.");
|
|
765
|
-
|
|
766
|
-
console.log(`\nš Bootstrap instructions written to: ${bootstrapFilePath}`);
|
|
767
|
-
}
|
|
776
|
+
// instructions were injected from registry templates
|
|
768
777
|
for (const r of agentConfigResults) {
|
|
769
778
|
if (r.status === "injected") {
|
|
770
779
|
console.log(`š Nexarch registration instructions added to: ${r.path}`);
|
|
@@ -773,9 +782,17 @@ export async function initAgent(args) {
|
|
|
773
782
|
console.log(`š Nexarch registration instructions updated in: ${r.path}`);
|
|
774
783
|
}
|
|
775
784
|
}
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
785
|
+
const hasInjectedAgentInstructions = agentConfigResults.some((r) => r.status === "injected" || r.status === "updated");
|
|
786
|
+
if (hasInjectedAgentInstructions) {
|
|
787
|
+
console.log("\nā” Next step: in your coding agent, run:");
|
|
788
|
+
console.log("\nrun npx nexarch@latest init-agent\n");
|
|
789
|
+
console.log(" (Registration instructions were already written into your agent config file.)");
|
|
790
|
+
}
|
|
791
|
+
else {
|
|
792
|
+
console.log("\nā” Next step (required): complete agent identity in your coding agent");
|
|
793
|
+
console.log(" Paste this and fill in real values:");
|
|
794
|
+
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`);
|
|
795
|
+
}
|
|
779
796
|
}
|
|
780
797
|
else {
|
|
781
798
|
console.log("ā Handshake/registration completed with issues.");
|
package/dist/lib/mcp.js
CHANGED
|
@@ -68,7 +68,7 @@ export async function mcpInitialize(options = {}) {
|
|
|
68
68
|
return callMcpRpc("initialize", {
|
|
69
69
|
protocolVersion: "2024-11-05",
|
|
70
70
|
capabilities: {},
|
|
71
|
-
clientInfo: { name: "nexarch-cli", version: "0.4.
|
|
71
|
+
clientInfo: { name: "nexarch-cli", version: "0.4.5" },
|
|
72
72
|
}, options);
|
|
73
73
|
}
|
|
74
74
|
export async function mcpListTools(options = {}) {
|