nexarch 0.12.6 → 0.12.7
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/ingest-infra.js +319 -0
- package/dist/commands/init-project-infra.js +170 -0
- package/dist/commands/init-project.js +19 -0
- package/dist/index.js +198 -192
- package/dist/lib/credentials.js +33 -1
- package/dist/lib/terraform-catalogue-seed.js +206 -0
- package/dist/lib/terraform-detect.js +338 -0
- package/dist/lib/terraform-projection.js +231 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ import { appliedPolicies } from "./commands/applied-policies.js";
|
|
|
26
26
|
import { governanceSummary } from "./commands/governance-summary.js";
|
|
27
27
|
import { proposalsStart } from "./commands/proposals-start.js";
|
|
28
28
|
import { registerRuntime } from "./commands/register-runtime.js";
|
|
29
|
+
import { ingestInfra } from "./commands/ingest-infra.js";
|
|
29
30
|
const [, , command, ...args] = process.argv;
|
|
30
31
|
const commands = {
|
|
31
32
|
login,
|
|
@@ -37,6 +38,7 @@ const commands = {
|
|
|
37
38
|
"init-agent": initAgent,
|
|
38
39
|
"agent-identify": agentIdentify,
|
|
39
40
|
"init-project": initProject,
|
|
41
|
+
"ingest-infra": ingestInfra,
|
|
40
42
|
"update-project": (args) => initProject(["--refresh", ...args]),
|
|
41
43
|
"update-entity": updateEntity,
|
|
42
44
|
"add-relationship": addRelationship,
|
|
@@ -73,198 +75,202 @@ async function main() {
|
|
|
73
75
|
}
|
|
74
76
|
const handler = commands[command ?? ""];
|
|
75
77
|
if (!handler) {
|
|
76
|
-
console.log(`
|
|
77
|
-
nexarch — Your architecture workspace for AI delivery.
|
|
78
|
-
|
|
79
|
-
Usage:
|
|
80
|
-
nexarch login Authenticate in browser and store company-scoped credentials
|
|
81
|
-
Option: --company <id>
|
|
82
|
-
nexarch logout Remove stored credentials
|
|
83
|
-
nexarch status Check connection and show architecture summary
|
|
84
|
-
nexarch setup One-step onboarding: login (if needed) + MCP config + register agent
|
|
85
|
-
nexarch mcp-config Print MCP server config block for manual setup
|
|
86
|
-
Client list is registry-managed (see 'nexarch mcp-config --client <code>')
|
|
87
|
-
nexarch mcp-proxy Run as stdio MCP proxy (used by MCP clients)
|
|
88
|
-
nexarch init-agent Run handshake + mandatory agent registration in graph (advanced/manual)
|
|
89
|
-
Options: --agent-id <id> --bind-to-external-key <key>
|
|
90
|
-
--bind-relationship-type <code> --redact-hostname
|
|
91
|
-
--json --strict
|
|
92
|
-
nexarch agent identify
|
|
93
|
-
Capture richer coding-agent identity metadata
|
|
94
|
-
Options: --agent-id <id> --provider <provider> --model <model>
|
|
95
|
-
--client <name> [--framework <name>] [--session-id <id>]
|
|
96
|
-
[--tool-version <v>] [--capabilities <csv>]
|
|
97
|
-
[--notes <text>] [--json]
|
|
98
|
-
nexarch agent-identify
|
|
99
|
-
Alias of 'nexarch agent identify'
|
|
100
|
-
nexarch init-project
|
|
101
|
-
Scan a project directory, resolve detected packages/env vars/
|
|
102
|
-
config files against the reference library, write entities and
|
|
103
|
-
relationships to the architecture graph, and log unresolved
|
|
104
|
-
names as reference candidates.
|
|
105
|
-
Monorepos register a project entity plus one proposed
|
|
106
|
-
application per deployable package (sourced_from the project).
|
|
107
|
-
Single-package repos register the repo's one application; when
|
|
108
|
-
similar applications exist they are listed, and the new
|
|
109
|
-
application is created as proposed for review at activation.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
--
|
|
116
|
-
--
|
|
117
|
-
--
|
|
118
|
-
--
|
|
119
|
-
--
|
|
120
|
-
--
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
--
|
|
144
|
-
--
|
|
145
|
-
--
|
|
146
|
-
--
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
--
|
|
165
|
-
--
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
Options: --
|
|
176
|
-
--
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
--
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
--
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
--
|
|
214
|
-
--
|
|
215
|
-
--
|
|
216
|
-
--
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
--
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
--
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
--
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
--json
|
|
238
|
-
nexarch policy-
|
|
239
|
-
|
|
240
|
-
Options: --entity <externalKey>
|
|
241
|
-
--
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
--
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
--
|
|
253
|
-
--
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
--
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
--
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
78
|
+
console.log(`
|
|
79
|
+
nexarch — Your architecture workspace for AI delivery.
|
|
80
|
+
|
|
81
|
+
Usage:
|
|
82
|
+
nexarch login Authenticate in browser and store company-scoped credentials
|
|
83
|
+
Option: --company <id>
|
|
84
|
+
nexarch logout Remove stored credentials
|
|
85
|
+
nexarch status Check connection and show architecture summary
|
|
86
|
+
nexarch setup One-step onboarding: login (if needed) + MCP config + register agent
|
|
87
|
+
nexarch mcp-config Print MCP server config block for manual setup
|
|
88
|
+
Client list is registry-managed (see 'nexarch mcp-config --client <code>')
|
|
89
|
+
nexarch mcp-proxy Run as stdio MCP proxy (used by MCP clients)
|
|
90
|
+
nexarch init-agent Run handshake + mandatory agent registration in graph (advanced/manual)
|
|
91
|
+
Options: --agent-id <id> --bind-to-external-key <key>
|
|
92
|
+
--bind-relationship-type <code> --redact-hostname
|
|
93
|
+
--json --strict
|
|
94
|
+
nexarch agent identify
|
|
95
|
+
Capture richer coding-agent identity metadata
|
|
96
|
+
Options: --agent-id <id> --provider <provider> --model <model>
|
|
97
|
+
--client <name> [--framework <name>] [--session-id <id>]
|
|
98
|
+
[--tool-version <v>] [--capabilities <csv>]
|
|
99
|
+
[--notes <text>] [--json]
|
|
100
|
+
nexarch agent-identify
|
|
101
|
+
Alias of 'nexarch agent identify'
|
|
102
|
+
nexarch init-project
|
|
103
|
+
Scan a project directory, resolve detected packages/env vars/
|
|
104
|
+
config files against the reference library, write entities and
|
|
105
|
+
relationships to the architecture graph, and log unresolved
|
|
106
|
+
names as reference candidates.
|
|
107
|
+
Monorepos register a project entity plus one proposed
|
|
108
|
+
application per deployable package (sourced_from the project).
|
|
109
|
+
Single-package repos register the repo's one application; when
|
|
110
|
+
similar applications exist they are listed, and the new
|
|
111
|
+
application is created as proposed for review at activation.
|
|
112
|
+
Terraform repositories take a different path: no dependency
|
|
113
|
+
scan and no applications. They register a project plus the
|
|
114
|
+
environments their root modules define, and hand over the
|
|
115
|
+
per-root ingest-infra commands that read the actual estate.
|
|
116
|
+
Options: --dir <path> (default: cwd)
|
|
117
|
+
--name <name> override project name
|
|
118
|
+
--entity-type <code> (default: application)
|
|
119
|
+
--application-ref <entityRef> force mapping target
|
|
120
|
+
--create-application force new application entity
|
|
121
|
+
--auto-map-application auto-map only when high confidence
|
|
122
|
+
--non-interactive deprecated (mapping no longer prompts)
|
|
123
|
+
--batch-size <n> upsert batch size (default: 10)
|
|
124
|
+
--profile include timing/profile data in JSON output
|
|
125
|
+
--dry-run preview without writing
|
|
126
|
+
--json
|
|
127
|
+
nexarch update-project
|
|
128
|
+
Re-scan a previously registered project directory, refresh
|
|
129
|
+
entities and relationships in the graph, and diff the new scan
|
|
130
|
+
against the current graph state to surface stale relationships
|
|
131
|
+
and removed sub-packages for the calling agent to review.
|
|
132
|
+
Accepts all the same options as init-project plus:
|
|
133
|
+
--application-ref <entityRef> target project key (recommended)
|
|
134
|
+
--auto-map-application auto-select best-match application
|
|
135
|
+
Output includes enrichmentRequired.diff with:
|
|
136
|
+
newRelationships — detected but not yet in graph
|
|
137
|
+
staleRelationships — in graph but absent from manifests
|
|
138
|
+
removedSubPackages — previously registered, no longer on disk
|
|
139
|
+
--json
|
|
140
|
+
nexarch update-entity
|
|
141
|
+
Update the name and/or description of an existing graph entity.
|
|
142
|
+
Use this after init-project to enrich the entity with meaningful
|
|
143
|
+
content from the project README or docs.
|
|
144
|
+
Options: --key <externalKey> (required)
|
|
145
|
+
--name <name>
|
|
146
|
+
--description <text>
|
|
147
|
+
--entity-type <code> (default: application)
|
|
148
|
+
--subtype <code>
|
|
149
|
+
--icon <lucide-name> (convenience; sets attributes.application_icon)
|
|
150
|
+
--attributes-json '<json object>'
|
|
151
|
+
--attributes-file <path.json>
|
|
152
|
+
--json
|
|
153
|
+
nexarch add-relationship
|
|
154
|
+
Add relationships between existing graph entities (single or batch).
|
|
155
|
+
Single options: --from <externalKey>
|
|
156
|
+
--to <externalKey>
|
|
157
|
+
--type <code> (e.g. part_of, depends_on)
|
|
158
|
+
Batch options: --relationships-json '<json array>'
|
|
159
|
+
--relationships-file <path.json>
|
|
160
|
+
--json
|
|
161
|
+
nexarch register-alias
|
|
162
|
+
Register a company-scoped alias for an entity so future
|
|
163
|
+
scans resolve it instead of logging it as a candidate.
|
|
164
|
+
Use after enriching internal monorepo packages.
|
|
165
|
+
Options: --alias <value> (required, e.g. @scope/name)
|
|
166
|
+
--key <externalKey> (required)
|
|
167
|
+
--name <name> (required)
|
|
168
|
+
--entity-type <code> (required)
|
|
169
|
+
--subtype <code>
|
|
170
|
+
--description <text>
|
|
171
|
+
--json
|
|
172
|
+
nexarch resolve-names
|
|
173
|
+
Look up one or more raw names (package names, platform
|
|
174
|
+
names) against the global reference library and return
|
|
175
|
+
their canonical external keys. Useful for gap-check
|
|
176
|
+
results before calling add-relationship.
|
|
177
|
+
Options: --names <csv> (required, e.g. "vercel,neon")
|
|
178
|
+
--json
|
|
179
|
+
nexarch list-entities
|
|
180
|
+
List entities from the workspace graph.
|
|
181
|
+
Options: --type <entityTypeCode>
|
|
182
|
+
--status <status>
|
|
183
|
+
--query <text>
|
|
184
|
+
--limit <1-500>
|
|
185
|
+
--json
|
|
186
|
+
nexarch list-relationships
|
|
187
|
+
List relationships from the workspace graph.
|
|
188
|
+
Options: --type <relationshipTypeCode>
|
|
189
|
+
--status <status>
|
|
190
|
+
--from <fromExternalKey>
|
|
191
|
+
--to <toExternalKey>
|
|
192
|
+
--limit <1-500>
|
|
193
|
+
--json
|
|
194
|
+
nexarch register-runtime
|
|
195
|
+
Register or refresh runtime + optional application context
|
|
196
|
+
without performing check-in.
|
|
197
|
+
Options: --application-ref <entityRef>
|
|
198
|
+
--client <name>
|
|
199
|
+
--version <semver>
|
|
200
|
+
--json
|
|
201
|
+
nexarch check-in Preview pending application-target commands (no auto-claim)
|
|
202
|
+
and report draft/proposed applications needing review so the
|
|
203
|
+
agent can prompt the user to explore and instantiate them.
|
|
204
|
+
Use command-claim to explicitly claim a specific command.
|
|
205
|
+
Scope is resolved server-side from active company context.
|
|
206
|
+
Options: --agent-key <key> override stored agent key
|
|
207
|
+
--application-ref <entityRef> narrow preview scope
|
|
208
|
+
--json JSON output includes draftApplications[] and proposedApplications[]
|
|
209
|
+
nexarch proposals start
|
|
210
|
+
Start a new application workspace from a proposed NexArch app.
|
|
211
|
+
Lists proposed apps, shows policy review gates, writes a starter
|
|
212
|
+
project scaffold, and activates the proposal to active once
|
|
213
|
+
required policy controls are acknowledged.
|
|
214
|
+
Options: --id <applicationId>
|
|
215
|
+
--dir <path>
|
|
216
|
+
--reason <text>
|
|
217
|
+
--repo <url>
|
|
218
|
+
--skip-activate
|
|
219
|
+
--activate
|
|
220
|
+
--force
|
|
221
|
+
--non-interactive
|
|
222
|
+
--json
|
|
223
|
+
nexarch command-claim
|
|
224
|
+
Explicitly claim a pending command by ID.
|
|
225
|
+
Options: --id <commandId> (required)
|
|
226
|
+
--agent-key <key> override stored agent key
|
|
227
|
+
--application-ref <entityRef> required for application-target commands
|
|
228
|
+
--json
|
|
229
|
+
nexarch command-done
|
|
230
|
+
Mark a claimed command as completed.
|
|
231
|
+
Options: --id <commandId> (required)
|
|
232
|
+
--summary <text> short summary of what was done
|
|
233
|
+
--summary-file <path.md|txt>
|
|
234
|
+
--json
|
|
235
|
+
nexarch command-fail
|
|
236
|
+
Mark a claimed command as failed.
|
|
237
|
+
Options: --id <commandId> (required)
|
|
238
|
+
--error <message> (required)
|
|
239
|
+
--json
|
|
240
|
+
nexarch policy-controls
|
|
241
|
+
Fetch policy controls/rules assigned to an entity (for policy audits).
|
|
242
|
+
Options: --entity <externalKey> (required, e.g. application:bad-driving)
|
|
243
|
+
--json
|
|
244
|
+
nexarch policy-audit-template
|
|
245
|
+
Generate a findings JSON template from policy controls/rules for an entity.
|
|
246
|
+
Options: --entity <externalKey> (required)
|
|
247
|
+
--control-id <uuid> (repeatable; optional filter)
|
|
248
|
+
--default-result <pass|partial|fail> (default: fail)
|
|
249
|
+
--output <path.json>
|
|
250
|
+
--json
|
|
251
|
+
nexarch policy-audit-submit
|
|
252
|
+
Submit structured policy findings (writes policy_audit_finding rows).
|
|
253
|
+
Options: --command-id <id> (required)
|
|
254
|
+
--application-key <key> (required)
|
|
255
|
+
--agent-key <key> (optional; defaults from identity)
|
|
256
|
+
--finding <controlId|ruleId|result|rationale|missing1;missing2> (repeatable)
|
|
257
|
+
--findings-json <json-array>
|
|
258
|
+
--findings-file <path.json>
|
|
259
|
+
--json
|
|
260
|
+
nexarch policy-audit-results
|
|
261
|
+
Retrieve stored results of previous policy audits for an application.
|
|
262
|
+
Options: --entity <applicationEntityRef> (required)
|
|
263
|
+
--limit <1-10> (default 1)
|
|
264
|
+
--json
|
|
265
|
+
nexarch applied-policies
|
|
266
|
+
List policy documents applied to this company account.
|
|
267
|
+
Options: --pack <packCode> filter to a specific pack
|
|
268
|
+
--markdown include full document markdown
|
|
269
|
+
--json
|
|
270
|
+
nexarch governance-summary
|
|
271
|
+
Print review queue, graph stats, and per-application policy
|
|
272
|
+
audit rollup (latest run status, pass/partial/fail counts).
|
|
273
|
+
Options: --json
|
|
268
274
|
`);
|
|
269
275
|
process.exit(command ? 1 : 0);
|
|
270
276
|
}
|
package/dist/lib/credentials.js
CHANGED
|
@@ -4,7 +4,35 @@ import { readFileSync, writeFileSync, mkdirSync, existsSync, rmSync } from "fs";
|
|
|
4
4
|
function credentialsPath() {
|
|
5
5
|
return join(homedir(), ".nexarch", "credentials.json");
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Credentials supplied by the environment, for CI.
|
|
9
|
+
*
|
|
10
|
+
* A pipeline cannot run `nexarch login` — that flow needs a browser and a
|
|
11
|
+
* human — so unattended commands such as `ingest-infra` take a service
|
|
12
|
+
* credential from the environment instead. `NEXARCH_TOKEN` is the token issued
|
|
13
|
+
* by `init-agent`; the company is carried by the token itself, so
|
|
14
|
+
* `NEXARCH_COMPANY_ID` is only needed for legacy static tokens.
|
|
15
|
+
*
|
|
16
|
+
* No local expiry check: the gateway is the authority on whether a service
|
|
17
|
+
* credential is still valid, and a stale clock in a runner should not be able
|
|
18
|
+
* to fail a build with a misleading "session expired".
|
|
19
|
+
*/
|
|
20
|
+
function credentialsFromEnvironment() {
|
|
21
|
+
const token = process.env.NEXARCH_TOKEN?.trim();
|
|
22
|
+
if (!token)
|
|
23
|
+
return null;
|
|
24
|
+
return {
|
|
25
|
+
token,
|
|
26
|
+
email: process.env.NEXARCH_ACTOR ?? "ci",
|
|
27
|
+
company: "",
|
|
28
|
+
companyId: process.env.NEXARCH_COMPANY_ID?.trim() ?? "",
|
|
29
|
+
expiresAt: new Date(Date.now() + 60 * 60 * 1000).toISOString(),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
7
32
|
export function loadCredentials() {
|
|
33
|
+
const fromEnv = credentialsFromEnvironment();
|
|
34
|
+
if (fromEnv)
|
|
35
|
+
return fromEnv;
|
|
8
36
|
const path = credentialsPath();
|
|
9
37
|
if (!existsSync(path))
|
|
10
38
|
return null;
|
|
@@ -35,8 +63,12 @@ export function removeCredentials() {
|
|
|
35
63
|
export function requireCredentials() {
|
|
36
64
|
const creds = loadCredentials();
|
|
37
65
|
if (!creds) {
|
|
38
|
-
throw new Error("Not logged in. Run `nexarch login` to authenticate.");
|
|
66
|
+
throw new Error("Not logged in. Run `nexarch login` to authenticate, or set NEXARCH_TOKEN for unattended use.");
|
|
39
67
|
}
|
|
68
|
+
// Environment-supplied service credentials are validated by the gateway, not
|
|
69
|
+
// by this process; only the stored interactive session carries a local expiry.
|
|
70
|
+
if (process.env.NEXARCH_TOKEN?.trim())
|
|
71
|
+
return creds;
|
|
40
72
|
if (new Date(creds.expiresAt) < new Date()) {
|
|
41
73
|
throw new Error("Your session has expired. Run `nexarch login` to re-authenticate.");
|
|
42
74
|
}
|