nexus-agents 2.167.1 → 2.169.0
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/README.md +1 -1
- package/dist/{child-mcp-config-X4YLQKGK.js → child-mcp-config-FJRGAMUU.js} +2 -2
- package/dist/{chunk-UNIDAVVR.js → chunk-3JH3FMEJ.js} +2 -2
- package/dist/{chunk-6KCZA3IO.js → chunk-3ON2P4WL.js} +4 -4
- package/dist/{chunk-GRWHPG72.js → chunk-4G5W5EPU.js} +7 -7
- package/dist/{chunk-O6VL6LA4.js → chunk-5O4JRXNQ.js} +2 -2
- package/dist/{chunk-7K5LSUEU.js → chunk-7S43YASS.js} +3 -3
- package/dist/{chunk-QV52AXTF.js → chunk-BWG54OJS.js} +2 -2
- package/dist/{chunk-XUMLVCFL.js → chunk-CD2NZFAI.js} +2 -2
- package/dist/{chunk-7YD3TRDX.js → chunk-CHF63T3L.js} +4 -4
- package/dist/{chunk-GVNY4ZB6.js → chunk-DSMSYENI.js} +2 -2
- package/dist/{chunk-ZIC6ZZFU.js → chunk-EQRN5FRZ.js} +3 -3
- package/dist/{chunk-TGAVZ2ZL.js → chunk-F6HJJG3E.js} +8 -8
- package/dist/{chunk-PC4Y4VPX.js → chunk-HAVBBSYN.js} +2 -2
- package/dist/{chunk-VNVGGM73.js → chunk-HNNSCTOI.js} +2 -2
- package/dist/{chunk-STMW5BSR.js → chunk-IQC2K3KY.js} +3 -3
- package/dist/{chunk-2NU774CB.js → chunk-JCJHQSAY.js} +2 -2
- package/dist/{chunk-IFSIKGHI.js → chunk-MCT7JJF6.js} +2 -2
- package/dist/{chunk-2S7T66IQ.js → chunk-N7FIUFQL.js} +811 -598
- package/dist/chunk-N7FIUFQL.js.map +1 -0
- package/dist/{chunk-S6HCREYY.js → chunk-NT3KCLT6.js} +7 -7
- package/dist/{chunk-7USEQLMS.js → chunk-OOFPDA3B.js} +2 -2
- package/dist/{chunk-GGYQTV2Y.js → chunk-P7MYTCE6.js} +4 -4
- package/dist/{chunk-COIZLMGV.js → chunk-PZF67XDY.js} +3 -3
- package/dist/{chunk-KM3YEIEN.js → chunk-Q3UMNYV2.js} +4 -4
- package/dist/{chunk-CURHM4TH.js → chunk-QXSR5KPG.js} +25 -4
- package/dist/chunk-QXSR5KPG.js.map +1 -0
- package/dist/{chunk-RKIPSMCN.js → chunk-R46SBPLH.js} +5 -5
- package/dist/{chunk-BB7KSLNA.js → chunk-RO23OT47.js} +2 -2
- package/dist/{chunk-EUQNHT7O.js → chunk-ROCNXZBC.js} +12 -8
- package/dist/chunk-ROCNXZBC.js.map +1 -0
- package/dist/{chunk-SRNAXDOT.js → chunk-SX4E2W3Z.js} +2 -2
- package/dist/{chunk-ZTTUXPBQ.js → chunk-T3VD32JY.js} +2 -2
- package/dist/{chunk-ZAPCPHGZ.js → chunk-TB26XNJH.js} +2 -2
- package/dist/{chunk-QPSYBHK6.js → chunk-W76DOL27.js} +2 -2
- package/dist/{chunk-3T6KLPGT.js → chunk-WB33EPTV.js} +5 -5
- package/dist/{chunk-ZSUN7BHE.js → chunk-XGNB7LQB.js} +696 -14
- package/dist/chunk-XGNB7LQB.js.map +1 -0
- package/dist/{chunk-AO4X3BMP.js → chunk-YF35FKKD.js} +2 -1
- package/dist/chunk-YF35FKKD.js.map +1 -0
- package/dist/{chunk-JKUX73VD.js → chunk-ZXFIBDT3.js} +3 -3
- package/dist/{cli-circuit-breaker-2AAHSCHR.js → cli-circuit-breaker-FJQXDC5M.js} +4 -4
- package/dist/cli.js +394 -893
- package/dist/cli.js.map +1 -1
- package/dist/codebase-search-LUF5YJLQ.js +14 -0
- package/dist/{composite-router-WOVGICBS.js → composite-router-UQTCPADM.js} +2 -2
- package/dist/{consensus-vote-322S65GQ.js → consensus-vote-FEDF24T5.js} +15 -15
- package/dist/{context-retriever-YMJY6YBJ.js → context-retriever-TIJGFLGO.js} +8 -8
- package/dist/{doctor-deep-DALT3OXC.js → doctor-deep-EULAHWTK.js} +3 -3
- package/dist/{expert-bridge-WNV3ST2T.js → expert-bridge-7HQ54XYU.js} +4 -4
- package/dist/{factory-33HQYVCK.js → factory-QZZQVDGQ.js} +8 -8
- package/dist/{factory-TLSTFONW.js → factory-RW2ROEDS.js} +5 -5
- package/dist/{improvement-review-2W6LKP74.js → improvement-review-DGQPADKS.js} +5 -5
- package/dist/index.d.ts +40 -1
- package/dist/index.js +35 -31
- package/dist/index.js.map +1 -1
- package/dist/{init-opencode-XVTVJ6FN.js → init-opencode-MK2NUEWH.js} +5 -5
- package/dist/{issue-triage-CVMVZ3IV.js → issue-triage-RVDZEM53.js} +6 -6
- package/dist/{pr-reviewer-helpers-SAMOVLNJ.js → pr-reviewer-helpers-TKXJBDT6.js} +4 -4
- package/dist/{registry-command-5D2DJT53.js → registry-command-VXXKVZ3H.js} +2 -2
- package/dist/{repo-security-plan-F7V5SHAQ.js → repo-security-plan-YCTKRAGA.js} +3 -3
- package/dist/{research-helpers-synthesize-F4PV4B4B.js → research-helpers-synthesize-4L6SXYQU.js} +4 -4
- package/dist/{routing-memory-G6YBK4WI.js → routing-memory-INY5DC2P.js} +2 -2
- package/dist/{session-memory-DAJHLPOY.js → session-memory-TQMLN67N.js} +3 -3
- package/dist/{setup-command-NUNIRAFN.js → setup-command-FT5LBTSR.js} +13 -13
- package/dist/{setup-config-HKUWFV5N.js → setup-config-U3WLC5OO.js} +3 -3
- package/dist/{setup-custom-api-XRUPWEPF.js → setup-custom-api-2E4MZ5MF.js} +3 -3
- package/dist/{tool-memory-XJ5VRMNQ.js → tool-memory-IV5BVIV4.js} +5 -5
- package/dist/{unified-registry-ETKPTZBU.js → unified-registry-6LFTI4MG.js} +9 -9
- package/dist/{weather-report-TWBLIHPZ.js → weather-report-7NZ6D4C7.js} +2 -2
- package/package.json +2 -1
- package/dist/chunk-2S7T66IQ.js.map +0 -1
- package/dist/chunk-AO4X3BMP.js.map +0 -1
- package/dist/chunk-CURHM4TH.js.map +0 -1
- package/dist/chunk-EUQNHT7O.js.map +0 -1
- package/dist/chunk-ZSUN7BHE.js.map +0 -1
- package/dist/codebase-search-DKLEA4PR.js +0 -12
- /package/dist/{child-mcp-config-X4YLQKGK.js.map → child-mcp-config-FJRGAMUU.js.map} +0 -0
- /package/dist/{chunk-UNIDAVVR.js.map → chunk-3JH3FMEJ.js.map} +0 -0
- /package/dist/{chunk-6KCZA3IO.js.map → chunk-3ON2P4WL.js.map} +0 -0
- /package/dist/{chunk-GRWHPG72.js.map → chunk-4G5W5EPU.js.map} +0 -0
- /package/dist/{chunk-O6VL6LA4.js.map → chunk-5O4JRXNQ.js.map} +0 -0
- /package/dist/{chunk-7K5LSUEU.js.map → chunk-7S43YASS.js.map} +0 -0
- /package/dist/{chunk-QV52AXTF.js.map → chunk-BWG54OJS.js.map} +0 -0
- /package/dist/{chunk-XUMLVCFL.js.map → chunk-CD2NZFAI.js.map} +0 -0
- /package/dist/{chunk-7YD3TRDX.js.map → chunk-CHF63T3L.js.map} +0 -0
- /package/dist/{chunk-GVNY4ZB6.js.map → chunk-DSMSYENI.js.map} +0 -0
- /package/dist/{chunk-ZIC6ZZFU.js.map → chunk-EQRN5FRZ.js.map} +0 -0
- /package/dist/{chunk-TGAVZ2ZL.js.map → chunk-F6HJJG3E.js.map} +0 -0
- /package/dist/{chunk-PC4Y4VPX.js.map → chunk-HAVBBSYN.js.map} +0 -0
- /package/dist/{chunk-VNVGGM73.js.map → chunk-HNNSCTOI.js.map} +0 -0
- /package/dist/{chunk-STMW5BSR.js.map → chunk-IQC2K3KY.js.map} +0 -0
- /package/dist/{chunk-2NU774CB.js.map → chunk-JCJHQSAY.js.map} +0 -0
- /package/dist/{chunk-IFSIKGHI.js.map → chunk-MCT7JJF6.js.map} +0 -0
- /package/dist/{chunk-S6HCREYY.js.map → chunk-NT3KCLT6.js.map} +0 -0
- /package/dist/{chunk-7USEQLMS.js.map → chunk-OOFPDA3B.js.map} +0 -0
- /package/dist/{chunk-GGYQTV2Y.js.map → chunk-P7MYTCE6.js.map} +0 -0
- /package/dist/{chunk-COIZLMGV.js.map → chunk-PZF67XDY.js.map} +0 -0
- /package/dist/{chunk-KM3YEIEN.js.map → chunk-Q3UMNYV2.js.map} +0 -0
- /package/dist/{chunk-RKIPSMCN.js.map → chunk-R46SBPLH.js.map} +0 -0
- /package/dist/{chunk-BB7KSLNA.js.map → chunk-RO23OT47.js.map} +0 -0
- /package/dist/{chunk-SRNAXDOT.js.map → chunk-SX4E2W3Z.js.map} +0 -0
- /package/dist/{chunk-ZTTUXPBQ.js.map → chunk-T3VD32JY.js.map} +0 -0
- /package/dist/{chunk-ZAPCPHGZ.js.map → chunk-TB26XNJH.js.map} +0 -0
- /package/dist/{chunk-QPSYBHK6.js.map → chunk-W76DOL27.js.map} +0 -0
- /package/dist/{chunk-3T6KLPGT.js.map → chunk-WB33EPTV.js.map} +0 -0
- /package/dist/{chunk-JKUX73VD.js.map → chunk-ZXFIBDT3.js.map} +0 -0
- /package/dist/{cli-circuit-breaker-2AAHSCHR.js.map → cli-circuit-breaker-FJQXDC5M.js.map} +0 -0
- /package/dist/{codebase-search-DKLEA4PR.js.map → codebase-search-LUF5YJLQ.js.map} +0 -0
- /package/dist/{composite-router-WOVGICBS.js.map → composite-router-UQTCPADM.js.map} +0 -0
- /package/dist/{consensus-vote-322S65GQ.js.map → consensus-vote-FEDF24T5.js.map} +0 -0
- /package/dist/{context-retriever-YMJY6YBJ.js.map → context-retriever-TIJGFLGO.js.map} +0 -0
- /package/dist/{doctor-deep-DALT3OXC.js.map → doctor-deep-EULAHWTK.js.map} +0 -0
- /package/dist/{expert-bridge-WNV3ST2T.js.map → expert-bridge-7HQ54XYU.js.map} +0 -0
- /package/dist/{factory-33HQYVCK.js.map → factory-QZZQVDGQ.js.map} +0 -0
- /package/dist/{factory-TLSTFONW.js.map → factory-RW2ROEDS.js.map} +0 -0
- /package/dist/{improvement-review-2W6LKP74.js.map → improvement-review-DGQPADKS.js.map} +0 -0
- /package/dist/{init-opencode-XVTVJ6FN.js.map → init-opencode-MK2NUEWH.js.map} +0 -0
- /package/dist/{issue-triage-CVMVZ3IV.js.map → issue-triage-RVDZEM53.js.map} +0 -0
- /package/dist/{pr-reviewer-helpers-SAMOVLNJ.js.map → pr-reviewer-helpers-TKXJBDT6.js.map} +0 -0
- /package/dist/{registry-command-5D2DJT53.js.map → registry-command-VXXKVZ3H.js.map} +0 -0
- /package/dist/{repo-security-plan-F7V5SHAQ.js.map → repo-security-plan-YCTKRAGA.js.map} +0 -0
- /package/dist/{research-helpers-synthesize-F4PV4B4B.js.map → research-helpers-synthesize-4L6SXYQU.js.map} +0 -0
- /package/dist/{routing-memory-G6YBK4WI.js.map → routing-memory-INY5DC2P.js.map} +0 -0
- /package/dist/{session-memory-DAJHLPOY.js.map → session-memory-TQMLN67N.js.map} +0 -0
- /package/dist/{setup-command-NUNIRAFN.js.map → setup-command-FT5LBTSR.js.map} +0 -0
- /package/dist/{setup-config-HKUWFV5N.js.map → setup-config-U3WLC5OO.js.map} +0 -0
- /package/dist/{setup-custom-api-XRUPWEPF.js.map → setup-custom-api-2E4MZ5MF.js.map} +0 -0
- /package/dist/{tool-memory-XJ5VRMNQ.js.map → tool-memory-IV5BVIV4.js.map} +0 -0
- /package/dist/{unified-registry-ETKPTZBU.js.map → unified-registry-6LFTI4MG.js.map} +0 -0
- /package/dist/{weather-report-TWBLIHPZ.js.map → weather-report-7NZ6D4C7.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -13,13 +13,13 @@ import {
|
|
|
13
13
|
generateSummary,
|
|
14
14
|
parseFindings,
|
|
15
15
|
sumFindings
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import "./chunk-
|
|
16
|
+
} from "./chunk-ZXFIBDT3.js";
|
|
17
|
+
import "./chunk-5O4JRXNQ.js";
|
|
18
18
|
import {
|
|
19
19
|
setupCommandAsync,
|
|
20
20
|
verifyCommand
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import "./chunk-
|
|
21
|
+
} from "./chunk-WB33EPTV.js";
|
|
22
|
+
import "./chunk-CD2NZFAI.js";
|
|
23
23
|
import {
|
|
24
24
|
AuthHandler,
|
|
25
25
|
DEFAULT_EXPERTS,
|
|
@@ -119,6 +119,7 @@ import {
|
|
|
119
119
|
registerRunTool,
|
|
120
120
|
registerRunWorkflowTool,
|
|
121
121
|
registerSearchCodebaseTool,
|
|
122
|
+
registerSearchUsagesTool,
|
|
122
123
|
registerSuggestResearchTasksTool,
|
|
123
124
|
registerSupplyChainTradeoffPanelTool,
|
|
124
125
|
registerSurveyOssLandscapeTool,
|
|
@@ -138,10 +139,10 @@ import {
|
|
|
138
139
|
validateCommand,
|
|
139
140
|
validateWorkflow,
|
|
140
141
|
wrapInMarkdownFence
|
|
141
|
-
} from "./chunk-
|
|
142
|
-
import "./chunk-
|
|
142
|
+
} from "./chunk-N7FIUFQL.js";
|
|
143
|
+
import "./chunk-HNNSCTOI.js";
|
|
143
144
|
import "./chunk-HFOQKCD2.js";
|
|
144
|
-
import "./chunk-
|
|
145
|
+
import "./chunk-YF35FKKD.js";
|
|
145
146
|
import {
|
|
146
147
|
CATEGORY_DISPLAY_NAMES,
|
|
147
148
|
DEFAULT_PR_REVIEW_CONFIG
|
|
@@ -165,15 +166,15 @@ import {
|
|
|
165
166
|
loadConfig,
|
|
166
167
|
runDoctor,
|
|
167
168
|
validateNexusEnv
|
|
168
|
-
} from "./chunk-
|
|
169
|
+
} from "./chunk-ROCNXZBC.js";
|
|
169
170
|
import {
|
|
170
171
|
buildOpenAICompatAdapters,
|
|
171
172
|
readOpenAICompatEnv
|
|
172
|
-
} from "./chunk-
|
|
173
|
-
import "./chunk-
|
|
173
|
+
} from "./chunk-3ON2P4WL.js";
|
|
174
|
+
import "./chunk-PZF67XDY.js";
|
|
174
175
|
import {
|
|
175
176
|
shutdownExpertBridge
|
|
176
|
-
} from "./chunk-
|
|
177
|
+
} from "./chunk-4G5W5EPU.js";
|
|
177
178
|
import {
|
|
178
179
|
ConsensusVoteInputSchema,
|
|
179
180
|
DEFAULT_VOTE_TIMEOUT_MS,
|
|
@@ -183,25 +184,25 @@ import {
|
|
|
183
184
|
executeVoting,
|
|
184
185
|
mapOutcomeToDecision,
|
|
185
186
|
registerConsensusVoteTool
|
|
186
|
-
} from "./chunk-
|
|
187
|
+
} from "./chunk-F6HJJG3E.js";
|
|
187
188
|
import {
|
|
188
189
|
loadUsageEvents,
|
|
189
190
|
rollupByModel
|
|
190
|
-
} from "./chunk-
|
|
191
|
+
} from "./chunk-TB26XNJH.js";
|
|
191
192
|
import {
|
|
192
193
|
synthesizeResearch
|
|
193
|
-
} from "./chunk-
|
|
194
|
+
} from "./chunk-7S43YASS.js";
|
|
194
195
|
import {
|
|
195
196
|
classifyTrust,
|
|
196
197
|
createFullGitHubProvider,
|
|
197
198
|
evaluatePolicy,
|
|
198
199
|
parsePRUrl
|
|
199
|
-
} from "./chunk-
|
|
200
|
-
import "./chunk-
|
|
200
|
+
} from "./chunk-R46SBPLH.js";
|
|
201
|
+
import "./chunk-RO23OT47.js";
|
|
201
202
|
import {
|
|
202
203
|
ReputationCache,
|
|
203
204
|
sanitizeInput
|
|
204
|
-
} from "./chunk-
|
|
205
|
+
} from "./chunk-SX4E2W3Z.js";
|
|
205
206
|
import {
|
|
206
207
|
ImprovementReviewInputSchema,
|
|
207
208
|
calculateFitnessScore,
|
|
@@ -215,13 +216,15 @@ import {
|
|
|
215
216
|
registerImprovementReviewTool,
|
|
216
217
|
runImprovementReview,
|
|
217
218
|
scanForSecrets
|
|
218
|
-
} from "./chunk-
|
|
219
|
+
} from "./chunk-EQRN5FRZ.js";
|
|
219
220
|
import {
|
|
220
221
|
createDefaultPolicyFirewall
|
|
221
|
-
} from "./chunk-
|
|
222
|
-
import "./chunk-
|
|
222
|
+
} from "./chunk-IQC2K3KY.js";
|
|
223
|
+
import "./chunk-BWG54OJS.js";
|
|
223
224
|
import {
|
|
225
|
+
CodebaseIndexSchema,
|
|
224
226
|
PaperStatusSchema,
|
|
227
|
+
buildIndex,
|
|
225
228
|
createResearchIssue,
|
|
226
229
|
discoverDeepMind,
|
|
227
230
|
discoverGitHubRepos,
|
|
@@ -231,6 +234,7 @@ import {
|
|
|
231
234
|
discoverOpenAlex,
|
|
232
235
|
discoverPapersWithCode,
|
|
233
236
|
discoverSemanticScholar,
|
|
237
|
+
extractProject,
|
|
234
238
|
findOverlaps,
|
|
235
239
|
formatOverlapResult,
|
|
236
240
|
formatResearchIssueBody,
|
|
@@ -242,32 +246,31 @@ import {
|
|
|
242
246
|
loadSourcesRegistry,
|
|
243
247
|
rankDiscoveredItems,
|
|
244
248
|
saveSourcesRegistry
|
|
245
|
-
} from "./chunk-
|
|
249
|
+
} from "./chunk-XGNB7LQB.js";
|
|
246
250
|
import {
|
|
247
251
|
resolveToken
|
|
248
|
-
} from "./chunk-
|
|
252
|
+
} from "./chunk-3JH3FMEJ.js";
|
|
249
253
|
import {
|
|
250
254
|
loadPapersRegistry,
|
|
251
255
|
loadTechniquesRegistry,
|
|
252
256
|
savePapersRegistry
|
|
253
|
-
} from "./chunk-
|
|
257
|
+
} from "./chunk-HAVBBSYN.js";
|
|
254
258
|
import "./chunk-NUBSJGQZ.js";
|
|
255
259
|
import {
|
|
256
260
|
MemoryError,
|
|
257
261
|
shutdownToolMemory
|
|
258
|
-
} from "./chunk-
|
|
262
|
+
} from "./chunk-Q3UMNYV2.js";
|
|
259
263
|
import {
|
|
260
264
|
capitalize,
|
|
261
|
-
capitalizeKebab
|
|
262
|
-
truncateSentence
|
|
265
|
+
capitalizeKebab
|
|
263
266
|
} from "./chunk-6T3EPABN.js";
|
|
264
|
-
import "./chunk-
|
|
267
|
+
import "./chunk-W76DOL27.js";
|
|
265
268
|
import "./chunk-ZM4O442V.js";
|
|
266
269
|
import "./chunk-PINS44XA.js";
|
|
267
270
|
import "./chunk-KSQSWEFH.js";
|
|
268
271
|
import {
|
|
269
272
|
createUnifiedRegistry
|
|
270
|
-
} from "./chunk-
|
|
273
|
+
} from "./chunk-P7MYTCE6.js";
|
|
271
274
|
import {
|
|
272
275
|
NEXUS_SUBPROCESS_DEPTH_ENV,
|
|
273
276
|
createAllAdapters,
|
|
@@ -275,15 +278,15 @@ import {
|
|
|
275
278
|
isRecord,
|
|
276
279
|
probeAllClis,
|
|
277
280
|
readSubprocessDepth
|
|
278
|
-
} from "./chunk-
|
|
279
|
-
import "./chunk-
|
|
281
|
+
} from "./chunk-NT3KCLT6.js";
|
|
282
|
+
import "./chunk-MCT7JJF6.js";
|
|
280
283
|
import {
|
|
281
284
|
DEFAULTS
|
|
282
|
-
} from "./chunk-
|
|
283
|
-
import "./chunk-
|
|
284
|
-
import "./chunk-
|
|
285
|
+
} from "./chunk-JCJHQSAY.js";
|
|
286
|
+
import "./chunk-DSMSYENI.js";
|
|
287
|
+
import "./chunk-T3VD32JY.js";
|
|
285
288
|
import "./chunk-QZUG667L.js";
|
|
286
|
-
import "./chunk-
|
|
289
|
+
import "./chunk-OOFPDA3B.js";
|
|
287
290
|
import {
|
|
288
291
|
API_TIMEOUTS,
|
|
289
292
|
AgentCapability,
|
|
@@ -357,7 +360,7 @@ import {
|
|
|
357
360
|
validateTimeout,
|
|
358
361
|
writeEmptyLine,
|
|
359
362
|
writeLine
|
|
360
|
-
} from "./chunk-
|
|
363
|
+
} from "./chunk-QXSR5KPG.js";
|
|
361
364
|
import "./chunk-AXTD4TFK.js";
|
|
362
365
|
import {
|
|
363
366
|
applyPortableMode,
|
|
@@ -645,8 +648,8 @@ function resolveOutputPath(output2) {
|
|
|
645
648
|
}
|
|
646
649
|
return resolve(process.cwd(), DEFAULT_CONFIG_REL_PATH);
|
|
647
650
|
}
|
|
648
|
-
function fileExists(
|
|
649
|
-
return existsSync(
|
|
651
|
+
function fileExists(path18) {
|
|
652
|
+
return existsSync(path18);
|
|
650
653
|
}
|
|
651
654
|
async function ensureDirectory(filePath) {
|
|
652
655
|
const dir = dirname(filePath);
|
|
@@ -654,9 +657,9 @@ async function ensureDirectory(filePath) {
|
|
|
654
657
|
await mkdir(dir, { recursive: true });
|
|
655
658
|
}
|
|
656
659
|
}
|
|
657
|
-
async function writeConfigFile(
|
|
658
|
-
await ensureDirectory(
|
|
659
|
-
await writeFile(
|
|
660
|
+
async function writeConfigFile(path18) {
|
|
661
|
+
await ensureDirectory(path18);
|
|
662
|
+
await writeFile(path18, renderConfigTemplate() + CONFIG_TEMPLATE_TAIL, "utf-8");
|
|
660
663
|
}
|
|
661
664
|
async function runConfigInit(options = {}) {
|
|
662
665
|
const outputPath = resolveOutputPath(options.output);
|
|
@@ -1636,14 +1639,14 @@ ${colors.dim}Session ended.${colors.reset}
|
|
|
1636
1639
|
});
|
|
1637
1640
|
});
|
|
1638
1641
|
rl.prompt();
|
|
1639
|
-
return new Promise((
|
|
1642
|
+
return new Promise((resolve13) => {
|
|
1640
1643
|
rl.on("line", (line) => {
|
|
1641
1644
|
void (async () => {
|
|
1642
1645
|
try {
|
|
1643
1646
|
const shouldExit = await processLine(line, session, logger19);
|
|
1644
1647
|
if (shouldExit) {
|
|
1645
1648
|
rl.close();
|
|
1646
|
-
|
|
1649
|
+
resolve13();
|
|
1647
1650
|
return;
|
|
1648
1651
|
}
|
|
1649
1652
|
} catch (error) {
|
|
@@ -1655,7 +1658,7 @@ ${colors.dim}Session ended.${colors.reset}
|
|
|
1655
1658
|
})();
|
|
1656
1659
|
});
|
|
1657
1660
|
rl.on("close", () => {
|
|
1658
|
-
|
|
1661
|
+
resolve13();
|
|
1659
1662
|
});
|
|
1660
1663
|
});
|
|
1661
1664
|
}
|
|
@@ -2701,9 +2704,9 @@ async function evaluateDirectory(target, timeoutMs, store = getOutcomeStore()) {
|
|
|
2701
2704
|
}
|
|
2702
2705
|
const aggregator = createAggregator();
|
|
2703
2706
|
const results = [];
|
|
2704
|
-
for (const [
|
|
2707
|
+
for (const [path18, evaluations] of evaluationsByComponent) {
|
|
2705
2708
|
if (evaluations.length > 0) {
|
|
2706
|
-
results.push(aggregator.aggregate(
|
|
2709
|
+
results.push(aggregator.aggregate(path18, evaluations));
|
|
2707
2710
|
}
|
|
2708
2711
|
}
|
|
2709
2712
|
const priority = { deprecate: 0, refactor: 1, review: 2, retain: 3 };
|
|
@@ -4035,7 +4038,7 @@ ${file.patch}
|
|
|
4035
4038
|
violations: policyResult.violations
|
|
4036
4039
|
});
|
|
4037
4040
|
}
|
|
4038
|
-
const { formatReviewComment: formatReviewComment2 } = await import("./pr-reviewer-helpers-
|
|
4041
|
+
const { formatReviewComment: formatReviewComment2 } = await import("./pr-reviewer-helpers-TKXJBDT6.js");
|
|
4039
4042
|
const body = formatReviewComment2(result);
|
|
4040
4043
|
const postResult = await provider.createReview(pr.prNumber, body, result.decision);
|
|
4041
4044
|
if (!postResult.ok) {
|
|
@@ -5081,27 +5084,27 @@ var CliAdapterAgent = class {
|
|
|
5081
5084
|
};
|
|
5082
5085
|
|
|
5083
5086
|
// src/cli/orchestrate-puppeteer.ts
|
|
5084
|
-
function loadPolicyParameters(
|
|
5087
|
+
function loadPolicyParameters(path18, logger19) {
|
|
5085
5088
|
try {
|
|
5086
|
-
if (fs2.existsSync(
|
|
5087
|
-
const content = fs2.readFileSync(
|
|
5089
|
+
if (fs2.existsSync(path18)) {
|
|
5090
|
+
const content = fs2.readFileSync(path18, "utf-8");
|
|
5088
5091
|
const params = JSON.parse(content);
|
|
5089
|
-
logger19.info("Loaded policy parameters", { path:
|
|
5092
|
+
logger19.info("Loaded policy parameters", { path: path18 });
|
|
5090
5093
|
return params;
|
|
5091
5094
|
}
|
|
5092
5095
|
} catch (error) {
|
|
5093
5096
|
const message = getErrorMessage(error);
|
|
5094
|
-
logger19.warn("Failed to load policy parameters", { path:
|
|
5097
|
+
logger19.warn("Failed to load policy parameters", { path: path18, error: message });
|
|
5095
5098
|
}
|
|
5096
5099
|
return void 0;
|
|
5097
5100
|
}
|
|
5098
|
-
function savePolicyParameters(
|
|
5101
|
+
function savePolicyParameters(path18, params, logger19) {
|
|
5099
5102
|
try {
|
|
5100
|
-
fs2.writeFileSync(
|
|
5101
|
-
logger19.info("Saved policy parameters", { path:
|
|
5103
|
+
fs2.writeFileSync(path18, JSON.stringify(params, null, 2));
|
|
5104
|
+
logger19.info("Saved policy parameters", { path: path18 });
|
|
5102
5105
|
} catch (error) {
|
|
5103
5106
|
const message = getErrorMessage(error);
|
|
5104
|
-
logger19.warn("Failed to save policy parameters", { path:
|
|
5107
|
+
logger19.warn("Failed to save policy parameters", { path: path18, error: message });
|
|
5105
5108
|
}
|
|
5106
5109
|
}
|
|
5107
5110
|
function createAgentsFromAdapters(adapters) {
|
|
@@ -9800,515 +9803,12 @@ async function researchCommand(subcommand, args, options) {
|
|
|
9800
9803
|
|
|
9801
9804
|
// src/cli/index-command.ts
|
|
9802
9805
|
import * as fs13 from "fs/promises";
|
|
9803
|
-
import * as
|
|
9806
|
+
import * as path14 from "path";
|
|
9804
9807
|
import * as yaml6 from "yaml";
|
|
9805
9808
|
|
|
9806
|
-
// src/indexer/types.ts
|
|
9807
|
-
import { z as z4 } from "zod";
|
|
9808
|
-
var SCHEMA_VERSION = "1.0";
|
|
9809
|
-
var ExportEntrySchema = z4.object({
|
|
9810
|
-
name: z4.string(),
|
|
9811
|
-
kind: z4.enum(["type", "interface", "class", "function", "const", "enum", "unknown"]),
|
|
9812
|
-
isReExport: z4.boolean(),
|
|
9813
|
-
sourceModule: z4.string().optional()
|
|
9814
|
-
});
|
|
9815
|
-
var DependencyEntrySchema = z4.object({
|
|
9816
|
-
specifier: z4.string(),
|
|
9817
|
-
isExternal: z4.boolean(),
|
|
9818
|
-
imports: z4.array(z4.string()).readonly()
|
|
9819
|
-
});
|
|
9820
|
-
var FileEntrySchema = z4.object({
|
|
9821
|
-
path: z4.string(),
|
|
9822
|
-
lines: z4.number().int().nonnegative(),
|
|
9823
|
-
category: z4.enum(["types", "implementation", "test", "config", "cli", "util", "index"]),
|
|
9824
|
-
exports: z4.array(ExportEntrySchema).readonly(),
|
|
9825
|
-
dependencies: z4.array(DependencyEntrySchema).readonly(),
|
|
9826
|
-
description: z4.string().optional()
|
|
9827
|
-
});
|
|
9828
|
-
var ModuleStatsSchema = z4.object({
|
|
9829
|
-
fileCount: z4.number().int().nonnegative(),
|
|
9830
|
-
totalLines: z4.number().int().nonnegative(),
|
|
9831
|
-
exportCount: z4.number().int().nonnegative(),
|
|
9832
|
-
internalDeps: z4.number().int().nonnegative(),
|
|
9833
|
-
externalDeps: z4.number().int().nonnegative()
|
|
9834
|
-
});
|
|
9835
|
-
var ModuleEntrySchema = z4.object({
|
|
9836
|
-
name: z4.string(),
|
|
9837
|
-
path: z4.string(),
|
|
9838
|
-
purpose: z4.string(),
|
|
9839
|
-
files: z4.array(FileEntrySchema).readonly(),
|
|
9840
|
-
stats: ModuleStatsSchema,
|
|
9841
|
-
dependsOn: z4.array(z4.string()).readonly()
|
|
9842
|
-
});
|
|
9843
|
-
var IndexStatsSchema = z4.object({
|
|
9844
|
-
totalFiles: z4.number().int().nonnegative(),
|
|
9845
|
-
totalLines: z4.number().int().nonnegative(),
|
|
9846
|
-
totalExports: z4.number().int().nonnegative(),
|
|
9847
|
-
moduleCount: z4.number().int().nonnegative(),
|
|
9848
|
-
externalPackages: z4.array(z4.string()).readonly()
|
|
9849
|
-
});
|
|
9850
|
-
var CodebaseIndexSchema = z4.object({
|
|
9851
|
-
schemaVersion: z4.literal(SCHEMA_VERSION),
|
|
9852
|
-
generatedAt: z4.string(),
|
|
9853
|
-
stats: IndexStatsSchema,
|
|
9854
|
-
modules: z4.record(z4.string(), ModuleEntrySchema)
|
|
9855
|
-
});
|
|
9856
|
-
var DEFAULT_EXTRACTOR_OPTIONS = {
|
|
9857
|
-
rootDir: "src",
|
|
9858
|
-
include: ["**/*.ts"],
|
|
9859
|
-
exclude: ["**/*.test.ts", "**/*.d.ts", "**/node_modules/**"],
|
|
9860
|
-
extractDescriptions: true
|
|
9861
|
-
};
|
|
9862
|
-
|
|
9863
|
-
// src/indexer/category-detection.ts
|
|
9864
|
-
import * as path8 from "path";
|
|
9865
|
-
var FILE_SUFFIX_PATTERNS = [
|
|
9866
|
-
[".test.ts", "test"],
|
|
9867
|
-
[".spec.ts", "test"],
|
|
9868
|
-
["-types.ts", "types"],
|
|
9869
|
-
[".types.ts", "types"],
|
|
9870
|
-
["-command.ts", "cli"]
|
|
9871
|
-
];
|
|
9872
|
-
var FILE_PATH_PATTERNS = [
|
|
9873
|
-
{ test: (f) => f === "index.ts", category: "index" },
|
|
9874
|
-
{ test: (_, d) => d.includes("/cli"), category: "cli" },
|
|
9875
|
-
{ test: (f, d) => d.includes("config") || f.includes("config"), category: "config" },
|
|
9876
|
-
{ test: (f) => f.includes("helper") || f.includes("util"), category: "util" }
|
|
9877
|
-
];
|
|
9878
|
-
function detectCategoryFromPath(fileName, dirName) {
|
|
9879
|
-
for (const [suffix, category] of FILE_SUFFIX_PATTERNS) {
|
|
9880
|
-
if (fileName.endsWith(suffix)) return category;
|
|
9881
|
-
}
|
|
9882
|
-
for (const { test, category } of FILE_PATH_PATTERNS) {
|
|
9883
|
-
if (test(fileName, dirName)) return category;
|
|
9884
|
-
}
|
|
9885
|
-
return void 0;
|
|
9886
|
-
}
|
|
9887
|
-
function isTypesOnlyFile(sourceFile) {
|
|
9888
|
-
const typeCount = sourceFile.getTypeAliases().length + sourceFile.getInterfaces().length;
|
|
9889
|
-
const implCount = sourceFile.getFunctions().length + sourceFile.getClasses().length + sourceFile.getVariableDeclarations().length;
|
|
9890
|
-
return typeCount > 0 && implCount === 0;
|
|
9891
|
-
}
|
|
9892
|
-
function detectFileCategory(filePath, sourceFile) {
|
|
9893
|
-
const pathCategory = detectCategoryFromPath(path8.basename(filePath), path8.dirname(filePath));
|
|
9894
|
-
if (pathCategory !== void 0) return pathCategory;
|
|
9895
|
-
if (isTypesOnlyFile(sourceFile)) return "types";
|
|
9896
|
-
return "implementation";
|
|
9897
|
-
}
|
|
9898
|
-
|
|
9899
|
-
// src/indexer/export-extraction.ts
|
|
9900
|
-
function addExport(state, name, kind, reExportInfo) {
|
|
9901
|
-
if (state.seenNames.has(name)) return;
|
|
9902
|
-
state.seenNames.add(name);
|
|
9903
|
-
const entry = { name, kind, isReExport: reExportInfo !== void 0 };
|
|
9904
|
-
if (reExportInfo !== void 0)
|
|
9905
|
-
entry.sourceModule = reExportInfo.sourceModule;
|
|
9906
|
-
state.exports.push(entry);
|
|
9907
|
-
}
|
|
9908
|
-
function extractFunctionClassExports(sourceFile, state) {
|
|
9909
|
-
for (const fn of sourceFile.getFunctions()) {
|
|
9910
|
-
if (fn.isExported()) {
|
|
9911
|
-
const name = fn.getName();
|
|
9912
|
-
if (name !== void 0) addExport(state, name, "function");
|
|
9913
|
-
}
|
|
9914
|
-
}
|
|
9915
|
-
for (const cls of sourceFile.getClasses()) {
|
|
9916
|
-
if (cls.isExported()) {
|
|
9917
|
-
const name = cls.getName();
|
|
9918
|
-
if (name !== void 0) addExport(state, name, "class");
|
|
9919
|
-
}
|
|
9920
|
-
}
|
|
9921
|
-
}
|
|
9922
|
-
function extractTypeExports(sourceFile, state) {
|
|
9923
|
-
for (const iface of sourceFile.getInterfaces()) {
|
|
9924
|
-
if (iface.isExported()) addExport(state, iface.getName(), "interface");
|
|
9925
|
-
}
|
|
9926
|
-
for (const typeAlias of sourceFile.getTypeAliases()) {
|
|
9927
|
-
if (typeAlias.isExported()) addExport(state, typeAlias.getName(), "type");
|
|
9928
|
-
}
|
|
9929
|
-
for (const enumDecl of sourceFile.getEnums()) {
|
|
9930
|
-
if (enumDecl.isExported()) addExport(state, enumDecl.getName(), "enum");
|
|
9931
|
-
}
|
|
9932
|
-
}
|
|
9933
|
-
function extractVariableExports(sourceFile, state) {
|
|
9934
|
-
for (const varStmt of sourceFile.getVariableStatements()) {
|
|
9935
|
-
if (varStmt.isExported()) {
|
|
9936
|
-
for (const decl of varStmt.getDeclarations()) addExport(state, decl.getName(), "const");
|
|
9937
|
-
}
|
|
9938
|
-
}
|
|
9939
|
-
}
|
|
9940
|
-
function extractReExports(sourceFile, state) {
|
|
9941
|
-
for (const exportDecl of sourceFile.getExportDeclarations()) {
|
|
9942
|
-
const moduleSpecifier = exportDecl.getModuleSpecifierValue();
|
|
9943
|
-
const namedExports = exportDecl.getNamedExports();
|
|
9944
|
-
const reExportInfo = moduleSpecifier !== void 0 ? { sourceModule: moduleSpecifier } : void 0;
|
|
9945
|
-
for (const namedExport of namedExports) {
|
|
9946
|
-
const name = namedExport.getAliasNode()?.getText() ?? namedExport.getName();
|
|
9947
|
-
addExport(state, name, "unknown", reExportInfo);
|
|
9948
|
-
}
|
|
9949
|
-
if (namedExports.length === 0 && reExportInfo !== void 0) {
|
|
9950
|
-
addExport(state, "*", "unknown", reExportInfo);
|
|
9951
|
-
}
|
|
9952
|
-
}
|
|
9953
|
-
}
|
|
9954
|
-
function extractExports(sourceFile) {
|
|
9955
|
-
const state = { exports: [], seenNames: /* @__PURE__ */ new Set() };
|
|
9956
|
-
extractFunctionClassExports(sourceFile, state);
|
|
9957
|
-
extractTypeExports(sourceFile, state);
|
|
9958
|
-
extractVariableExports(sourceFile, state);
|
|
9959
|
-
extractReExports(sourceFile, state);
|
|
9960
|
-
return state.exports;
|
|
9961
|
-
}
|
|
9962
|
-
|
|
9963
|
-
// src/indexer/dependency-extraction.ts
|
|
9964
|
-
function isExternalImport(specifier) {
|
|
9965
|
-
if (specifier.startsWith(".") || specifier.startsWith("/")) {
|
|
9966
|
-
return false;
|
|
9967
|
-
}
|
|
9968
|
-
if (specifier.startsWith("node:")) {
|
|
9969
|
-
return true;
|
|
9970
|
-
}
|
|
9971
|
-
return true;
|
|
9972
|
-
}
|
|
9973
|
-
function extractDependencies(sourceFile) {
|
|
9974
|
-
const deps = [];
|
|
9975
|
-
const seenSpecifiers = /* @__PURE__ */ new Set();
|
|
9976
|
-
for (const importDecl of sourceFile.getImportDeclarations()) {
|
|
9977
|
-
const specifier = importDecl.getModuleSpecifierValue();
|
|
9978
|
-
if (seenSpecifiers.has(specifier)) continue;
|
|
9979
|
-
seenSpecifiers.add(specifier);
|
|
9980
|
-
const imports = [];
|
|
9981
|
-
const namedImports = importDecl.getNamedImports();
|
|
9982
|
-
for (const namedImport of namedImports) {
|
|
9983
|
-
imports.push(namedImport.getName());
|
|
9984
|
-
}
|
|
9985
|
-
const defaultImport = importDecl.getDefaultImport();
|
|
9986
|
-
if (defaultImport !== void 0) {
|
|
9987
|
-
imports.push(defaultImport.getText());
|
|
9988
|
-
}
|
|
9989
|
-
const namespaceImport = importDecl.getNamespaceImport();
|
|
9990
|
-
if (namespaceImport !== void 0) {
|
|
9991
|
-
imports.push(`* as ${namespaceImport.getText()}`);
|
|
9992
|
-
}
|
|
9993
|
-
deps.push({
|
|
9994
|
-
specifier,
|
|
9995
|
-
isExternal: isExternalImport(specifier),
|
|
9996
|
-
imports
|
|
9997
|
-
});
|
|
9998
|
-
}
|
|
9999
|
-
return deps;
|
|
10000
|
-
}
|
|
10001
|
-
|
|
10002
|
-
// src/indexer/description-extraction.ts
|
|
10003
|
-
function isPlainBlockComment(trimmed) {
|
|
10004
|
-
return trimmed.startsWith("/*") && trimmed.endsWith("*/");
|
|
10005
|
-
}
|
|
10006
|
-
function classifyOutsideComment(trimmed) {
|
|
10007
|
-
if (isPlainBlockComment(trimmed)) return "skip";
|
|
10008
|
-
if (trimmed.length > 0 && !trimmed.startsWith("//")) return "stop";
|
|
10009
|
-
return "skip";
|
|
10010
|
-
}
|
|
10011
|
-
function classifyInsideComment(trimmed) {
|
|
10012
|
-
if (trimmed.endsWith("*/")) return "end";
|
|
10013
|
-
if (trimmed.startsWith("* @") || trimmed.startsWith("@")) return "skip";
|
|
10014
|
-
return "content";
|
|
10015
|
-
}
|
|
10016
|
-
function classifyJsDocLine(trimmed, inComment) {
|
|
10017
|
-
if (trimmed.startsWith("/**")) {
|
|
10018
|
-
return trimmed.endsWith("*/") ? "startEnd" : "start";
|
|
10019
|
-
}
|
|
10020
|
-
return inComment ? classifyInsideComment(trimmed) : classifyOutsideComment(trimmed);
|
|
10021
|
-
}
|
|
10022
|
-
function extractJsDocLineContent(trimmed) {
|
|
10023
|
-
return trimmed.startsWith("*") ? trimmed.slice(1).trim() : trimmed;
|
|
10024
|
-
}
|
|
10025
|
-
function extractInlineJsDocContent(trimmed) {
|
|
10026
|
-
return trimmed.slice(3, -2).trim();
|
|
10027
|
-
}
|
|
10028
|
-
function truncateDescription(full) {
|
|
10029
|
-
return truncateSentence(full, 150);
|
|
10030
|
-
}
|
|
10031
|
-
function extractDescription(sourceFile) {
|
|
10032
|
-
const lines = sourceFile.getFullText().split("\n");
|
|
10033
|
-
let inComment = false;
|
|
10034
|
-
const description = [];
|
|
10035
|
-
for (const line of lines) {
|
|
10036
|
-
const trimmed = line.trim();
|
|
10037
|
-
const result = classifyJsDocLine(trimmed, inComment);
|
|
10038
|
-
if (result === "start") {
|
|
10039
|
-
inComment = true;
|
|
10040
|
-
continue;
|
|
10041
|
-
}
|
|
10042
|
-
if (result === "startEnd") {
|
|
10043
|
-
const inline = extractInlineJsDocContent(trimmed);
|
|
10044
|
-
if (inline.length > 0) description.push(inline);
|
|
10045
|
-
break;
|
|
10046
|
-
}
|
|
10047
|
-
if (result === "end" || result === "stop") break;
|
|
10048
|
-
if (result === "skip") continue;
|
|
10049
|
-
const content = extractJsDocLineContent(trimmed);
|
|
10050
|
-
if (content.length > 0) description.push(content);
|
|
10051
|
-
}
|
|
10052
|
-
if (description.length === 0) return void 0;
|
|
10053
|
-
return truncateDescription(description.join(" "));
|
|
10054
|
-
}
|
|
10055
|
-
|
|
10056
|
-
// src/indexer/project-extraction.ts
|
|
10057
|
-
import { Project } from "ts-morph";
|
|
10058
|
-
import * as path9 from "path";
|
|
10059
|
-
function extractFileEntry(sourceFile, rootDir, extractDescriptions) {
|
|
10060
|
-
const absolutePath = sourceFile.getFilePath();
|
|
10061
|
-
const relativePath = path9.relative(rootDir, absolutePath);
|
|
10062
|
-
const lineCount = sourceFile.getEndLineNumber();
|
|
10063
|
-
const entry = {
|
|
10064
|
-
path: relativePath,
|
|
10065
|
-
lines: lineCount,
|
|
10066
|
-
category: detectFileCategory(relativePath, sourceFile),
|
|
10067
|
-
exports: extractExports(sourceFile),
|
|
10068
|
-
dependencies: extractDependencies(sourceFile)
|
|
10069
|
-
};
|
|
10070
|
-
if (extractDescriptions) {
|
|
10071
|
-
const desc = extractDescription(sourceFile);
|
|
10072
|
-
if (desc !== void 0) {
|
|
10073
|
-
entry.description = desc;
|
|
10074
|
-
}
|
|
10075
|
-
}
|
|
10076
|
-
return entry;
|
|
10077
|
-
}
|
|
10078
|
-
function processSourceFiles(project, rootDir, extractDescriptions) {
|
|
10079
|
-
const files = [];
|
|
10080
|
-
const errors = [];
|
|
10081
|
-
for (const sourceFile of project.getSourceFiles()) {
|
|
10082
|
-
const filePath = sourceFile.getFilePath();
|
|
10083
|
-
try {
|
|
10084
|
-
files.push(extractFileEntry(sourceFile, rootDir, extractDescriptions));
|
|
10085
|
-
} catch (err2) {
|
|
10086
|
-
const message = err2 instanceof Error ? err2.message : String(err2);
|
|
10087
|
-
errors.push(`Error extracting ${filePath}: ${message}`);
|
|
10088
|
-
}
|
|
10089
|
-
}
|
|
10090
|
-
return { files, errors };
|
|
10091
|
-
}
|
|
10092
|
-
function extractProject(options = {}) {
|
|
10093
|
-
const opts = { ...DEFAULT_EXTRACTOR_OPTIONS, ...options };
|
|
10094
|
-
const startTime = getTimeProvider().now();
|
|
10095
|
-
const project = new Project({
|
|
10096
|
-
skipAddingFilesFromTsConfig: true,
|
|
10097
|
-
skipFileDependencyResolution: true
|
|
10098
|
-
});
|
|
10099
|
-
const rootDir = path9.resolve(process.cwd(), opts.rootDir);
|
|
10100
|
-
const includePatterns = opts.include.map((p) => path9.join(rootDir, p));
|
|
10101
|
-
const excludePatterns = opts.exclude.map((p) => `!${path9.join(rootDir, p)}`);
|
|
10102
|
-
try {
|
|
10103
|
-
project.addSourceFilesAtPaths([...includePatterns, ...excludePatterns]);
|
|
10104
|
-
const { files, errors } = processSourceFiles(project, rootDir, opts.extractDescriptions);
|
|
10105
|
-
return { files, errors, durationMs: getTimeProvider().now() - startTime };
|
|
10106
|
-
} catch (err2) {
|
|
10107
|
-
const message = err2 instanceof Error ? err2.message : String(err2);
|
|
10108
|
-
return {
|
|
10109
|
-
files: [],
|
|
10110
|
-
errors: [`Error loading project: ${message}`],
|
|
10111
|
-
durationMs: getTimeProvider().now() - startTime
|
|
10112
|
-
};
|
|
10113
|
-
}
|
|
10114
|
-
}
|
|
10115
|
-
|
|
10116
|
-
// src/indexer/analyzer.ts
|
|
10117
|
-
import * as path10 from "path";
|
|
10118
|
-
var MODULE_PURPOSES = {
|
|
10119
|
-
core: "Types, Result<T,E>, errors, logger",
|
|
10120
|
-
config: "Configuration loading, validation, Zod schemas",
|
|
10121
|
-
adapters: "Model adapters (Claude, OpenAI, Gemini, Ollama)",
|
|
10122
|
-
agents: "Agent framework, Orchestrator, Experts, collaboration",
|
|
10123
|
-
workflows: "Workflow engine, templates, execution",
|
|
10124
|
-
mcp: "MCP server, tool definitions",
|
|
10125
|
-
cli: "CLI interface, mode detection, commands",
|
|
10126
|
-
"cli-adapters": "External CLI integrations (Claude, Gemini, Codex)",
|
|
10127
|
-
context: "Context management, token counting, memory",
|
|
10128
|
-
consensus: "Multi-agent consensus, voting strategies",
|
|
10129
|
-
learning: "Feedback collection, outcome tracking",
|
|
10130
|
-
indexer: "Codebase indexing and documentation",
|
|
10131
|
-
security: "Sandbox execution, secrets management"
|
|
10132
|
-
};
|
|
10133
|
-
function detectModulePurpose(moduleName, files) {
|
|
10134
|
-
const known = MODULE_PURPOSES[moduleName];
|
|
10135
|
-
if (known !== void 0) {
|
|
10136
|
-
return known;
|
|
10137
|
-
}
|
|
10138
|
-
const descriptions = files.filter((f) => f.description !== void 0).map((f) => f.description).slice(0, 3);
|
|
10139
|
-
if (descriptions.length > 0) {
|
|
10140
|
-
return descriptions.join("; ");
|
|
10141
|
-
}
|
|
10142
|
-
return `${moduleName} module`;
|
|
10143
|
-
}
|
|
10144
|
-
function extractPackageName(specifier) {
|
|
10145
|
-
if (specifier.startsWith("@")) {
|
|
10146
|
-
const parts2 = specifier.split("/");
|
|
10147
|
-
const scope = parts2[0];
|
|
10148
|
-
const name = parts2[1];
|
|
10149
|
-
if (scope !== void 0 && name !== void 0) {
|
|
10150
|
-
return `${scope}/${name}`;
|
|
10151
|
-
}
|
|
10152
|
-
return void 0;
|
|
10153
|
-
}
|
|
10154
|
-
if (specifier.startsWith("node:")) {
|
|
10155
|
-
return specifier;
|
|
10156
|
-
}
|
|
10157
|
-
const parts = specifier.split("/");
|
|
10158
|
-
return parts[0];
|
|
10159
|
-
}
|
|
10160
|
-
function groupFilesByModule(files) {
|
|
10161
|
-
const modules = /* @__PURE__ */ new Map();
|
|
10162
|
-
for (const file of files) {
|
|
10163
|
-
const parts = file.path.split("/");
|
|
10164
|
-
const moduleName = parts.length > 1 ? parts[0] ?? "root" : "root";
|
|
10165
|
-
const existing = modules.get(moduleName);
|
|
10166
|
-
if (existing !== void 0) {
|
|
10167
|
-
existing.push(file);
|
|
10168
|
-
} else {
|
|
10169
|
-
modules.set(moduleName, [file]);
|
|
10170
|
-
}
|
|
10171
|
-
}
|
|
10172
|
-
return modules;
|
|
10173
|
-
}
|
|
10174
|
-
function collectExternalPackages(file, packages) {
|
|
10175
|
-
for (const dep of file.dependencies) {
|
|
10176
|
-
if (dep.isExternal) {
|
|
10177
|
-
const pkgName = extractPackageName(dep.specifier);
|
|
10178
|
-
if (pkgName !== void 0) {
|
|
10179
|
-
packages.add(pkgName);
|
|
10180
|
-
}
|
|
10181
|
-
}
|
|
10182
|
-
}
|
|
10183
|
-
}
|
|
10184
|
-
function computeModuleStats(files) {
|
|
10185
|
-
let totalLines = 0;
|
|
10186
|
-
let exportCount = 0;
|
|
10187
|
-
let internalDeps = 0;
|
|
10188
|
-
let externalDeps = 0;
|
|
10189
|
-
for (const file of files) {
|
|
10190
|
-
totalLines += file.lines;
|
|
10191
|
-
exportCount += file.exports.length;
|
|
10192
|
-
for (const dep of file.dependencies) {
|
|
10193
|
-
if (dep.isExternal) {
|
|
10194
|
-
externalDeps++;
|
|
10195
|
-
} else {
|
|
10196
|
-
internalDeps++;
|
|
10197
|
-
}
|
|
10198
|
-
}
|
|
10199
|
-
}
|
|
10200
|
-
return {
|
|
10201
|
-
fileCount: files.length,
|
|
10202
|
-
totalLines,
|
|
10203
|
-
exportCount,
|
|
10204
|
-
internalDeps,
|
|
10205
|
-
externalDeps
|
|
10206
|
-
};
|
|
10207
|
-
}
|
|
10208
|
-
function resolveTargetModule(filePath, specifier) {
|
|
10209
|
-
if (!specifier.startsWith(".")) return void 0;
|
|
10210
|
-
const resolved = path10.join(path10.dirname(filePath), specifier);
|
|
10211
|
-
const parts = resolved.split("/");
|
|
10212
|
-
return parts[0];
|
|
10213
|
-
}
|
|
10214
|
-
function isValidModuleDep(targetModule, moduleName, allModules) {
|
|
10215
|
-
return targetModule !== void 0 && targetModule !== moduleName && allModules.has(targetModule);
|
|
10216
|
-
}
|
|
10217
|
-
function detectModuleDependencies(moduleName, files, allModules) {
|
|
10218
|
-
const deps = /* @__PURE__ */ new Set();
|
|
10219
|
-
for (const file of files) {
|
|
10220
|
-
for (const dep of file.dependencies) {
|
|
10221
|
-
if (dep.isExternal) continue;
|
|
10222
|
-
const targetModule = resolveTargetModule(file.path, dep.specifier);
|
|
10223
|
-
if (isValidModuleDep(targetModule, moduleName, allModules)) {
|
|
10224
|
-
deps.add(targetModule);
|
|
10225
|
-
}
|
|
10226
|
-
}
|
|
10227
|
-
}
|
|
10228
|
-
return Array.from(deps).sort();
|
|
10229
|
-
}
|
|
10230
|
-
function analyzeModules(files) {
|
|
10231
|
-
const filesByModule = groupFilesByModule(files);
|
|
10232
|
-
const moduleNames = new Set(filesByModule.keys());
|
|
10233
|
-
const modules = /* @__PURE__ */ new Map();
|
|
10234
|
-
for (const [moduleName, moduleFiles] of filesByModule) {
|
|
10235
|
-
modules.set(moduleName, {
|
|
10236
|
-
name: moduleName,
|
|
10237
|
-
path: moduleName === "root" ? "." : moduleName,
|
|
10238
|
-
purpose: detectModulePurpose(moduleName, moduleFiles),
|
|
10239
|
-
files: moduleFiles,
|
|
10240
|
-
stats: computeModuleStats(moduleFiles),
|
|
10241
|
-
dependsOn: detectModuleDependencies(moduleName, moduleFiles, moduleNames)
|
|
10242
|
-
});
|
|
10243
|
-
}
|
|
10244
|
-
return modules;
|
|
10245
|
-
}
|
|
10246
|
-
function computeIndexStats(modules) {
|
|
10247
|
-
let totalFiles = 0;
|
|
10248
|
-
let totalLines = 0;
|
|
10249
|
-
let totalExports = 0;
|
|
10250
|
-
const externalPackages = /* @__PURE__ */ new Set();
|
|
10251
|
-
for (const module of modules.values()) {
|
|
10252
|
-
totalFiles += module.stats.fileCount;
|
|
10253
|
-
totalLines += module.stats.totalLines;
|
|
10254
|
-
totalExports += module.stats.exportCount;
|
|
10255
|
-
for (const file of module.files) {
|
|
10256
|
-
collectExternalPackages(file, externalPackages);
|
|
10257
|
-
}
|
|
10258
|
-
}
|
|
10259
|
-
return {
|
|
10260
|
-
totalFiles,
|
|
10261
|
-
totalLines,
|
|
10262
|
-
totalExports,
|
|
10263
|
-
moduleCount: modules.size,
|
|
10264
|
-
externalPackages: Array.from(externalPackages).sort()
|
|
10265
|
-
};
|
|
10266
|
-
}
|
|
10267
|
-
function buildIndex(files) {
|
|
10268
|
-
const modules = analyzeModules(files);
|
|
10269
|
-
const stats = computeIndexStats(modules);
|
|
10270
|
-
const now = new Date(getTimeProvider().now());
|
|
10271
|
-
const etFormatter = new Intl.DateTimeFormat("en-US", {
|
|
10272
|
-
timeZone: "America/New_York",
|
|
10273
|
-
year: "numeric",
|
|
10274
|
-
month: "2-digit",
|
|
10275
|
-
day: "2-digit",
|
|
10276
|
-
hour: "2-digit",
|
|
10277
|
-
minute: "2-digit",
|
|
10278
|
-
second: "2-digit",
|
|
10279
|
-
hour12: false
|
|
10280
|
-
});
|
|
10281
|
-
const parts = etFormatter.formatToParts(now);
|
|
10282
|
-
const getPart = (type) => parts.find((p) => p.type === type)?.value ?? "00";
|
|
10283
|
-
const utcFormatter = new Intl.DateTimeFormat("en-US", {
|
|
10284
|
-
timeZone: "UTC",
|
|
10285
|
-
hour: "numeric",
|
|
10286
|
-
hour12: false
|
|
10287
|
-
});
|
|
10288
|
-
const utcHour = Number(
|
|
10289
|
-
utcFormatter.formatToParts(now).find((p) => p.type === "hour")?.value ?? "0"
|
|
10290
|
-
);
|
|
10291
|
-
const etHour = Number(getPart("hour"));
|
|
10292
|
-
const rawDiff = etHour - utcHour;
|
|
10293
|
-
const offsetHours = rawDiff > 12 ? rawDiff - 24 : rawDiff < -12 ? rawDiff + 24 : rawDiff;
|
|
10294
|
-
const offsetSign = offsetHours <= 0 ? "-" : "+";
|
|
10295
|
-
const absOffset = String(Math.abs(offsetHours)).padStart(2, "0");
|
|
10296
|
-
const timestamp = `${getPart("year")}-${getPart("month")}-${getPart("day")}T${getPart("hour")}:${getPart("minute")}:${getPart("second")}${offsetSign}${absOffset}:00`;
|
|
10297
|
-
const modulesRecord = {};
|
|
10298
|
-
for (const [name, entry] of modules) {
|
|
10299
|
-
modulesRecord[name] = entry;
|
|
10300
|
-
}
|
|
10301
|
-
return {
|
|
10302
|
-
schemaVersion: SCHEMA_VERSION,
|
|
10303
|
-
generatedAt: timestamp,
|
|
10304
|
-
stats,
|
|
10305
|
-
modules: modulesRecord
|
|
10306
|
-
};
|
|
10307
|
-
}
|
|
10308
|
-
|
|
10309
9809
|
// src/indexer/generator.ts
|
|
10310
9810
|
import * as fs10 from "fs/promises";
|
|
10311
|
-
import * as
|
|
9811
|
+
import * as path8 from "path";
|
|
10312
9812
|
import * as yaml4 from "yaml";
|
|
10313
9813
|
function indexToYaml(index) {
|
|
10314
9814
|
const doc = new yaml4.Document(index);
|
|
@@ -10438,43 +9938,43 @@ function validateIndex(index, currentFiles) {
|
|
|
10438
9938
|
}
|
|
10439
9939
|
|
|
10440
9940
|
// src/indexer/entrypoint-types.ts
|
|
10441
|
-
import { z as
|
|
9941
|
+
import { z as z4 } from "zod";
|
|
10442
9942
|
var ENTRYPOINT_SCHEMA_VERSION = "1.0";
|
|
10443
|
-
var OptionSpecSchema =
|
|
10444
|
-
name:
|
|
10445
|
-
type:
|
|
10446
|
-
description:
|
|
10447
|
-
required:
|
|
10448
|
-
default:
|
|
10449
|
-
short:
|
|
9943
|
+
var OptionSpecSchema = z4.object({
|
|
9944
|
+
name: z4.string(),
|
|
9945
|
+
type: z4.string(),
|
|
9946
|
+
description: z4.string().optional(),
|
|
9947
|
+
required: z4.boolean().optional(),
|
|
9948
|
+
default: z4.string().optional(),
|
|
9949
|
+
short: z4.string().optional()
|
|
10450
9950
|
});
|
|
10451
|
-
var ParameterSpecSchema =
|
|
10452
|
-
name:
|
|
10453
|
-
type:
|
|
10454
|
-
description:
|
|
10455
|
-
required:
|
|
10456
|
-
default:
|
|
9951
|
+
var ParameterSpecSchema = z4.object({
|
|
9952
|
+
name: z4.string(),
|
|
9953
|
+
type: z4.string(),
|
|
9954
|
+
description: z4.string().optional(),
|
|
9955
|
+
required: z4.boolean().optional(),
|
|
9956
|
+
default: z4.string().optional()
|
|
10457
9957
|
});
|
|
10458
|
-
var CliCommandSpecSchema =
|
|
10459
|
-
name:
|
|
10460
|
-
description:
|
|
10461
|
-
subcommands:
|
|
10462
|
-
options:
|
|
10463
|
-
source_file:
|
|
10464
|
-
source_line:
|
|
9958
|
+
var CliCommandSpecSchema = z4.object({
|
|
9959
|
+
name: z4.string(),
|
|
9960
|
+
description: z4.string(),
|
|
9961
|
+
subcommands: z4.array(z4.string()).readonly().optional(),
|
|
9962
|
+
options: z4.array(OptionSpecSchema).readonly().optional(),
|
|
9963
|
+
source_file: z4.string(),
|
|
9964
|
+
source_line: z4.number().int().positive()
|
|
10465
9965
|
});
|
|
10466
|
-
var McpToolSpecSchema =
|
|
10467
|
-
name:
|
|
10468
|
-
description:
|
|
10469
|
-
parameters:
|
|
10470
|
-
source_file:
|
|
10471
|
-
source_line:
|
|
9966
|
+
var McpToolSpecSchema = z4.object({
|
|
9967
|
+
name: z4.string(),
|
|
9968
|
+
description: z4.string(),
|
|
9969
|
+
parameters: z4.array(ParameterSpecSchema).readonly(),
|
|
9970
|
+
source_file: z4.string(),
|
|
9971
|
+
source_line: z4.number().int().positive()
|
|
10472
9972
|
});
|
|
10473
|
-
var EntrypointManifestSchema =
|
|
10474
|
-
schema_version:
|
|
10475
|
-
generated_at:
|
|
10476
|
-
cli_commands:
|
|
10477
|
-
mcp_tools:
|
|
9973
|
+
var EntrypointManifestSchema = z4.object({
|
|
9974
|
+
schema_version: z4.literal(ENTRYPOINT_SCHEMA_VERSION),
|
|
9975
|
+
generated_at: z4.string(),
|
|
9976
|
+
cli_commands: z4.array(CliCommandSpecSchema).readonly(),
|
|
9977
|
+
mcp_tools: z4.array(McpToolSpecSchema).readonly()
|
|
10478
9978
|
});
|
|
10479
9979
|
var DEFAULT_ENTRYPOINT_EXTRACTOR_OPTIONS = {
|
|
10480
9980
|
packageRoot: "packages/nexus-agents",
|
|
@@ -10484,8 +9984,8 @@ var DEFAULT_ENTRYPOINT_EXTRACTOR_OPTIONS = {
|
|
|
10484
9984
|
};
|
|
10485
9985
|
|
|
10486
9986
|
// src/indexer/entrypoint-extractor.ts
|
|
10487
|
-
import { Project
|
|
10488
|
-
import * as
|
|
9987
|
+
import { Project } from "ts-morph";
|
|
9988
|
+
import * as path11 from "path";
|
|
10489
9989
|
import * as yaml5 from "yaml";
|
|
10490
9990
|
|
|
10491
9991
|
// src/indexer/entrypoint-sanitizer.ts
|
|
@@ -10582,7 +10082,7 @@ function sanitizeTool(tool) {
|
|
|
10582
10082
|
|
|
10583
10083
|
// src/indexer/entrypoint-cli-extractor.ts
|
|
10584
10084
|
import { SyntaxKind } from "ts-morph";
|
|
10585
|
-
import * as
|
|
10085
|
+
import * as path9 from "path";
|
|
10586
10086
|
function extractCliOptions(sourceFile) {
|
|
10587
10087
|
const options = /* @__PURE__ */ new Map();
|
|
10588
10088
|
const configVar = sourceFile.getVariableDeclaration("PARSE_ARGS_CONFIG");
|
|
@@ -10698,7 +10198,7 @@ function buildCommandSpec(entry, ctx) {
|
|
|
10698
10198
|
return cmdSpec;
|
|
10699
10199
|
}
|
|
10700
10200
|
function extractCliCommands(project, packageRoot, cliCommandsPath, cliTypesPath, warnings) {
|
|
10701
|
-
const typesFullPath =
|
|
10201
|
+
const typesFullPath = path9.join(packageRoot, cliTypesPath);
|
|
10702
10202
|
const typesFile = project.getSourceFile(typesFullPath);
|
|
10703
10203
|
if (typesFile === void 0 && warnings !== void 0) {
|
|
10704
10204
|
warnings.push(
|
|
@@ -10706,7 +10206,7 @@ function extractCliCommands(project, packageRoot, cliCommandsPath, cliTypesPath,
|
|
|
10706
10206
|
);
|
|
10707
10207
|
}
|
|
10708
10208
|
const cliOptions = typesFile !== void 0 ? extractCliOptions(typesFile) : /* @__PURE__ */ new Map();
|
|
10709
|
-
const commandsFullPath =
|
|
10209
|
+
const commandsFullPath = path9.join(packageRoot, cliCommandsPath);
|
|
10710
10210
|
const commandsFile = project.getSourceFile(commandsFullPath);
|
|
10711
10211
|
if (commandsFile === void 0) {
|
|
10712
10212
|
if (warnings !== void 0) {
|
|
@@ -10718,7 +10218,7 @@ function extractCliCommands(project, packageRoot, cliCommandsPath, cliTypesPath,
|
|
|
10718
10218
|
}
|
|
10719
10219
|
const ctx = {
|
|
10720
10220
|
commandsFile,
|
|
10721
|
-
relativePath:
|
|
10221
|
+
relativePath: path9.relative(process.cwd(), commandsFullPath),
|
|
10722
10222
|
cliOptions,
|
|
10723
10223
|
cliCommandsPath,
|
|
10724
10224
|
...warnings !== void 0 && { warnings }
|
|
@@ -10728,7 +10228,7 @@ function extractCliCommands(project, packageRoot, cliCommandsPath, cliTypesPath,
|
|
|
10728
10228
|
|
|
10729
10229
|
// src/indexer/entrypoint-mcp-extractor.ts
|
|
10730
10230
|
import { SyntaxKind as SyntaxKind2 } from "ts-morph";
|
|
10731
|
-
import * as
|
|
10231
|
+
import * as path10 from "path";
|
|
10732
10232
|
function inferZodType(zodExpr) {
|
|
10733
10233
|
if (zodExpr.includes("z.string()")) return "string";
|
|
10734
10234
|
if (zodExpr.includes("z.number()")) return "number";
|
|
@@ -10771,7 +10271,7 @@ function extractZodParameters(schemaObj) {
|
|
|
10771
10271
|
}
|
|
10772
10272
|
function extractMcpTools(project, packageRoot, mcpToolsPath, warnings) {
|
|
10773
10273
|
const tools = [];
|
|
10774
|
-
const toolsDir =
|
|
10274
|
+
const toolsDir = path10.join(packageRoot, mcpToolsPath);
|
|
10775
10275
|
const toolFiles = project.getSourceFiles(`${toolsDir}/*.ts`);
|
|
10776
10276
|
if (toolFiles.length === 0 && warnings !== void 0) {
|
|
10777
10277
|
warnings.push(
|
|
@@ -10780,9 +10280,9 @@ function extractMcpTools(project, packageRoot, mcpToolsPath, warnings) {
|
|
|
10780
10280
|
}
|
|
10781
10281
|
for (const sourceFile of toolFiles) {
|
|
10782
10282
|
const filePath = sourceFile.getFilePath();
|
|
10783
|
-
const fileName =
|
|
10283
|
+
const fileName = path10.basename(filePath);
|
|
10784
10284
|
if (fileName.endsWith(".test.ts") || fileName === "index.ts") continue;
|
|
10785
|
-
const relativePath =
|
|
10285
|
+
const relativePath = path10.relative(process.cwd(), filePath);
|
|
10786
10286
|
const extractedTools = extractToolsFromFile(sourceFile, relativePath, warnings);
|
|
10787
10287
|
tools.push(...extractedTools);
|
|
10788
10288
|
}
|
|
@@ -10910,19 +10410,19 @@ function generateTimestamp() {
|
|
|
10910
10410
|
});
|
|
10911
10411
|
}
|
|
10912
10412
|
function createProject(opts) {
|
|
10913
|
-
const project = new
|
|
10914
|
-
tsConfigFilePath:
|
|
10413
|
+
const project = new Project({
|
|
10414
|
+
tsConfigFilePath: path11.join(opts.packageRoot, "tsconfig.json"),
|
|
10915
10415
|
skipAddingFilesFromTsConfig: true
|
|
10916
10416
|
});
|
|
10917
10417
|
project.addSourceFilesAtPaths([
|
|
10918
|
-
|
|
10919
|
-
|
|
10418
|
+
path11.join(opts.packageRoot, opts.cliCommandsPath),
|
|
10419
|
+
path11.join(opts.packageRoot, "src/cli-types.ts"),
|
|
10920
10420
|
// HELP_TEXT was extracted to cli-help-text.ts in #293 (Jan 2026) and
|
|
10921
10421
|
// cli-types.ts now only re-exports it. The extractor reads it via AST,
|
|
10922
10422
|
// so we have to load the defining file — a bare re-export isn't enough.
|
|
10923
10423
|
// Without this line the CLI command list silently came back empty.
|
|
10924
|
-
|
|
10925
|
-
|
|
10424
|
+
path11.join(opts.packageRoot, "src/cli-help-text.ts"),
|
|
10425
|
+
path11.join(opts.packageRoot, opts.mcpToolsPath, "*.ts")
|
|
10926
10426
|
]);
|
|
10927
10427
|
return project;
|
|
10928
10428
|
}
|
|
@@ -10969,17 +10469,17 @@ function manifestToJson(manifest) {
|
|
|
10969
10469
|
|
|
10970
10470
|
// src/cli/index-command-link-validator.ts
|
|
10971
10471
|
import * as fs12 from "fs/promises";
|
|
10972
|
-
import * as
|
|
10472
|
+
import * as path13 from "path";
|
|
10973
10473
|
|
|
10974
10474
|
// src/cli/index-command-link-validation-helpers.ts
|
|
10975
10475
|
import * as fs11 from "fs/promises";
|
|
10976
|
-
import * as
|
|
10476
|
+
import * as path12 from "path";
|
|
10977
10477
|
async function validateInternalLink(url, sourceFile) {
|
|
10978
10478
|
const [filePath, anchor] = url.split("#");
|
|
10979
10479
|
if (filePath === void 0 || filePath === "") {
|
|
10980
10480
|
return { valid: true };
|
|
10981
10481
|
}
|
|
10982
|
-
const resolvedPath =
|
|
10482
|
+
const resolvedPath = path12.resolve(path12.dirname(sourceFile), filePath);
|
|
10983
10483
|
try {
|
|
10984
10484
|
await fs11.access(resolvedPath);
|
|
10985
10485
|
if (anchor !== void 0 && anchor !== "") {
|
|
@@ -11064,9 +10564,9 @@ async function validateAnchorInFile(anchor, targetFile) {
|
|
|
11064
10564
|
return { valid: true };
|
|
11065
10565
|
}
|
|
11066
10566
|
}
|
|
11067
|
-
return { valid: false, error: `Anchor '#${anchor}' not found in ${
|
|
10567
|
+
return { valid: false, error: `Anchor '#${anchor}' not found in ${path12.basename(targetFile)}` };
|
|
11068
10568
|
} catch {
|
|
11069
|
-
return { valid: false, error: `Failed to read ${
|
|
10569
|
+
return { valid: false, error: `Failed to read ${path12.basename(targetFile)} for anchor check` };
|
|
11070
10570
|
}
|
|
11071
10571
|
}
|
|
11072
10572
|
async function validateAnchorLink(anchor, sourceFile) {
|
|
@@ -11158,7 +10658,7 @@ async function findMarkdownFiles(dir) {
|
|
|
11158
10658
|
try {
|
|
11159
10659
|
const entries = await fs12.readdir(dir, { withFileTypes: true });
|
|
11160
10660
|
for (const entry of entries) {
|
|
11161
|
-
const fullPath =
|
|
10661
|
+
const fullPath = path13.join(dir, entry.name);
|
|
11162
10662
|
if (entry.name === "node_modules" || entry.name === "dist") {
|
|
11163
10663
|
continue;
|
|
11164
10664
|
}
|
|
@@ -11353,7 +10853,7 @@ async function generateIndex(options) {
|
|
|
11353
10853
|
`Extracted ${String(extraction.files.length)} files in ${String(extraction.durationMs)}ms`
|
|
11354
10854
|
);
|
|
11355
10855
|
const index = buildIndex(extraction.files);
|
|
11356
|
-
const outputDir =
|
|
10856
|
+
const outputDir = path14.dirname(outputPath);
|
|
11357
10857
|
await fs13.mkdir(outputDir, { recursive: true });
|
|
11358
10858
|
const content = format === "yaml" ? indexToYaml(index) : indexToJson(index);
|
|
11359
10859
|
await fs13.writeFile(outputPath, content, "utf-8");
|
|
@@ -11424,7 +10924,7 @@ async function generateDiagram(options) {
|
|
|
11424
10924
|
CodebaseIndexSchema.parse(parsed);
|
|
11425
10925
|
const index = parsed;
|
|
11426
10926
|
const diagram = generateDiagramMarkdown(index);
|
|
11427
|
-
await fs13.mkdir(
|
|
10927
|
+
await fs13.mkdir(path14.dirname(diagramPath), { recursive: true });
|
|
11428
10928
|
await fs13.writeFile(diagramPath, diagram, "utf-8");
|
|
11429
10929
|
logger10.info(`Wrote diagram to ${diagramPath}`);
|
|
11430
10930
|
return {
|
|
@@ -11530,7 +11030,7 @@ async function entrypointsCommand(options) {
|
|
|
11530
11030
|
for (const warning of result.warnings) {
|
|
11531
11031
|
logger10.warn(warning);
|
|
11532
11032
|
}
|
|
11533
|
-
const outputDir =
|
|
11033
|
+
const outputDir = path14.dirname(outputPath);
|
|
11534
11034
|
await fs13.mkdir(outputDir, { recursive: true });
|
|
11535
11035
|
const content = format === "yaml" ? manifestToYaml(manifest) : manifestToJson(manifest);
|
|
11536
11036
|
await fs13.writeFile(outputPath, content, "utf-8");
|
|
@@ -11552,7 +11052,7 @@ async function freshnessCommand(options) {
|
|
|
11552
11052
|
const hasIssues = summary.stale > 0 || summary.warning > 0 || summary.unknown > 0;
|
|
11553
11053
|
const output2 = options.format === "json" ? formatFreshnessJson(result) : formatFreshnessTable(result);
|
|
11554
11054
|
if (options.output !== void 0) {
|
|
11555
|
-
const outputDir =
|
|
11055
|
+
const outputDir = path14.dirname(options.output);
|
|
11556
11056
|
await fs13.mkdir(outputDir, { recursive: true });
|
|
11557
11057
|
await fs13.writeFile(options.output, output2, "utf-8");
|
|
11558
11058
|
logger10.info(`Wrote freshness report to ${options.output}`);
|
|
@@ -11586,7 +11086,7 @@ async function linksCommand(options) {
|
|
|
11586
11086
|
const hasBrokenLinks = summary.brokenLinks > 0;
|
|
11587
11087
|
const output2 = options.format === "json" ? formatLinkValidationJson(result) : formatLinkValidationTable(result);
|
|
11588
11088
|
if (options.output !== void 0) {
|
|
11589
|
-
const outputDir =
|
|
11089
|
+
const outputDir = path14.dirname(options.output);
|
|
11590
11090
|
await fs13.mkdir(outputDir, { recursive: true });
|
|
11591
11091
|
await fs13.writeFile(options.output, output2, "utf-8");
|
|
11592
11092
|
logger10.info(`Wrote link validation report to ${options.output}`);
|
|
@@ -12082,32 +11582,32 @@ function learningMetricsCommand(options, context) {
|
|
|
12082
11582
|
}
|
|
12083
11583
|
|
|
12084
11584
|
// src/cli/config-command-types.ts
|
|
12085
|
-
import { z as
|
|
11585
|
+
import { z as z5 } from "zod";
|
|
12086
11586
|
var CONFIG_ACTIONS = ["get", "set", "list", "reset", "export", "import"];
|
|
12087
11587
|
var CONFIG_FORMATS = ["json", "yaml"];
|
|
12088
|
-
var ConfigCommandOptionsSchema =
|
|
11588
|
+
var ConfigCommandOptionsSchema = z5.object({
|
|
12089
11589
|
/** Command action */
|
|
12090
|
-
action:
|
|
11590
|
+
action: z5.enum(CONFIG_ACTIONS),
|
|
12091
11591
|
/** Configuration key (dot notation supported) */
|
|
12092
|
-
key:
|
|
11592
|
+
key: z5.string().optional(),
|
|
12093
11593
|
/** Value to set */
|
|
12094
|
-
value:
|
|
11594
|
+
value: z5.string().optional(),
|
|
12095
11595
|
/** File path for import/export */
|
|
12096
|
-
file:
|
|
11596
|
+
file: z5.string().optional(),
|
|
12097
11597
|
/** Export format */
|
|
12098
|
-
format:
|
|
11598
|
+
format: z5.enum(CONFIG_FORMATS).default("json"),
|
|
12099
11599
|
/** Force overwrite without backup */
|
|
12100
|
-
force:
|
|
11600
|
+
force: z5.boolean().default(false),
|
|
12101
11601
|
/** Show verbose output */
|
|
12102
|
-
verbose:
|
|
11602
|
+
verbose: z5.boolean().default(false)
|
|
12103
11603
|
});
|
|
12104
|
-
var ParsedConfigKeySchema =
|
|
11604
|
+
var ParsedConfigKeySchema = z5.object({
|
|
12105
11605
|
/** Full key string */
|
|
12106
|
-
fullKey:
|
|
11606
|
+
fullKey: z5.string(),
|
|
12107
11607
|
/** Category portion */
|
|
12108
|
-
category:
|
|
11608
|
+
category: z5.string(),
|
|
12109
11609
|
/** Key within category */
|
|
12110
|
-
key:
|
|
11610
|
+
key: z5.string()
|
|
12111
11611
|
});
|
|
12112
11612
|
var ConfigCommandError = class extends Error {
|
|
12113
11613
|
code;
|
|
@@ -12123,7 +11623,7 @@ function isValidConfigAction(value) {
|
|
|
12123
11623
|
|
|
12124
11624
|
// src/cli/config-command-helpers.ts
|
|
12125
11625
|
import * as fs14 from "fs/promises";
|
|
12126
|
-
import * as
|
|
11626
|
+
import * as path15 from "path";
|
|
12127
11627
|
import { existsSync as existsSync10 } from "fs";
|
|
12128
11628
|
|
|
12129
11629
|
// src/cli/config-command-formatting.ts
|
|
@@ -12391,10 +11891,10 @@ function parseValueFromString(stringValue, defaultValue) {
|
|
|
12391
11891
|
}
|
|
12392
11892
|
function resolveFilePath(filePath, allowedBase) {
|
|
12393
11893
|
const base = allowedBase ?? process.cwd();
|
|
12394
|
-
const resolved =
|
|
12395
|
-
const normalizedResolved =
|
|
12396
|
-
const normalizedBase =
|
|
12397
|
-
const isWithinBase = normalizedResolved === normalizedBase || normalizedResolved.startsWith(normalizedBase +
|
|
11894
|
+
const resolved = path15.isAbsolute(filePath) ? filePath : path15.resolve(base, filePath);
|
|
11895
|
+
const normalizedResolved = path15.normalize(resolved);
|
|
11896
|
+
const normalizedBase = path15.normalize(base);
|
|
11897
|
+
const isWithinBase = normalizedResolved === normalizedBase || normalizedResolved.startsWith(normalizedBase + path15.sep);
|
|
12398
11898
|
if (!isWithinBase) {
|
|
12399
11899
|
throw new ConfigCommandError(
|
|
12400
11900
|
"PATH_TRAVERSAL",
|
|
@@ -12405,7 +11905,7 @@ function resolveFilePath(filePath, allowedBase) {
|
|
|
12405
11905
|
}
|
|
12406
11906
|
function getDefaultExportPath(format) {
|
|
12407
11907
|
const extension = format === "json" ? "json" : "yaml";
|
|
12408
|
-
return
|
|
11908
|
+
return path15.resolve(process.cwd(), `nexus-config.${extension}`);
|
|
12409
11909
|
}
|
|
12410
11910
|
|
|
12411
11911
|
// src/cli/config-command-handlers.ts
|
|
@@ -12775,8 +12275,8 @@ async function configCommand(options) {
|
|
|
12775
12275
|
}
|
|
12776
12276
|
|
|
12777
12277
|
// src/cli/hooks/hook-types.ts
|
|
12778
|
-
import { z as
|
|
12779
|
-
var HookEventName =
|
|
12278
|
+
import { z as z6 } from "zod";
|
|
12279
|
+
var HookEventName = z6.enum([
|
|
12780
12280
|
"SessionStart",
|
|
12781
12281
|
"UserPromptSubmit",
|
|
12782
12282
|
"PreToolUse",
|
|
@@ -12791,100 +12291,100 @@ var HookEventName = z7.enum([
|
|
|
12791
12291
|
"Notification",
|
|
12792
12292
|
"Setup"
|
|
12793
12293
|
]);
|
|
12794
|
-
var PermissionMode =
|
|
12294
|
+
var PermissionMode = z6.enum([
|
|
12795
12295
|
"default",
|
|
12796
12296
|
"plan",
|
|
12797
12297
|
"acceptEdits",
|
|
12798
12298
|
"dontAsk",
|
|
12799
12299
|
"bypassPermissions"
|
|
12800
12300
|
]);
|
|
12801
|
-
var HookInputBaseSchema =
|
|
12802
|
-
session_id:
|
|
12803
|
-
transcript_path:
|
|
12804
|
-
cwd:
|
|
12301
|
+
var HookInputBaseSchema = z6.object({
|
|
12302
|
+
session_id: z6.string(),
|
|
12303
|
+
transcript_path: z6.string(),
|
|
12304
|
+
cwd: z6.string(),
|
|
12805
12305
|
permission_mode: PermissionMode,
|
|
12806
12306
|
hook_event_name: HookEventName
|
|
12807
12307
|
});
|
|
12808
|
-
var SessionStartSource =
|
|
12308
|
+
var SessionStartSource = z6.enum(["startup", "resume", "clear", "compact"]);
|
|
12809
12309
|
var SessionStartInputSchema = HookInputBaseSchema.extend({
|
|
12810
|
-
hook_event_name:
|
|
12310
|
+
hook_event_name: z6.literal("SessionStart"),
|
|
12811
12311
|
source: SessionStartSource,
|
|
12812
|
-
model:
|
|
12813
|
-
agent_type:
|
|
12312
|
+
model: z6.string().optional(),
|
|
12313
|
+
agent_type: z6.string().optional()
|
|
12814
12314
|
});
|
|
12815
|
-
var SessionEndReason =
|
|
12315
|
+
var SessionEndReason = z6.enum(["clear", "logout", "prompt_input_exit", "other"]);
|
|
12816
12316
|
var SessionEndInputSchema = HookInputBaseSchema.extend({
|
|
12817
|
-
hook_event_name:
|
|
12317
|
+
hook_event_name: z6.literal("SessionEnd"),
|
|
12818
12318
|
reason: SessionEndReason
|
|
12819
12319
|
});
|
|
12820
12320
|
var PreToolUseInputSchema = HookInputBaseSchema.extend({
|
|
12821
|
-
hook_event_name:
|
|
12822
|
-
tool_name:
|
|
12823
|
-
tool_input:
|
|
12824
|
-
tool_use_id:
|
|
12321
|
+
hook_event_name: z6.literal("PreToolUse"),
|
|
12322
|
+
tool_name: z6.string(),
|
|
12323
|
+
tool_input: z6.record(z6.string(), z6.unknown()),
|
|
12324
|
+
tool_use_id: z6.string()
|
|
12825
12325
|
});
|
|
12826
12326
|
var PostToolUseInputSchema = HookInputBaseSchema.extend({
|
|
12827
|
-
hook_event_name:
|
|
12828
|
-
tool_name:
|
|
12829
|
-
tool_input:
|
|
12830
|
-
tool_response:
|
|
12831
|
-
tool_use_id:
|
|
12327
|
+
hook_event_name: z6.literal("PostToolUse"),
|
|
12328
|
+
tool_name: z6.string(),
|
|
12329
|
+
tool_input: z6.record(z6.string(), z6.unknown()),
|
|
12330
|
+
tool_response: z6.record(z6.string(), z6.unknown()),
|
|
12331
|
+
tool_use_id: z6.string()
|
|
12832
12332
|
});
|
|
12833
12333
|
var PostToolUseFailureInputSchema = HookInputBaseSchema.extend({
|
|
12834
|
-
hook_event_name:
|
|
12835
|
-
tool_name:
|
|
12836
|
-
tool_input:
|
|
12837
|
-
tool_use_id:
|
|
12838
|
-
error:
|
|
12334
|
+
hook_event_name: z6.literal("PostToolUseFailure"),
|
|
12335
|
+
tool_name: z6.string(),
|
|
12336
|
+
tool_input: z6.record(z6.string(), z6.unknown()),
|
|
12337
|
+
tool_use_id: z6.string(),
|
|
12338
|
+
error: z6.string().optional()
|
|
12839
12339
|
});
|
|
12840
12340
|
var StopInputSchema = HookInputBaseSchema.extend({
|
|
12841
|
-
hook_event_name:
|
|
12842
|
-
stop_hook_active:
|
|
12341
|
+
hook_event_name: z6.literal("Stop"),
|
|
12342
|
+
stop_hook_active: z6.boolean()
|
|
12843
12343
|
});
|
|
12844
12344
|
var SubagentStopInputSchema = HookInputBaseSchema.extend({
|
|
12845
|
-
hook_event_name:
|
|
12846
|
-
stop_hook_active:
|
|
12847
|
-
agent_id:
|
|
12848
|
-
agent_transcript_path:
|
|
12345
|
+
hook_event_name: z6.literal("SubagentStop"),
|
|
12346
|
+
stop_hook_active: z6.boolean(),
|
|
12347
|
+
agent_id: z6.string(),
|
|
12348
|
+
agent_transcript_path: z6.string()
|
|
12849
12349
|
});
|
|
12850
12350
|
var UserPromptSubmitInputSchema = HookInputBaseSchema.extend({
|
|
12851
|
-
hook_event_name:
|
|
12852
|
-
prompt:
|
|
12351
|
+
hook_event_name: z6.literal("UserPromptSubmit"),
|
|
12352
|
+
prompt: z6.string()
|
|
12853
12353
|
});
|
|
12854
|
-
var NotificationType =
|
|
12354
|
+
var NotificationType = z6.enum([
|
|
12855
12355
|
"permission_prompt",
|
|
12856
12356
|
"idle_prompt",
|
|
12857
12357
|
"auth_success",
|
|
12858
12358
|
"elicitation_dialog"
|
|
12859
12359
|
]);
|
|
12860
12360
|
var NotificationInputSchema = HookInputBaseSchema.extend({
|
|
12861
|
-
hook_event_name:
|
|
12862
|
-
message:
|
|
12361
|
+
hook_event_name: z6.literal("Notification"),
|
|
12362
|
+
message: z6.string(),
|
|
12863
12363
|
notification_type: NotificationType
|
|
12864
12364
|
});
|
|
12865
|
-
var PreCompactTrigger =
|
|
12365
|
+
var PreCompactTrigger = z6.enum(["manual", "auto"]);
|
|
12866
12366
|
var PreCompactInputSchema = HookInputBaseSchema.extend({
|
|
12867
|
-
hook_event_name:
|
|
12367
|
+
hook_event_name: z6.literal("PreCompact"),
|
|
12868
12368
|
trigger: PreCompactTrigger,
|
|
12869
|
-
custom_instructions:
|
|
12369
|
+
custom_instructions: z6.string().optional()
|
|
12870
12370
|
});
|
|
12871
|
-
var SetupTrigger =
|
|
12371
|
+
var SetupTrigger = z6.enum(["init", "maintenance"]);
|
|
12872
12372
|
var SetupInputSchema = HookInputBaseSchema.extend({
|
|
12873
|
-
hook_event_name:
|
|
12373
|
+
hook_event_name: z6.literal("Setup"),
|
|
12874
12374
|
trigger: SetupTrigger
|
|
12875
12375
|
});
|
|
12876
12376
|
var SubagentStartInputSchema = HookInputBaseSchema.extend({
|
|
12877
|
-
hook_event_name:
|
|
12878
|
-
agent_id:
|
|
12879
|
-
agent_type:
|
|
12377
|
+
hook_event_name: z6.literal("SubagentStart"),
|
|
12378
|
+
agent_id: z6.string(),
|
|
12379
|
+
agent_type: z6.string()
|
|
12880
12380
|
});
|
|
12881
12381
|
var PermissionRequestInputSchema = HookInputBaseSchema.extend({
|
|
12882
|
-
hook_event_name:
|
|
12883
|
-
tool_name:
|
|
12884
|
-
tool_input:
|
|
12885
|
-
tool_use_id:
|
|
12382
|
+
hook_event_name: z6.literal("PermissionRequest"),
|
|
12383
|
+
tool_name: z6.string(),
|
|
12384
|
+
tool_input: z6.record(z6.string(), z6.unknown()),
|
|
12385
|
+
tool_use_id: z6.string()
|
|
12886
12386
|
});
|
|
12887
|
-
var HookInputSchema =
|
|
12387
|
+
var HookInputSchema = z6.discriminatedUnion("hook_event_name", [
|
|
12888
12388
|
SessionStartInputSchema,
|
|
12889
12389
|
SessionEndInputSchema,
|
|
12890
12390
|
PreToolUseInputSchema,
|
|
@@ -12899,57 +12399,57 @@ var HookInputSchema = z7.discriminatedUnion("hook_event_name", [
|
|
|
12899
12399
|
SubagentStartInputSchema,
|
|
12900
12400
|
PermissionRequestInputSchema
|
|
12901
12401
|
]);
|
|
12902
|
-
var PermissionDecision =
|
|
12903
|
-
var HookDecision =
|
|
12904
|
-
var HookOutputBaseSchema =
|
|
12905
|
-
continue:
|
|
12906
|
-
stopReason:
|
|
12907
|
-
suppressOutput:
|
|
12908
|
-
systemMessage:
|
|
12402
|
+
var PermissionDecision = z6.enum(["allow", "deny", "ask"]);
|
|
12403
|
+
var HookDecision = z6.enum(["block"]);
|
|
12404
|
+
var HookOutputBaseSchema = z6.object({
|
|
12405
|
+
continue: z6.boolean().optional(),
|
|
12406
|
+
stopReason: z6.string().optional(),
|
|
12407
|
+
suppressOutput: z6.boolean().optional(),
|
|
12408
|
+
systemMessage: z6.string().optional()
|
|
12909
12409
|
});
|
|
12910
12410
|
var PreToolUseOutputSchema = HookOutputBaseSchema.extend({
|
|
12911
|
-
hookSpecificOutput:
|
|
12912
|
-
hookEventName:
|
|
12411
|
+
hookSpecificOutput: z6.object({
|
|
12412
|
+
hookEventName: z6.literal("PreToolUse"),
|
|
12913
12413
|
permissionDecision: PermissionDecision.optional(),
|
|
12914
|
-
permissionDecisionReason:
|
|
12915
|
-
updatedInput:
|
|
12916
|
-
additionalContext:
|
|
12414
|
+
permissionDecisionReason: z6.string().optional(),
|
|
12415
|
+
updatedInput: z6.record(z6.string(), z6.unknown()).optional(),
|
|
12416
|
+
additionalContext: z6.string().optional()
|
|
12917
12417
|
}).optional()
|
|
12918
12418
|
});
|
|
12919
12419
|
var PostToolUseOutputSchema = HookOutputBaseSchema.extend({
|
|
12920
12420
|
decision: HookDecision.optional(),
|
|
12921
|
-
reason:
|
|
12922
|
-
hookSpecificOutput:
|
|
12923
|
-
hookEventName:
|
|
12924
|
-
additionalContext:
|
|
12421
|
+
reason: z6.string().optional(),
|
|
12422
|
+
hookSpecificOutput: z6.object({
|
|
12423
|
+
hookEventName: z6.literal("PostToolUse"),
|
|
12424
|
+
additionalContext: z6.string().optional()
|
|
12925
12425
|
}).optional()
|
|
12926
12426
|
});
|
|
12927
12427
|
var StopOutputSchema = HookOutputBaseSchema.extend({
|
|
12928
12428
|
decision: HookDecision.optional(),
|
|
12929
|
-
reason:
|
|
12429
|
+
reason: z6.string().optional()
|
|
12930
12430
|
});
|
|
12931
12431
|
var UserPromptSubmitOutputSchema = HookOutputBaseSchema.extend({
|
|
12932
12432
|
decision: HookDecision.optional(),
|
|
12933
|
-
reason:
|
|
12934
|
-
hookSpecificOutput:
|
|
12935
|
-
hookEventName:
|
|
12936
|
-
additionalContext:
|
|
12433
|
+
reason: z6.string().optional(),
|
|
12434
|
+
hookSpecificOutput: z6.object({
|
|
12435
|
+
hookEventName: z6.literal("UserPromptSubmit"),
|
|
12436
|
+
additionalContext: z6.string().optional()
|
|
12937
12437
|
}).optional()
|
|
12938
12438
|
});
|
|
12939
12439
|
var SessionStartOutputSchema = HookOutputBaseSchema.extend({
|
|
12940
|
-
hookSpecificOutput:
|
|
12941
|
-
hookEventName:
|
|
12942
|
-
additionalContext:
|
|
12440
|
+
hookSpecificOutput: z6.object({
|
|
12441
|
+
hookEventName: z6.literal("SessionStart"),
|
|
12442
|
+
additionalContext: z6.string().optional()
|
|
12943
12443
|
}).optional()
|
|
12944
12444
|
});
|
|
12945
12445
|
var PermissionRequestOutputSchema = HookOutputBaseSchema.extend({
|
|
12946
|
-
hookSpecificOutput:
|
|
12947
|
-
hookEventName:
|
|
12948
|
-
decision:
|
|
12949
|
-
behavior:
|
|
12950
|
-
updatedInput:
|
|
12951
|
-
message:
|
|
12952
|
-
interrupt:
|
|
12446
|
+
hookSpecificOutput: z6.object({
|
|
12447
|
+
hookEventName: z6.literal("PermissionRequest"),
|
|
12448
|
+
decision: z6.object({
|
|
12449
|
+
behavior: z6.enum(["allow", "deny"]),
|
|
12450
|
+
updatedInput: z6.record(z6.string(), z6.unknown()).optional(),
|
|
12451
|
+
message: z6.string().optional(),
|
|
12452
|
+
interrupt: z6.boolean().optional()
|
|
12953
12453
|
})
|
|
12954
12454
|
}).optional()
|
|
12955
12455
|
});
|
|
@@ -13035,7 +12535,7 @@ function writeResultAndExit(result) {
|
|
|
13035
12535
|
|
|
13036
12536
|
// src/cli/hooks/hook-router.ts
|
|
13037
12537
|
async function readStdin() {
|
|
13038
|
-
return new Promise((
|
|
12538
|
+
return new Promise((resolve13, reject) => {
|
|
13039
12539
|
let data = "";
|
|
13040
12540
|
process.stdin.setEncoding("utf8");
|
|
13041
12541
|
process.stdin.on("readable", () => {
|
|
@@ -13046,24 +12546,24 @@ async function readStdin() {
|
|
|
13046
12546
|
}
|
|
13047
12547
|
});
|
|
13048
12548
|
process.stdin.on("end", () => {
|
|
13049
|
-
|
|
12549
|
+
resolve13(data);
|
|
13050
12550
|
});
|
|
13051
12551
|
process.stdin.on("error", (err2) => {
|
|
13052
12552
|
reject(err2);
|
|
13053
12553
|
});
|
|
13054
12554
|
if (process.stdin.isTTY) {
|
|
13055
|
-
|
|
12555
|
+
resolve13("");
|
|
13056
12556
|
}
|
|
13057
12557
|
});
|
|
13058
12558
|
}
|
|
13059
12559
|
async function readStdinWithTimeout(timeoutMs = 5e3) {
|
|
13060
|
-
return new Promise((
|
|
12560
|
+
return new Promise((resolve13, reject) => {
|
|
13061
12561
|
const timeout2 = setTimeout(() => {
|
|
13062
12562
|
reject(new Error(`Stdin read timeout after ${String(timeoutMs)}ms`));
|
|
13063
12563
|
}, timeoutMs);
|
|
13064
12564
|
readStdin().then((data) => {
|
|
13065
12565
|
clearTimeout(timeout2);
|
|
13066
|
-
|
|
12566
|
+
resolve13(data);
|
|
13067
12567
|
}).catch((err2) => {
|
|
13068
12568
|
clearTimeout(timeout2);
|
|
13069
12569
|
reject(err2 instanceof Error ? err2 : new Error(String(err2)));
|
|
@@ -14553,9 +14053,9 @@ function interactiveIO() {
|
|
|
14553
14053
|
write: (text) => {
|
|
14554
14054
|
process.stdout.write(text);
|
|
14555
14055
|
},
|
|
14556
|
-
prompt: (question) => new Promise((
|
|
14056
|
+
prompt: (question) => new Promise((resolve13) => {
|
|
14557
14057
|
rl.question(question, (answer) => {
|
|
14558
|
-
|
|
14058
|
+
resolve13(answer.trim());
|
|
14559
14059
|
});
|
|
14560
14060
|
}),
|
|
14561
14061
|
close: () => {
|
|
@@ -14577,8 +14077,8 @@ function scriptedIO() {
|
|
|
14577
14077
|
// src/governance/claims-registry.ts
|
|
14578
14078
|
import { existsSync as existsSync12, readFileSync as readFileSync6 } from "fs";
|
|
14579
14079
|
import { parse as parseYaml2 } from "yaml";
|
|
14580
|
-
import { z as
|
|
14581
|
-
var VerificationMethodSchema =
|
|
14080
|
+
import { z as z7 } from "zod";
|
|
14081
|
+
var VerificationMethodSchema = z7.enum([
|
|
14582
14082
|
"file-exists",
|
|
14583
14083
|
"file-contains",
|
|
14584
14084
|
"source-contains-all",
|
|
@@ -14586,7 +14086,7 @@ var VerificationMethodSchema = z8.enum([
|
|
|
14586
14086
|
"manifest-tool-count",
|
|
14587
14087
|
"roadmap-status"
|
|
14588
14088
|
]);
|
|
14589
|
-
var ClaimStatusSchema =
|
|
14089
|
+
var ClaimStatusSchema = z7.enum([
|
|
14590
14090
|
"verified",
|
|
14591
14091
|
// backed by live evidence the runner checks every CI run
|
|
14592
14092
|
"partial",
|
|
@@ -14596,25 +14096,25 @@ var ClaimStatusSchema = z8.enum([
|
|
|
14596
14096
|
"stale"
|
|
14597
14097
|
// known-broken backing; tracked, must not regress to silent
|
|
14598
14098
|
]);
|
|
14599
|
-
var EvidenceTypeSchema =
|
|
14600
|
-
var VerificationSchema =
|
|
14099
|
+
var EvidenceTypeSchema = z7.enum(["test", "gate", "eval-artifact", "adr", "source"]);
|
|
14100
|
+
var VerificationSchema = z7.object({
|
|
14601
14101
|
method: VerificationMethodSchema,
|
|
14602
14102
|
/** Repo-root-relative path to the live backing evidence. */
|
|
14603
|
-
path:
|
|
14103
|
+
path: z7.string().min(1),
|
|
14604
14104
|
/**
|
|
14605
14105
|
* Expected value. Numeric for `enum-member-count` / `manifest-tool-count`,
|
|
14606
14106
|
* string for `file-contains` / `roadmap-status`. Unused by `file-exists`.
|
|
14607
14107
|
*/
|
|
14608
|
-
expected:
|
|
14108
|
+
expected: z7.union([z7.number().int().nonnegative(), z7.string().min(1)]).optional(),
|
|
14609
14109
|
/** Target symbol name (e.g. the exported `z.enum` const) for count methods. */
|
|
14610
|
-
symbol:
|
|
14110
|
+
symbol: z7.string().min(1).optional(),
|
|
14611
14111
|
/**
|
|
14612
14112
|
* Literal the claim's `subject` doc must contain (#3877). When present, the
|
|
14613
14113
|
* runner verifies the doc making the claim — not just the source of truth —
|
|
14614
14114
|
* so README/ARCHITECTURE drift fails the gate. Omit only for claims whose
|
|
14615
14115
|
* `subject` IS the verification `path` (e.g. `roadmap-status`).
|
|
14616
14116
|
*/
|
|
14617
|
-
subjectContains:
|
|
14117
|
+
subjectContains: z7.string().min(1).optional()
|
|
14618
14118
|
}).strict().superRefine((v, ctx) => {
|
|
14619
14119
|
const needsNumber = v.method === "enum-member-count" || v.method === "manifest-tool-count";
|
|
14620
14120
|
const needsString = v.method === "file-contains" || v.method === "source-contains-all" || v.method === "roadmap-status";
|
|
@@ -14640,24 +14140,24 @@ var VerificationSchema = z8.object({
|
|
|
14640
14140
|
});
|
|
14641
14141
|
}
|
|
14642
14142
|
});
|
|
14643
|
-
var ClaimEntrySchema =
|
|
14143
|
+
var ClaimEntrySchema = z7.object({
|
|
14644
14144
|
/** Stable, kebab-case identifier; never reused. */
|
|
14645
|
-
id:
|
|
14145
|
+
id: z7.string().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/, "id must be kebab-case"),
|
|
14646
14146
|
/** Human-readable claim text (<=25 words). */
|
|
14647
|
-
claim:
|
|
14147
|
+
claim: z7.string().min(1).refine((s) => s.trim().split(/\s+/).length <= 25, "claim must be <=25 words"),
|
|
14648
14148
|
/** Repo-root-relative doc that makes the claim (e.g. README.md). */
|
|
14649
|
-
subject:
|
|
14149
|
+
subject: z7.string().min(1),
|
|
14650
14150
|
status: ClaimStatusSchema,
|
|
14651
14151
|
evidenceType: EvidenceTypeSchema,
|
|
14652
14152
|
verification: VerificationSchema,
|
|
14653
14153
|
/** ISO date (YYYY-MM-DD) the claim was last manually verified. */
|
|
14654
|
-
lastVerified:
|
|
14154
|
+
lastVerified: z7.string().regex(/^\d{4}-\d{2}-\d{2}$/, "lastVerified must be YYYY-MM-DD"),
|
|
14655
14155
|
/** Optional caveat surfaced in reports (required-ish for `partial`). */
|
|
14656
|
-
caveat:
|
|
14156
|
+
caveat: z7.string().optional()
|
|
14657
14157
|
}).strict();
|
|
14658
|
-
var ClaimsRegistrySchema =
|
|
14659
|
-
version:
|
|
14660
|
-
claims:
|
|
14158
|
+
var ClaimsRegistrySchema = z7.object({
|
|
14159
|
+
version: z7.number().int().positive(),
|
|
14160
|
+
claims: z7.array(ClaimEntrySchema).min(1).superRefine((claims, ctx) => {
|
|
14661
14161
|
const seen = /* @__PURE__ */ new Set();
|
|
14662
14162
|
for (const [i, c] of claims.entries()) {
|
|
14663
14163
|
if (seen.has(c.id)) {
|
|
@@ -14674,7 +14174,7 @@ var ClaimsRegistrySchema = z8.object({
|
|
|
14674
14174
|
|
|
14675
14175
|
// src/governance/claims-verify.ts
|
|
14676
14176
|
import { existsSync as existsSync13, readFileSync as readFileSync7 } from "fs";
|
|
14677
|
-
import { isAbsolute as isAbsolute2, join as
|
|
14177
|
+
import { isAbsolute as isAbsolute2, join as join10 } from "path";
|
|
14678
14178
|
|
|
14679
14179
|
// src/cli/fitness-audit.ts
|
|
14680
14180
|
var COLORS = colors;
|
|
@@ -15879,7 +15379,7 @@ async function releaseAnnounceCommand(args) {
|
|
|
15879
15379
|
|
|
15880
15380
|
// src/cli/scaffold.ts
|
|
15881
15381
|
import * as fs16 from "fs";
|
|
15882
|
-
import * as
|
|
15382
|
+
import * as path16 from "path";
|
|
15883
15383
|
|
|
15884
15384
|
// src/cli/scaffold-templates.ts
|
|
15885
15385
|
function toolImportsAndSchema(name, pascal) {
|
|
@@ -16215,8 +15715,8 @@ ${lines}`;
|
|
|
16215
15715
|
function writeFiles(files) {
|
|
16216
15716
|
const createdPaths = [];
|
|
16217
15717
|
for (const file of files) {
|
|
16218
|
-
const fullPath =
|
|
16219
|
-
const dir =
|
|
15718
|
+
const fullPath = path16.resolve(process.cwd(), file.path);
|
|
15719
|
+
const dir = path16.dirname(fullPath);
|
|
16220
15720
|
fs16.mkdirSync(dir, { recursive: true });
|
|
16221
15721
|
if (fs16.existsSync(fullPath)) {
|
|
16222
15722
|
return {
|
|
@@ -17013,11 +16513,11 @@ import {
|
|
|
17013
16513
|
appendFileSync as appendFileSync2,
|
|
17014
16514
|
readFileSync as readFileSync13
|
|
17015
16515
|
} from "fs";
|
|
17016
|
-
import { resolve as
|
|
16516
|
+
import { resolve as resolve9, join as join14, isAbsolute as isAbsolute3 } from "path";
|
|
17017
16517
|
|
|
17018
16518
|
// src/cli/mcp-config-emitter.ts
|
|
17019
16519
|
import { existsSync as existsSync18, readFileSync as readFileSync11, writeFileSync as writeFileSync5, appendFileSync } from "fs";
|
|
17020
|
-
import { join as
|
|
16520
|
+
import { join as join11 } from "path";
|
|
17021
16521
|
var MCP_CONFIG_FILENAME = ".mcp.json";
|
|
17022
16522
|
var NEXUS_SERVER_KEY = "nexus-agents";
|
|
17023
16523
|
function buildNexusServerEntry(dataDir, commandPath) {
|
|
@@ -17039,23 +16539,23 @@ function entriesEqual(a, b) {
|
|
|
17039
16539
|
for (const k of aKeys) if (aEnv[k] !== bEnv[k]) return false;
|
|
17040
16540
|
return true;
|
|
17041
16541
|
}
|
|
17042
|
-
function loadExistingConfig(
|
|
17043
|
-
if (!existsSync18(
|
|
16542
|
+
function loadExistingConfig(path18) {
|
|
16543
|
+
if (!existsSync18(path18)) return { ok: true, value: void 0 };
|
|
17044
16544
|
let raw;
|
|
17045
16545
|
try {
|
|
17046
|
-
raw = readFileSync11(
|
|
16546
|
+
raw = readFileSync11(path18, "utf-8");
|
|
17047
16547
|
} catch (e) {
|
|
17048
16548
|
return { ok: false, error: e instanceof Error ? e.message : String(e) };
|
|
17049
16549
|
}
|
|
17050
16550
|
try {
|
|
17051
16551
|
const parsed = JSON.parse(raw);
|
|
17052
16552
|
if (typeof parsed !== "object" || parsed === null) {
|
|
17053
|
-
return { ok: false, error: `${
|
|
16553
|
+
return { ok: false, error: `${path18}: top-level JSON must be an object` };
|
|
17054
16554
|
}
|
|
17055
16555
|
return { ok: true, value: parsed };
|
|
17056
16556
|
} catch (e) {
|
|
17057
16557
|
const msg = e instanceof Error ? e.message : String(e);
|
|
17058
|
-
return { ok: false, error: `${
|
|
16558
|
+
return { ok: false, error: `${path18}: invalid JSON \u2014 ${msg}` };
|
|
17059
16559
|
}
|
|
17060
16560
|
}
|
|
17061
16561
|
function decideEmission(existing, desired, force) {
|
|
@@ -17077,9 +16577,9 @@ function decideEmission(existing, desired, force) {
|
|
|
17077
16577
|
return { kind: "write", nextConfig: { ...existing, mcpServers: nextServers } };
|
|
17078
16578
|
}
|
|
17079
16579
|
function autoGitignoreMcpConfig(workspaceDir, dryRun) {
|
|
17080
|
-
const gitDir =
|
|
16580
|
+
const gitDir = join11(workspaceDir, ".git");
|
|
17081
16581
|
if (!existsSync18(gitDir)) return false;
|
|
17082
|
-
const gitignorePath =
|
|
16582
|
+
const gitignorePath = join11(workspaceDir, ".gitignore");
|
|
17083
16583
|
let existing = "";
|
|
17084
16584
|
if (existsSync18(gitignorePath)) {
|
|
17085
16585
|
existing = readFileSync11(gitignorePath, "utf-8");
|
|
@@ -17094,7 +16594,7 @@ function autoGitignoreMcpConfig(workspaceDir, dryRun) {
|
|
|
17094
16594
|
return true;
|
|
17095
16595
|
}
|
|
17096
16596
|
function emitMcpConfig(options) {
|
|
17097
|
-
const mcpConfigPath =
|
|
16597
|
+
const mcpConfigPath = join11(options.workspaceDir, MCP_CONFIG_FILENAME);
|
|
17098
16598
|
const dryRun = options.dryRun === true;
|
|
17099
16599
|
const force = options.force === true;
|
|
17100
16600
|
const desired = buildNexusServerEntry(options.dataDir, options.commandPath);
|
|
@@ -17133,12 +16633,12 @@ function makeFailure(mcpConfigPath, error) {
|
|
|
17133
16633
|
// src/cli/portable-installer.ts
|
|
17134
16634
|
import { execFile as execFile2 } from "child_process";
|
|
17135
16635
|
import { existsSync as existsSync20, mkdirSync as mkdirSync4, rmSync, writeFileSync as writeFileSync7 } from "fs";
|
|
17136
|
-
import { join as
|
|
16636
|
+
import { join as join13 } from "path";
|
|
17137
16637
|
import { promisify as promisify2 } from "util";
|
|
17138
16638
|
|
|
17139
16639
|
// src/cli/bin-shim.ts
|
|
17140
16640
|
import { existsSync as existsSync19, readFileSync as readFileSync12, writeFileSync as writeFileSync6, chmodSync as chmodSync2, mkdirSync as mkdirSync3 } from "fs";
|
|
17141
|
-
import { join as
|
|
16641
|
+
import { join as join12 } from "path";
|
|
17142
16642
|
var SHIM_BASENAME = "nexus-agents";
|
|
17143
16643
|
var SHIM_MODE = 493;
|
|
17144
16644
|
function buildShimContents(cliEntryPath) {
|
|
@@ -17152,7 +16652,7 @@ function buildShimContents(cliEntryPath) {
|
|
|
17152
16652
|
return lines.join("\n");
|
|
17153
16653
|
}
|
|
17154
16654
|
function writeBinShim(options) {
|
|
17155
|
-
const shimPath =
|
|
16655
|
+
const shimPath = join12(options.binDir, SHIM_BASENAME);
|
|
17156
16656
|
const desired = buildShimContents(options.cliEntryPath);
|
|
17157
16657
|
const dryRun = options.dryRun === true;
|
|
17158
16658
|
try {
|
|
@@ -17198,10 +16698,10 @@ function writeInstallManifest(cliDir, version) {
|
|
|
17198
16698
|
description: "Local install root for portable nexus-agents (generated; do not commit)",
|
|
17199
16699
|
dependencies: { "nexus-agents": version }
|
|
17200
16700
|
};
|
|
17201
|
-
writeFileSync7(
|
|
16701
|
+
writeFileSync7(join13(cliDir, "package.json"), JSON.stringify(manifest, null, 2) + "\n", "utf-8");
|
|
17202
16702
|
}
|
|
17203
16703
|
function isAlreadyInstalled(cliDir) {
|
|
17204
|
-
return existsSync20(
|
|
16704
|
+
return existsSync20(join13(cliDir, "node_modules", "nexus-agents", "package.json"));
|
|
17205
16705
|
}
|
|
17206
16706
|
async function spawnNpmInstall(cliDir) {
|
|
17207
16707
|
await execFileAsync2("npm", ["install", "--no-audit", "--no-fund", "--silent"], {
|
|
@@ -17228,8 +16728,8 @@ async function runNpmStep(ctx) {
|
|
|
17228
16728
|
}
|
|
17229
16729
|
}
|
|
17230
16730
|
async function installPortable(options) {
|
|
17231
|
-
const cliDir =
|
|
17232
|
-
const binDir =
|
|
16731
|
+
const cliDir = join13(options.dataDir, CLI_SUBDIR);
|
|
16732
|
+
const binDir = join13(options.dataDir, BIN_SUBDIR);
|
|
17233
16733
|
const versionResolution = resolveInstallVersion(options.version);
|
|
17234
16734
|
if (!versionResolution.ok) {
|
|
17235
16735
|
return {
|
|
@@ -17250,7 +16750,7 @@ async function installPortable(options) {
|
|
|
17250
16750
|
}
|
|
17251
16751
|
const npmFailure = await runNpmStep(ctx);
|
|
17252
16752
|
if (npmFailure !== void 0) return npmFailure;
|
|
17253
|
-
const shim = writeBinShim({ binDir, cliEntryPath:
|
|
16753
|
+
const shim = writeBinShim({ binDir, cliEntryPath: join13(cliDir, CLI_ENTRY_RELATIVE) });
|
|
17254
16754
|
if (!shim.success) {
|
|
17255
16755
|
cleanupOnFailure(cliDir);
|
|
17256
16756
|
return {
|
|
@@ -17264,8 +16764,8 @@ async function installPortable(options) {
|
|
|
17264
16764
|
return { success: true, ...ctx, shim, skipped: false, error: null };
|
|
17265
16765
|
}
|
|
17266
16766
|
function uninstallPortable(options) {
|
|
17267
|
-
const cliDir =
|
|
17268
|
-
const binDir =
|
|
16767
|
+
const cliDir = join13(options.dataDir, CLI_SUBDIR);
|
|
16768
|
+
const binDir = join13(options.dataDir, BIN_SUBDIR);
|
|
17269
16769
|
const removed = [];
|
|
17270
16770
|
const notPresent = [];
|
|
17271
16771
|
const dryRun = options.dryRun === true;
|
|
@@ -17285,7 +16785,7 @@ function uninstallPortable(options) {
|
|
|
17285
16785
|
}
|
|
17286
16786
|
}
|
|
17287
16787
|
function findBinShim(dataDir) {
|
|
17288
|
-
const shimPath =
|
|
16788
|
+
const shimPath = join13(dataDir, BIN_SUBDIR, "nexus-agents");
|
|
17289
16789
|
return existsSync20(shimPath) ? shimPath : void 0;
|
|
17290
16790
|
}
|
|
17291
16791
|
|
|
@@ -17294,9 +16794,9 @@ var DEFAULT_PORTABLE_DIRNAME = ".nexus-agents";
|
|
|
17294
16794
|
var RESTRICTED_SUBDIRS = /* @__PURE__ */ new Set(["auth"]);
|
|
17295
16795
|
function resolveTargetPath(rawPath) {
|
|
17296
16796
|
if (rawPath === void 0 || rawPath === "") {
|
|
17297
|
-
return
|
|
16797
|
+
return resolve9(process.cwd(), DEFAULT_PORTABLE_DIRNAME);
|
|
17298
16798
|
}
|
|
17299
|
-
return isAbsolute3(rawPath) ? rawPath :
|
|
16799
|
+
return isAbsolute3(rawPath) ? rawPath : resolve9(process.cwd(), rawPath);
|
|
17300
16800
|
}
|
|
17301
16801
|
function isNonEmpty(dir) {
|
|
17302
16802
|
if (!existsSync21(dir)) return false;
|
|
@@ -17304,20 +16804,20 @@ function isNonEmpty(dir) {
|
|
|
17304
16804
|
if (!stat2.isDirectory()) return true;
|
|
17305
16805
|
return readdirSync(dir).length > 0;
|
|
17306
16806
|
}
|
|
17307
|
-
function ensureDir(
|
|
17308
|
-
if (existsSync21(
|
|
17309
|
-
alreadyExisted.push(
|
|
16807
|
+
function ensureDir(path18, dryRun, created, alreadyExisted, mode) {
|
|
16808
|
+
if (existsSync21(path18)) {
|
|
16809
|
+
alreadyExisted.push(path18);
|
|
17310
16810
|
return;
|
|
17311
16811
|
}
|
|
17312
16812
|
if (!dryRun) {
|
|
17313
|
-
mkdirSync5(
|
|
16813
|
+
mkdirSync5(path18, { recursive: true, ...mode !== void 0 ? { mode } : {} });
|
|
17314
16814
|
}
|
|
17315
|
-
created.push(
|
|
16815
|
+
created.push(path18);
|
|
17316
16816
|
}
|
|
17317
16817
|
function maybeUpdateGitignore(workspaceDir, portableDirName, dryRun) {
|
|
17318
|
-
const gitDir =
|
|
16818
|
+
const gitDir = join14(workspaceDir, ".git");
|
|
17319
16819
|
if (!existsSync21(gitDir)) return false;
|
|
17320
|
-
const gitignorePath =
|
|
16820
|
+
const gitignorePath = join14(workspaceDir, ".gitignore");
|
|
17321
16821
|
const entry = `${portableDirName}/`;
|
|
17322
16822
|
let existing = "";
|
|
17323
16823
|
if (existsSync21(gitignorePath)) {
|
|
@@ -17338,14 +16838,14 @@ function inspectTarget(target) {
|
|
|
17338
16838
|
if (!exists) return { exists: false, nonEmpty: false, isExistingNexusDir: false };
|
|
17339
16839
|
const nonEmpty = isNonEmpty(target);
|
|
17340
16840
|
const stat2 = statSync2(target);
|
|
17341
|
-
const isExistingNexusDir = stat2.isDirectory() && existsSync21(
|
|
16841
|
+
const isExistingNexusDir = stat2.isDirectory() && existsSync21(join14(target, "audit"));
|
|
17342
16842
|
return { exists, nonEmpty, isExistingNexusDir };
|
|
17343
16843
|
}
|
|
17344
16844
|
function createDataLayout(target, dryRun, created, alreadyExisted) {
|
|
17345
16845
|
ensureDir(target, dryRun, created, alreadyExisted);
|
|
17346
16846
|
for (const subdir of DATA_SUBDIRECTORIES) {
|
|
17347
16847
|
const mode = RESTRICTED_SUBDIRS.has(subdir) ? 448 : void 0;
|
|
17348
|
-
ensureDir(
|
|
16848
|
+
ensureDir(join14(target, subdir), dryRun, created, alreadyExisted, mode);
|
|
17349
16849
|
}
|
|
17350
16850
|
}
|
|
17351
16851
|
function makeResult(opts) {
|
|
@@ -17364,13 +16864,13 @@ function makeResult(opts) {
|
|
|
17364
16864
|
}
|
|
17365
16865
|
function applyGitignoreOption(target, options, dryRun) {
|
|
17366
16866
|
if (options.gitignore !== true) return false;
|
|
17367
|
-
const workspaceDir =
|
|
16867
|
+
const workspaceDir = resolve9(target, "..");
|
|
17368
16868
|
const portableName = target.slice(workspaceDir.length + 1);
|
|
17369
16869
|
return maybeUpdateGitignore(workspaceDir, portableName, dryRun);
|
|
17370
16870
|
}
|
|
17371
16871
|
function applyMcpConfigOption(target, options, dryRun) {
|
|
17372
16872
|
if (options.mcpConfig !== true) return void 0;
|
|
17373
|
-
const workspaceDir =
|
|
16873
|
+
const workspaceDir = resolve9(target, "..");
|
|
17374
16874
|
const shimPath = findBinShim(target);
|
|
17375
16875
|
return emitMcpConfig({
|
|
17376
16876
|
workspaceDir,
|
|
@@ -17886,7 +17386,7 @@ function startImprovementReviewScheduler(options) {
|
|
|
17886
17386
|
let running = false;
|
|
17887
17387
|
const runOnce = async () => {
|
|
17888
17388
|
try {
|
|
17889
|
-
const { runImprovementReview: runImprovementReview2, ImprovementReviewInputSchema: ImprovementReviewInputSchema2 } = await import("./improvement-review-
|
|
17389
|
+
const { runImprovementReview: runImprovementReview2, ImprovementReviewInputSchema: ImprovementReviewInputSchema2 } = await import("./improvement-review-DGQPADKS.js");
|
|
17890
17390
|
const input = ImprovementReviewInputSchema2.parse({ fileIssues });
|
|
17891
17391
|
const result = await runImprovementReview2(input, { logger: logger19 });
|
|
17892
17392
|
logger19.info("Scheduled improvement_review complete", {
|
|
@@ -18307,8 +17807,8 @@ async function initUpstreamServers(gatewayConfig, server, logger19) {
|
|
|
18307
17807
|
servers: upstreamServers.length,
|
|
18308
17808
|
tools: tools.length
|
|
18309
17809
|
});
|
|
18310
|
-
const { z:
|
|
18311
|
-
const passthroughSchema =
|
|
17810
|
+
const { z: z13 } = await import("zod");
|
|
17811
|
+
const passthroughSchema = z13.looseObject({});
|
|
18312
17812
|
for (const tool of tools) {
|
|
18313
17813
|
const toolName = tool.name;
|
|
18314
17814
|
const desc = tool.description ?? `Upstream tool: ${toolName}`;
|
|
@@ -18463,6 +17963,7 @@ var HANDLER_TABLE = {
|
|
|
18463
17963
|
verify_audit_chain: standardHandler("verify_audit_chain", registerVerifyAuditChainTool),
|
|
18464
17964
|
extract_symbols: standardHandler("extract_symbols", registerExtractSymbolsTool),
|
|
18465
17965
|
search_codebase: standardHandler("search_codebase", registerSearchCodebaseTool),
|
|
17966
|
+
search_usages: standardHandler("search_usages", registerSearchUsagesTool),
|
|
18466
17967
|
run_dev_pipeline: standardHandler("run_dev_pipeline", registerDevPipelineTool),
|
|
18467
17968
|
run_pipeline: standardHandler("run_pipeline", registerPipelineTool),
|
|
18468
17969
|
pr_review: (ctx) => {
|
|
@@ -18568,21 +18069,21 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
18568
18069
|
|
|
18569
18070
|
// src/mcp/workspace-roots.ts
|
|
18570
18071
|
import { existsSync as existsSync22 } from "fs";
|
|
18571
|
-
import { join as
|
|
18072
|
+
import { join as join15 } from "path";
|
|
18572
18073
|
import { fileURLToPath } from "url";
|
|
18573
18074
|
function deriveWorkspaceRootFromRoots(roots) {
|
|
18574
18075
|
let first = null;
|
|
18575
18076
|
let gitRoot = null;
|
|
18576
18077
|
for (const root of roots) {
|
|
18577
18078
|
if (typeof root.uri !== "string" || !root.uri.startsWith("file://")) continue;
|
|
18578
|
-
let
|
|
18079
|
+
let path18;
|
|
18579
18080
|
try {
|
|
18580
|
-
|
|
18081
|
+
path18 = fileURLToPath(root.uri);
|
|
18581
18082
|
} catch {
|
|
18582
18083
|
continue;
|
|
18583
18084
|
}
|
|
18584
|
-
first ??=
|
|
18585
|
-
if (gitRoot === null && existsSync22(
|
|
18085
|
+
first ??= path18;
|
|
18086
|
+
if (gitRoot === null && existsSync22(join15(path18, ".git"))) gitRoot = path18;
|
|
18586
18087
|
}
|
|
18587
18088
|
return gitRoot ?? first;
|
|
18588
18089
|
}
|
|
@@ -18765,7 +18266,7 @@ async function executeReplTask(task, options, logger19, rl) {
|
|
|
18765
18266
|
}
|
|
18766
18267
|
}
|
|
18767
18268
|
function runOrchestratorRepl(options, logger19) {
|
|
18768
|
-
return new Promise((
|
|
18269
|
+
return new Promise((resolve13) => {
|
|
18769
18270
|
const rl = readline2.createInterface({
|
|
18770
18271
|
input: process.stdin,
|
|
18771
18272
|
output: process.stdout,
|
|
@@ -18788,7 +18289,7 @@ function runOrchestratorRepl(options, logger19) {
|
|
|
18788
18289
|
});
|
|
18789
18290
|
rl.on("close", () => {
|
|
18790
18291
|
logger19.info("Orchestrator REPL closed");
|
|
18791
|
-
|
|
18292
|
+
resolve13();
|
|
18792
18293
|
});
|
|
18793
18294
|
});
|
|
18794
18295
|
}
|
|
@@ -19939,7 +19440,7 @@ function adaptConfigToLibrary(config) {
|
|
|
19939
19440
|
}
|
|
19940
19441
|
function createBeliefPromoter() {
|
|
19941
19442
|
return async (event) => {
|
|
19942
|
-
const { getToolMemory } = await import("./tool-memory-
|
|
19443
|
+
const { getToolMemory } = await import("./tool-memory-IV5BVIV4.js");
|
|
19943
19444
|
const tm = getToolMemory();
|
|
19944
19445
|
await tm.recordBelief(
|
|
19945
19446
|
`skill:${event.name}`,
|
|
@@ -21115,7 +20616,7 @@ async function handleResearchCommand(args) {
|
|
|
21115
20616
|
}
|
|
21116
20617
|
}
|
|
21117
20618
|
async function handleRegistryCommand(args) {
|
|
21118
|
-
const { registryCommand, isValidRegistrySubcommand, formatRegistryUsage } = await import("./registry-command-
|
|
20619
|
+
const { registryCommand, isValidRegistrySubcommand, formatRegistryUsage } = await import("./registry-command-VXXKVZ3H.js");
|
|
21119
20620
|
const subcommand = args.subcommand;
|
|
21120
20621
|
if (!isValidRegistrySubcommand(subcommand)) {
|
|
21121
20622
|
process.stdout.write(`${formatRegistryUsage()}
|
|
@@ -21163,7 +20664,7 @@ async function handleVerifyCommand(args) {
|
|
|
21163
20664
|
async function handleDoctorCommand(args) {
|
|
21164
20665
|
const exitCode = await doctorCommand({ fix: args.options.fix });
|
|
21165
20666
|
if (args.options.deep) {
|
|
21166
|
-
const { runDeepDiagnostics: runDeepDiagnostics2, formatDeepDiagnostics: formatDeepDiagnostics2 } = await import("./doctor-deep-
|
|
20667
|
+
const { runDeepDiagnostics: runDeepDiagnostics2, formatDeepDiagnostics: formatDeepDiagnostics2 } = await import("./doctor-deep-EULAHWTK.js");
|
|
21167
20668
|
const diag = runDeepDiagnostics2();
|
|
21168
20669
|
process.stdout.write(formatDeepDiagnostics2(diag) + "\n");
|
|
21169
20670
|
}
|
|
@@ -21213,7 +20714,7 @@ async function runInitPortableFlow(args) {
|
|
|
21213
20714
|
return cliExit(result.success ? EXIT_CODES.SUCCESS : EXIT_CODES.SERVER_START_FAILED);
|
|
21214
20715
|
}
|
|
21215
20716
|
async function runInitOpencodeFlow(args) {
|
|
21216
|
-
const { runInitOpencode } = await import("./init-opencode-
|
|
20717
|
+
const { runInitOpencode } = await import("./init-opencode-MK2NUEWH.js");
|
|
21217
20718
|
const opencodePath = args.options.opencode;
|
|
21218
20719
|
if (opencodePath === void 0 || opencodePath === "") {
|
|
21219
20720
|
process.stderr.write("Error: --opencode requires a path argument.\n");
|
|
@@ -21239,7 +20740,7 @@ async function runInitOpencodeFlow(args) {
|
|
|
21239
20740
|
return cliExit(EXIT_CODES.SUCCESS);
|
|
21240
20741
|
}
|
|
21241
20742
|
async function renderOpencodeValidate(opencodePath) {
|
|
21242
|
-
const { runOpencodeValidate } = await import("./init-opencode-
|
|
20743
|
+
const { runOpencodeValidate } = await import("./init-opencode-MK2NUEWH.js");
|
|
21243
20744
|
const result = await runOpencodeValidate(opencodePath);
|
|
21244
20745
|
if (!result.ok) {
|
|
21245
20746
|
process.stderr.write(`init --opencode --validate: ${result.reason ?? "failed"}
|
|
@@ -21278,7 +20779,7 @@ async function handleSetupCommandAsync(args) {
|
|
|
21278
20779
|
return cliExitFromStatus(exitCode);
|
|
21279
20780
|
}
|
|
21280
20781
|
async function runCustomApiSetup(args) {
|
|
21281
|
-
const { configureCustomApi } = await import("./setup-custom-api-
|
|
20782
|
+
const { configureCustomApi } = await import("./setup-custom-api-2E4MZ5MF.js");
|
|
21282
20783
|
const baseUrl = args.options.customApi;
|
|
21283
20784
|
if (baseUrl === void 0) return EXIT_CODES.SERVER_START_FAILED;
|
|
21284
20785
|
const input = {
|
|
@@ -21640,13 +21141,13 @@ function handleScaffoldCommand(args) {
|
|
|
21640
21141
|
|
|
21641
21142
|
// src/cli/visualize-summary.ts
|
|
21642
21143
|
import * as fs17 from "fs";
|
|
21643
|
-
import * as
|
|
21144
|
+
import * as path17 from "path";
|
|
21644
21145
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
21645
21146
|
function findPackageRoot(startDir) {
|
|
21646
21147
|
let dir = startDir;
|
|
21647
21148
|
for (let i = 0; i < 5; i++) {
|
|
21648
|
-
if (fs17.existsSync(
|
|
21649
|
-
const parent =
|
|
21149
|
+
if (fs17.existsSync(path17.join(dir, "package.json"))) return dir;
|
|
21150
|
+
const parent = path17.dirname(dir);
|
|
21650
21151
|
if (parent === dir) break;
|
|
21651
21152
|
dir = parent;
|
|
21652
21153
|
}
|
|
@@ -21657,7 +21158,7 @@ function countFiles(dir, pattern) {
|
|
|
21657
21158
|
let count = 0;
|
|
21658
21159
|
for (const entry of fs17.readdirSync(dir, { withFileTypes: true })) {
|
|
21659
21160
|
if (entry.isDirectory() && entry.name !== "node_modules" && entry.name !== "dist") {
|
|
21660
|
-
count += countFiles(
|
|
21161
|
+
count += countFiles(path17.join(dir, entry.name), pattern);
|
|
21661
21162
|
} else if (entry.isFile() && pattern.test(entry.name)) {
|
|
21662
21163
|
count++;
|
|
21663
21164
|
}
|
|
@@ -21666,7 +21167,7 @@ function countFiles(dir, pattern) {
|
|
|
21666
21167
|
}
|
|
21667
21168
|
function readVersion(pkgRoot) {
|
|
21668
21169
|
try {
|
|
21669
|
-
const raw = fs17.readFileSync(
|
|
21170
|
+
const raw = fs17.readFileSync(path17.join(pkgRoot, "package.json"), "utf-8");
|
|
21670
21171
|
const pkg = JSON.parse(raw);
|
|
21671
21172
|
return pkg.version ?? "unknown";
|
|
21672
21173
|
} catch {
|
|
@@ -21687,13 +21188,13 @@ var LAYER_DIRS = [
|
|
|
21687
21188
|
];
|
|
21688
21189
|
function gatherSystemSummary() {
|
|
21689
21190
|
const thisFile = fileURLToPath2(import.meta.url);
|
|
21690
|
-
const pkgRoot = findPackageRoot(
|
|
21691
|
-
const srcDir =
|
|
21191
|
+
const pkgRoot = findPackageRoot(path17.dirname(thisFile));
|
|
21192
|
+
const srcDir = path17.resolve(pkgRoot, "src");
|
|
21692
21193
|
const allTs = countFiles(srcDir, /\.ts$/);
|
|
21693
21194
|
const testTs = countFiles(srcDir, /\.test\.ts$/);
|
|
21694
21195
|
const layers = LAYER_DIRS.map(({ name, dir }) => ({
|
|
21695
21196
|
name,
|
|
21696
|
-
files: countFiles(
|
|
21197
|
+
files: countFiles(path17.join(srcDir, dir), /\.ts$/)
|
|
21697
21198
|
})).filter((l) => l.files > 0);
|
|
21698
21199
|
return {
|
|
21699
21200
|
version: readVersion(pkgRoot),
|
|
@@ -22851,7 +22352,7 @@ function handleStatusCommand2(args) {
|
|
|
22851
22352
|
|
|
22852
22353
|
// src/cli/scenario-command.ts
|
|
22853
22354
|
import { readdir as readdir4 } from "fs/promises";
|
|
22854
|
-
import { join as
|
|
22355
|
+
import { join as join17, resolve as resolve11 } from "path";
|
|
22855
22356
|
|
|
22856
22357
|
// src/testing/e2e/scenario-runner.ts
|
|
22857
22358
|
import { readFile as readFile7 } from "fs/promises";
|
|
@@ -22982,9 +22483,9 @@ function checkCircularDependencies(workflow) {
|
|
|
22982
22483
|
for (const step of workflow.steps) {
|
|
22983
22484
|
stepMap.set(step.id, step);
|
|
22984
22485
|
}
|
|
22985
|
-
const visit = (stepId,
|
|
22486
|
+
const visit = (stepId, path18) => {
|
|
22986
22487
|
if (visiting.has(stepId)) {
|
|
22987
|
-
errors.push(`Circular dependency detected: ${[...
|
|
22488
|
+
errors.push(`Circular dependency detected: ${[...path18, stepId].join(" -> ")}`);
|
|
22988
22489
|
return false;
|
|
22989
22490
|
}
|
|
22990
22491
|
if (visited.has(stepId)) return true;
|
|
@@ -22992,7 +22493,7 @@ function checkCircularDependencies(workflow) {
|
|
|
22992
22493
|
const step = stepMap.get(stepId);
|
|
22993
22494
|
if (step?.dependsOn) {
|
|
22994
22495
|
for (const dep of step.dependsOn) {
|
|
22995
|
-
if (!visit(dep, [...
|
|
22496
|
+
if (!visit(dep, [...path18, stepId])) {
|
|
22996
22497
|
return false;
|
|
22997
22498
|
}
|
|
22998
22499
|
}
|
|
@@ -23011,7 +22512,7 @@ function checkCircularDependencies(workflow) {
|
|
|
23011
22512
|
var defaultStubFactory = {
|
|
23012
22513
|
createAgentStub(agentType, action) {
|
|
23013
22514
|
return async (inputs) => {
|
|
23014
|
-
await new Promise((
|
|
22515
|
+
await new Promise((resolve13) => setTimeout(resolve13, 10));
|
|
23015
22516
|
return {
|
|
23016
22517
|
stepId: `${agentType}-${action}`,
|
|
23017
22518
|
status: "success",
|
|
@@ -23036,8 +22537,8 @@ var ScenarioRunner = class {
|
|
|
23036
22537
|
/**
|
|
23037
22538
|
* Load a scenario fixture from a YAML file.
|
|
23038
22539
|
*/
|
|
23039
|
-
async loadFixture(
|
|
23040
|
-
const content = await readFile7(
|
|
22540
|
+
async loadFixture(path18) {
|
|
22541
|
+
const content = await readFile7(path18, "utf-8");
|
|
23041
22542
|
const data = yaml7.parse(content);
|
|
23042
22543
|
return ScenarioFixtureSchema.parse(data);
|
|
23043
22544
|
}
|
|
@@ -23170,7 +22671,7 @@ function createScenarioRunner(stubFactory) {
|
|
|
23170
22671
|
}
|
|
23171
22672
|
|
|
23172
22673
|
// src/cli/scenario-command.ts
|
|
23173
|
-
var FIXTURES_DIR =
|
|
22674
|
+
var FIXTURES_DIR = resolve11(import.meta.dirname, "../testing/e2e/fixtures");
|
|
23174
22675
|
var SCENARIO_SUFFIX = ".scenario.yaml";
|
|
23175
22676
|
async function listScenarios() {
|
|
23176
22677
|
try {
|
|
@@ -23221,7 +22722,7 @@ async function handleRun(args) {
|
|
|
23221
22722
|
return cliExit(EXIT_CODES.SERVER_START_FAILED);
|
|
23222
22723
|
}
|
|
23223
22724
|
const runner = createScenarioRunner();
|
|
23224
|
-
const fixturePath =
|
|
22725
|
+
const fixturePath = join17(FIXTURES_DIR, `${name}${SCENARIO_SUFFIX}`);
|
|
23225
22726
|
try {
|
|
23226
22727
|
const fixture = await runner.loadFixture(fixturePath);
|
|
23227
22728
|
const result = await runner.run(fixture);
|
|
@@ -23776,10 +23277,10 @@ function stripRefsPrefix(ref) {
|
|
|
23776
23277
|
import { execFile as execFile4 } from "child_process";
|
|
23777
23278
|
import { promisify as promisify4 } from "util";
|
|
23778
23279
|
import { writeFile as writeFile6, mkdir as mkdir5 } from "fs/promises";
|
|
23779
|
-
import { join as
|
|
23280
|
+
import { join as join18, dirname as dirname9 } from "path";
|
|
23780
23281
|
|
|
23781
23282
|
// src/mcp/tools/improvement-remediation-capability.ts
|
|
23782
|
-
import { z as
|
|
23283
|
+
import { z as z8 } from "zod";
|
|
23783
23284
|
var PHASE_CAPABILITIES = {
|
|
23784
23285
|
research: /* @__PURE__ */ new Set(["untrusted-input", "secrets"]),
|
|
23785
23286
|
implement: /* @__PURE__ */ new Set(["repo-write", "secrets"])
|
|
@@ -23820,7 +23321,7 @@ var CapabilityLedger = class {
|
|
|
23820
23321
|
}
|
|
23821
23322
|
}
|
|
23822
23323
|
};
|
|
23823
|
-
var RemediationActionKindSchema =
|
|
23324
|
+
var RemediationActionKindSchema = z8.enum([
|
|
23824
23325
|
"investigate",
|
|
23825
23326
|
"adjust-routing",
|
|
23826
23327
|
"add-test",
|
|
@@ -23828,17 +23329,17 @@ var RemediationActionKindSchema = z9.enum([
|
|
|
23828
23329
|
"update-docs",
|
|
23829
23330
|
"fix-bug"
|
|
23830
23331
|
]);
|
|
23831
|
-
var RemediationStepSchema =
|
|
23332
|
+
var RemediationStepSchema = z8.object({
|
|
23832
23333
|
kind: RemediationActionKindSchema,
|
|
23833
|
-
description:
|
|
23334
|
+
description: z8.string().min(1).max(500),
|
|
23834
23335
|
/** Optional path hint; bounded inert string, validated for traversal at use. */
|
|
23835
|
-
targetPath:
|
|
23336
|
+
targetPath: z8.string().min(1).max(300).optional()
|
|
23836
23337
|
}).strict();
|
|
23837
|
-
var RemediationPlanSchema =
|
|
23338
|
+
var RemediationPlanSchema = z8.object({
|
|
23838
23339
|
/** Source signal key (mirrors ImprovementSignal.signalKey). */
|
|
23839
|
-
signalKey:
|
|
23340
|
+
signalKey: z8.string().min(1).max(200),
|
|
23840
23341
|
/** Signal category (mirrors SignalCategory; 'tool-fitness' #3852, 'perf-regression' #3692). */
|
|
23841
|
-
category:
|
|
23342
|
+
category: z8.enum([
|
|
23842
23343
|
"routing",
|
|
23843
23344
|
"tech-debt",
|
|
23844
23345
|
"bug",
|
|
@@ -23847,8 +23348,8 @@ var RemediationPlanSchema = z9.object({
|
|
|
23847
23348
|
"tool-fitness",
|
|
23848
23349
|
"perf-regression"
|
|
23849
23350
|
]),
|
|
23850
|
-
summary:
|
|
23851
|
-
steps:
|
|
23351
|
+
summary: z8.string().min(1).max(1e3),
|
|
23352
|
+
steps: z8.array(RemediationStepSchema).min(1).max(20)
|
|
23852
23353
|
}).strict();
|
|
23853
23354
|
function parseRemediationPlan(raw) {
|
|
23854
23355
|
const result = RemediationPlanSchema.safeParse(raw);
|
|
@@ -23935,13 +23436,13 @@ function makeGitWorktreeOps(repoRoot) {
|
|
|
23935
23436
|
};
|
|
23936
23437
|
return {
|
|
23937
23438
|
async addWorktree(branch, baseBranch) {
|
|
23938
|
-
const
|
|
23939
|
-
await git2(["worktree", "add", "-b", branch,
|
|
23940
|
-
return
|
|
23439
|
+
const path18 = join18(repoRoot, ".nexus-worktrees", branch.replace(/\//g, "_"));
|
|
23440
|
+
await git2(["worktree", "add", "-b", branch, path18, baseBranch], repoRoot);
|
|
23441
|
+
return path18;
|
|
23941
23442
|
},
|
|
23942
23443
|
async writeFileIn(worktreePath, relPath, content) {
|
|
23943
|
-
const abs =
|
|
23944
|
-
await mkdir5(
|
|
23444
|
+
const abs = join18(worktreePath, relPath);
|
|
23445
|
+
await mkdir5(dirname9(abs), { recursive: true });
|
|
23945
23446
|
await writeFile6(abs, content, "utf8");
|
|
23946
23447
|
},
|
|
23947
23448
|
async commitAll(worktreePath, message) {
|
|
@@ -23978,25 +23479,25 @@ function makeGhPrCreator() {
|
|
|
23978
23479
|
}
|
|
23979
23480
|
|
|
23980
23481
|
// src/mcp/tools/remediation-review.ts
|
|
23981
|
-
import { z as
|
|
23482
|
+
import { z as z9 } from "zod";
|
|
23982
23483
|
function soakRefOf(record) {
|
|
23983
23484
|
return `${record.signalKey}::${record.timestamp}`;
|
|
23984
23485
|
}
|
|
23985
|
-
var ReviewRecordSchema =
|
|
23486
|
+
var ReviewRecordSchema = z9.object({
|
|
23986
23487
|
/** Reference to the reviewed soak selection (`signalKey::timestamp`). */
|
|
23987
|
-
soakRef:
|
|
23488
|
+
soakRef: z9.string(),
|
|
23988
23489
|
/** ISO-8601 time the review was recorded. */
|
|
23989
|
-
reviewedAt:
|
|
23490
|
+
reviewedAt: z9.string(),
|
|
23990
23491
|
/** Always true — a persisted record is, by construction, a review. */
|
|
23991
|
-
reviewed:
|
|
23492
|
+
reviewed: z9.literal(true),
|
|
23992
23493
|
/** Whether the evaluator assessed the selection SOUND. */
|
|
23993
|
-
sound:
|
|
23494
|
+
sound: z9.boolean(),
|
|
23994
23495
|
/** Named evaluator who performed the review (required — the gate's named-evaluator criterion). */
|
|
23995
|
-
evaluator:
|
|
23496
|
+
evaluator: z9.string().min(1),
|
|
23996
23497
|
/** Named owner accepting enforcement, recorded at sign-off time (optional per record). */
|
|
23997
|
-
owner:
|
|
23498
|
+
owner: z9.string().min(1).optional(),
|
|
23998
23499
|
/** Free-text note (secret-scrubbed). */
|
|
23999
|
-
note:
|
|
23500
|
+
note: z9.string().optional()
|
|
24000
23501
|
});
|
|
24001
23502
|
var REVIEW_MAX_RECORDS = 1e4;
|
|
24002
23503
|
function getRemediationReviewFile() {
|
|
@@ -24141,14 +23642,14 @@ import { createHash as createHash4 } from "crypto";
|
|
|
24141
23642
|
import { createHash as createHash3 } from "crypto";
|
|
24142
23643
|
import { mkdtempSync, mkdirSync as mkdirSync6, writeFileSync as writeFileSync8, rmSync as rmSync2, realpathSync as realpathSync2 } from "fs";
|
|
24143
23644
|
import { tmpdir } from "os";
|
|
24144
|
-
import { dirname as
|
|
23645
|
+
import { dirname as dirname11, join as join19 } from "path";
|
|
24145
23646
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
24146
|
-
import { z as
|
|
23647
|
+
import { z as z11 } from "zod";
|
|
24147
23648
|
|
|
24148
23649
|
// src/mcp/tools/codepr-guards.ts
|
|
24149
23650
|
import { realpathSync } from "fs";
|
|
24150
|
-
import { isAbsolute as isAbsolute4, resolve as
|
|
24151
|
-
import { z as
|
|
23651
|
+
import { isAbsolute as isAbsolute4, resolve as resolve12, relative as relative4, sep as sep3, dirname as dirname10, basename as basename4 } from "path";
|
|
23652
|
+
import { z as z10 } from "zod";
|
|
24152
23653
|
function deny(reason, detail) {
|
|
24153
23654
|
return { ok: false, reason, detail };
|
|
24154
23655
|
}
|
|
@@ -24169,7 +23670,7 @@ function confinePath(worktreeRoot, candidatePath, realpath = realpathSync) {
|
|
|
24169
23670
|
} catch {
|
|
24170
23671
|
return deny("path_escape", "worktreeRoot could not be resolved (fail-closed)");
|
|
24171
23672
|
}
|
|
24172
|
-
const joined = isAbsolute4(candidatePath) ? candidatePath :
|
|
23673
|
+
const joined = isAbsolute4(candidatePath) ? candidatePath : resolve12(resolvedRoot, candidatePath);
|
|
24173
23674
|
const reassembled = resolveNewFilePath(joined, realpath);
|
|
24174
23675
|
if (reassembled === void 0) {
|
|
24175
23676
|
return deny("path_escape", "candidate path could not be resolved (fail-closed)");
|
|
@@ -24188,17 +23689,17 @@ function resolveNewFilePath(joined, realpath) {
|
|
|
24188
23689
|
break;
|
|
24189
23690
|
} catch (err2) {
|
|
24190
23691
|
if (errnoCode(err2) !== "ENOENT") return void 0;
|
|
24191
|
-
const parent =
|
|
23692
|
+
const parent = dirname10(existing);
|
|
24192
23693
|
if (parent === existing) return void 0;
|
|
24193
|
-
trailing.push(
|
|
23694
|
+
trailing.push(basename4(existing));
|
|
24194
23695
|
existing = parent;
|
|
24195
23696
|
}
|
|
24196
23697
|
}
|
|
24197
|
-
return trailing.length === 0 ? existing :
|
|
23698
|
+
return trailing.length === 0 ? existing : resolve12(existing, ...trailing.reverse());
|
|
24198
23699
|
}
|
|
24199
23700
|
function isWithin(parent, child) {
|
|
24200
23701
|
if (child === parent) return true;
|
|
24201
|
-
const rel =
|
|
23702
|
+
const rel = relative4(parent, child);
|
|
24202
23703
|
if (rel === "") return true;
|
|
24203
23704
|
if (rel === ".." || rel.startsWith(".." + sep3)) return false;
|
|
24204
23705
|
if (isAbsolute4(rel)) return false;
|
|
@@ -24294,11 +23795,11 @@ function classifyPath(relPath) {
|
|
|
24294
23795
|
}
|
|
24295
23796
|
return { sensitive: false };
|
|
24296
23797
|
}
|
|
24297
|
-
var BlastRadiusLimitsSchema =
|
|
23798
|
+
var BlastRadiusLimitsSchema = z10.object({
|
|
24298
23799
|
/** Max number of files the change may touch. Default 20. */
|
|
24299
|
-
maxFiles:
|
|
23800
|
+
maxFiles: z10.number().int().positive().default(20),
|
|
24300
23801
|
/** Max total changed lines (added + removed across all files). Default 400. */
|
|
24301
|
-
maxLines:
|
|
23802
|
+
maxLines: z10.number().int().positive().default(400)
|
|
24302
23803
|
}).strict();
|
|
24303
23804
|
var DEFAULT_BLAST_RADIUS_LIMITS = Object.freeze(
|
|
24304
23805
|
BlastRadiusLimitsSchema.parse({})
|
|
@@ -24376,13 +23877,13 @@ function auditAutonomousEvent(logger19, record) {
|
|
|
24376
23877
|
}
|
|
24377
23878
|
return { ok: true };
|
|
24378
23879
|
}
|
|
24379
|
-
var ResourceBudgetLimitsSchema =
|
|
23880
|
+
var ResourceBudgetLimitsSchema = z10.object({
|
|
24380
23881
|
/** Wall-clock ceiling in ms. Default 600000 (10 min). */
|
|
24381
|
-
maxWallClockMs:
|
|
23882
|
+
maxWallClockMs: z10.number().int().positive().default(6e5),
|
|
24382
23883
|
/** Token ceiling. Default 200000. */
|
|
24383
|
-
maxTokens:
|
|
23884
|
+
maxTokens: z10.number().int().positive().default(2e5),
|
|
24384
23885
|
/** Tool-call ceiling. Default 200. */
|
|
24385
|
-
maxToolCalls:
|
|
23886
|
+
maxToolCalls: z10.number().int().positive().default(200)
|
|
24386
23887
|
}).strict();
|
|
24387
23888
|
var DEFAULT_RESOURCE_BUDGET_LIMITS = Object.freeze(
|
|
24388
23889
|
ResourceBudgetLimitsSchema.parse({})
|
|
@@ -24442,19 +23943,19 @@ function runGuard(name, fn) {
|
|
|
24442
23943
|
}
|
|
24443
23944
|
|
|
24444
23945
|
// src/mcp/tools/codepr-orchestrator.ts
|
|
24445
|
-
var ProposedChangeSchema =
|
|
23946
|
+
var ProposedChangeSchema = z11.object({
|
|
24446
23947
|
/** Repo-relative path the change would write. */
|
|
24447
|
-
relPath:
|
|
23948
|
+
relPath: z11.string().min(1),
|
|
24448
23949
|
/** The full new file content. */
|
|
24449
|
-
newContent:
|
|
23950
|
+
newContent: z11.string()
|
|
24450
23951
|
}).strict();
|
|
24451
|
-
var CodePrRunInputSchema =
|
|
23952
|
+
var CodePrRunInputSchema = z11.object({
|
|
24452
23953
|
/** Correlates all audit events for this run. */
|
|
24453
|
-
runId:
|
|
23954
|
+
runId: z11.string().min(1),
|
|
24454
23955
|
/** Hash of the source signal (fitness/improvement) that triggered the run. */
|
|
24455
|
-
sourceSignalHash:
|
|
23956
|
+
sourceSignalHash: z11.string().min(1),
|
|
24456
23957
|
/** The proposed change set. */
|
|
24457
|
-
changes:
|
|
23958
|
+
changes: z11.array(ProposedChangeSchema).min(1)
|
|
24458
23959
|
}).strict();
|
|
24459
23960
|
var ORCHESTRATOR_USAGE_ZERO = { wallClockMs: 0, tokens: 0, toolCalls: 0 };
|
|
24460
23961
|
function sha256(s) {
|
|
@@ -24471,9 +23972,9 @@ function parseNumstat(numstat) {
|
|
|
24471
23972
|
if (parts.length < 3) continue;
|
|
24472
23973
|
const added = parts[0] === "-" ? 0 : Number.parseInt(parts[0] ?? "0", 10);
|
|
24473
23974
|
const removed = parts[1] === "-" ? 0 : Number.parseInt(parts[1] ?? "0", 10);
|
|
24474
|
-
const
|
|
23975
|
+
const path18 = parts.slice(2).join(" ");
|
|
24475
23976
|
files.push({
|
|
24476
|
-
path:
|
|
23977
|
+
path: path18,
|
|
24477
23978
|
addedLines: Number.isFinite(added) ? added : 0,
|
|
24478
23979
|
removedLines: Number.isFinite(removed) ? removed : 0
|
|
24479
23980
|
});
|
|
@@ -24528,7 +24029,7 @@ function applyChanges(worktreeRoot, run) {
|
|
|
24528
24029
|
for (const change of run.changes) {
|
|
24529
24030
|
const confined = confinePath(worktreeRoot, change.relPath);
|
|
24530
24031
|
if (!confined.ok) throw new Error(`apply: ${confined.detail}`);
|
|
24531
|
-
mkdirSync6(
|
|
24032
|
+
mkdirSync6(dirname11(confined.resolvedPath), { recursive: true });
|
|
24532
24033
|
writeFileSync8(confined.resolvedPath, change.newContent);
|
|
24533
24034
|
}
|
|
24534
24035
|
}
|
|
@@ -24590,8 +24091,8 @@ function runGuardsAndPlan(args, logger19) {
|
|
|
24590
24091
|
function runInWorktree(run, logger19, options, handle) {
|
|
24591
24092
|
const fault = options.faultInjector;
|
|
24592
24093
|
const repoRoot = options.repoRoot ?? process.cwd();
|
|
24593
|
-
handle.tempParent = realpathSync2(mkdtempSync(
|
|
24594
|
-
handle.worktreeRoot =
|
|
24094
|
+
handle.tempParent = realpathSync2(mkdtempSync(join19(tmpdir(), "codepr-orchestrator-")));
|
|
24095
|
+
handle.worktreeRoot = join19(handle.tempParent, "wt");
|
|
24595
24096
|
git(repoRoot, ["worktree", "add", "--detach", handle.worktreeRoot]);
|
|
24596
24097
|
fault?.("after-worktree");
|
|
24597
24098
|
const precheck = precheckChanges(handle.worktreeRoot, run, logger19);
|
|
@@ -24657,20 +24158,20 @@ function planCodePrRun(input, logger19, options = {}) {
|
|
|
24657
24158
|
}
|
|
24658
24159
|
|
|
24659
24160
|
// src/mcp/tools/codepr-soak-store.ts
|
|
24660
|
-
import { z as
|
|
24661
|
-
var CodePrSoakRecordSchema =
|
|
24161
|
+
import { z as z12 } from "zod";
|
|
24162
|
+
var CodePrSoakRecordSchema = z12.object({
|
|
24662
24163
|
/** ISO-8601 capture time. */
|
|
24663
|
-
timestamp:
|
|
24164
|
+
timestamp: z12.string(),
|
|
24664
24165
|
/** Correlates the data point to the dry-run's orchestrator runId. */
|
|
24665
|
-
runId:
|
|
24166
|
+
runId: z12.string(),
|
|
24666
24167
|
/** The improvement signal's stable key that triggered the dry-run. */
|
|
24667
|
-
signalKey:
|
|
24168
|
+
signalKey: z12.string(),
|
|
24668
24169
|
/** True when the dry-run plan succeeded with ZERO guard denial. */
|
|
24669
|
-
green:
|
|
24170
|
+
green: z12.boolean(),
|
|
24670
24171
|
/** The guard denial reason when `green` is false; omitted for a green plan. */
|
|
24671
|
-
denialReason:
|
|
24172
|
+
denialReason: z12.string().optional(),
|
|
24672
24173
|
/** Files the dry-run plan touched (0 on denial before the diff was realized). */
|
|
24673
|
-
filesTouched:
|
|
24174
|
+
filesTouched: z12.number().int().nonnegative()
|
|
24674
24175
|
}).strict();
|
|
24675
24176
|
var CODEPR_SOAK_MAX_RECORDS = 1e4;
|
|
24676
24177
|
function getCodePrSoakFile() {
|
|
@@ -24736,11 +24237,11 @@ function deriveProposedChanges(plan) {
|
|
|
24736
24237
|
const changes = [];
|
|
24737
24238
|
for (const step of plan.steps) {
|
|
24738
24239
|
if (!CODE_TOUCHING_KINDS.has(step.kind)) continue;
|
|
24739
|
-
const
|
|
24740
|
-
if (seen.has(
|
|
24741
|
-
seen.add(
|
|
24240
|
+
const path18 = step.targetPath !== void 0 && step.targetPath !== "" ? step.targetPath : placeholderPathFor(plan, step.kind);
|
|
24241
|
+
if (seen.has(path18)) continue;
|
|
24242
|
+
seen.add(path18);
|
|
24742
24243
|
changes.push({
|
|
24743
|
-
relPath:
|
|
24244
|
+
relPath: path18,
|
|
24744
24245
|
newContent: `// codepr soak dry-run placeholder for ${plan.signalKey} (${step.kind})
|
|
24745
24246
|
`
|
|
24746
24247
|
});
|
|
@@ -25016,11 +24517,11 @@ var PROTECTED_PATH_FRAGMENTS = [
|
|
|
25016
24517
|
"secret",
|
|
25017
24518
|
"credential"
|
|
25018
24519
|
];
|
|
25019
|
-
function normalize2(
|
|
25020
|
-
return
|
|
24520
|
+
function normalize2(path18) {
|
|
24521
|
+
return path18.replace(/\\/g, "/").replace(/^\.\//, "").toLowerCase();
|
|
25021
24522
|
}
|
|
25022
|
-
function isProtectedPath(
|
|
25023
|
-
const p = normalize2(
|
|
24523
|
+
function isProtectedPath(path18) {
|
|
24524
|
+
const p = normalize2(path18);
|
|
25024
24525
|
return PROTECTED_PATH_FRAGMENTS.some((frag) => p.includes(frag));
|
|
25025
24526
|
}
|
|
25026
24527
|
function planTouchesProtectedPath(plan) {
|
|
@@ -25460,16 +24961,16 @@ async function handleRemediationReviewCommand(args) {
|
|
|
25460
24961
|
// src/cli/migrate-command.ts
|
|
25461
24962
|
import { cpSync, existsSync as existsSync24, mkdirSync as mkdirSync7, readdirSync as readdirSync3 } from "fs";
|
|
25462
24963
|
import { homedir } from "os";
|
|
25463
|
-
import { join as
|
|
24964
|
+
import { join as join20 } from "path";
|
|
25464
24965
|
var logger18 = createLogger({ component: "migrate-command" });
|
|
25465
|
-
var HOMEDIR_DEFAULT_BASE =
|
|
24966
|
+
var HOMEDIR_DEFAULT_BASE = join20(homedir(), ".nexus-agents");
|
|
25466
24967
|
function countItems(dir) {
|
|
25467
24968
|
if (!existsSync24(dir)) return 0;
|
|
25468
24969
|
try {
|
|
25469
24970
|
const entries = readdirSync3(dir, { withFileTypes: true });
|
|
25470
24971
|
let n = 0;
|
|
25471
24972
|
for (const e of entries) {
|
|
25472
|
-
const p =
|
|
24973
|
+
const p = join20(dir, e.name);
|
|
25473
24974
|
if (e.isDirectory()) {
|
|
25474
24975
|
n += countItems(p);
|
|
25475
24976
|
} else {
|
|
@@ -25524,8 +25025,8 @@ function checkEarlyExits(fromBase, toBase, dryRun) {
|
|
|
25524
25025
|
return null;
|
|
25525
25026
|
}
|
|
25526
25027
|
function planAndExecuteEntry(name, fromBase, toBase, perRepoSet, dryRun) {
|
|
25527
|
-
const source =
|
|
25528
|
-
const target =
|
|
25028
|
+
const source = join20(fromBase, name);
|
|
25029
|
+
const target = join20(toBase, name);
|
|
25529
25030
|
if (!perRepoSet.has(name)) {
|
|
25530
25031
|
return { subdir: name, status: "skipped-not-per-repo", source, target: "", itemsCopied: 0 };
|
|
25531
25032
|
}
|
|
@@ -25545,7 +25046,7 @@ function planAndExecuteEntry(name, fromBase, toBase, perRepoSet, dryRun) {
|
|
|
25545
25046
|
function resolveDefaultTarget(cwd) {
|
|
25546
25047
|
const repoRoot = findRepoRoot(cwd);
|
|
25547
25048
|
if (repoRoot === null) return null;
|
|
25548
|
-
return
|
|
25049
|
+
return join20(repoRoot, ".nexus-agents");
|
|
25549
25050
|
}
|
|
25550
25051
|
function formatMigrationResult(result) {
|
|
25551
25052
|
if (!result.success) {
|
|
@@ -25588,7 +25089,7 @@ async function handleMigrateCommand(args) {
|
|
|
25588
25089
|
|
|
25589
25090
|
// src/cli/first-run-hint.ts
|
|
25590
25091
|
import { existsSync as existsSync25, mkdirSync as mkdirSync8, writeFileSync as writeFileSync9 } from "fs";
|
|
25591
|
-
import { dirname as
|
|
25092
|
+
import { dirname as dirname12 } from "path";
|
|
25592
25093
|
var HINT_SUPPRESSED_COMMANDS = /* @__PURE__ */ new Set(["version", "help", "setup"]);
|
|
25593
25094
|
function firstRunMarkerPath() {
|
|
25594
25095
|
return nexusSharedPath(".first-run-done");
|
|
@@ -25605,7 +25106,7 @@ function maybeShowFirstRunHint(command) {
|
|
|
25605
25106
|
"\x1B[36mnexus-agents\x1B[0m: First time? Run \x1B[1mnexus-agents setup\x1B[0m to configure.\n (This one-time hint is now dismissed.)\n"
|
|
25606
25107
|
);
|
|
25607
25108
|
try {
|
|
25608
|
-
mkdirSync8(
|
|
25109
|
+
mkdirSync8(dirname12(marker), { recursive: true });
|
|
25609
25110
|
writeFileSync9(marker, `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
25610
25111
|
`, { flag: "w" });
|
|
25611
25112
|
} catch {
|