@microsoft/agentrc 2.0.1-90 → 2.0.1-92
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 +30 -13
- package/dist/index.js +472 -556
- package/dist/index.js.map +1 -1
- package/dist/skills/nested-hub/SKILL.md +22 -1
- package/package.json +8 -3
package/dist/index.js
CHANGED
|
@@ -3308,21 +3308,6 @@ function createServerRpc(connection) {
|
|
|
3308
3308
|
},
|
|
3309
3309
|
account: {
|
|
3310
3310
|
getQuota: async () => connection.sendRequest("account.getQuota", {})
|
|
3311
|
-
},
|
|
3312
|
-
mcp: {
|
|
3313
|
-
config: {
|
|
3314
|
-
list: async () => connection.sendRequest("mcp.config.list", {}),
|
|
3315
|
-
add: async (params) => connection.sendRequest("mcp.config.add", params),
|
|
3316
|
-
update: async (params) => connection.sendRequest("mcp.config.update", params),
|
|
3317
|
-
remove: async (params) => connection.sendRequest("mcp.config.remove", params)
|
|
3318
|
-
}
|
|
3319
|
-
},
|
|
3320
|
-
sessionFs: {
|
|
3321
|
-
setProvider: async (params) => connection.sendRequest("sessionFs.setProvider", params)
|
|
3322
|
-
},
|
|
3323
|
-
/** @experimental */
|
|
3324
|
-
sessions: {
|
|
3325
|
-
fork: async (params) => connection.sendRequest("sessions.fork", params)
|
|
3326
3311
|
}
|
|
3327
3312
|
};
|
|
3328
3313
|
}
|
|
@@ -3383,6 +3368,10 @@ function createSessionRpc(connection, sessionId) {
|
|
|
3383
3368
|
disable: async (params) => connection.sendRequest("session.extensions.disable", { sessionId, ...params }),
|
|
3384
3369
|
reload: async () => connection.sendRequest("session.extensions.reload", { sessionId })
|
|
3385
3370
|
},
|
|
3371
|
+
/** @experimental */
|
|
3372
|
+
compaction: {
|
|
3373
|
+
compact: async () => connection.sendRequest("session.compaction.compact", { sessionId })
|
|
3374
|
+
},
|
|
3386
3375
|
tools: {
|
|
3387
3376
|
handlePendingToolCall: async (params) => connection.sendRequest("session.tools.handlePendingToolCall", { sessionId, ...params })
|
|
3388
3377
|
},
|
|
@@ -3390,8 +3379,7 @@ function createSessionRpc(connection, sessionId) {
|
|
|
3390
3379
|
handlePendingCommand: async (params) => connection.sendRequest("session.commands.handlePendingCommand", { sessionId, ...params })
|
|
3391
3380
|
},
|
|
3392
3381
|
ui: {
|
|
3393
|
-
elicitation: async (params) => connection.sendRequest("session.ui.elicitation", { sessionId, ...params })
|
|
3394
|
-
handlePendingElicitation: async (params) => connection.sendRequest("session.ui.handlePendingElicitation", { sessionId, ...params })
|
|
3382
|
+
elicitation: async (params) => connection.sendRequest("session.ui.elicitation", { sessionId, ...params })
|
|
3395
3383
|
},
|
|
3396
3384
|
permissions: {
|
|
3397
3385
|
handlePendingPermissionRequest: async (params) => connection.sendRequest("session.permissions.handlePendingPermissionRequest", { sessionId, ...params })
|
|
@@ -3400,66 +3388,9 @@ function createSessionRpc(connection, sessionId) {
|
|
|
3400
3388
|
shell: {
|
|
3401
3389
|
exec: async (params) => connection.sendRequest("session.shell.exec", { sessionId, ...params }),
|
|
3402
3390
|
kill: async (params) => connection.sendRequest("session.shell.kill", { sessionId, ...params })
|
|
3403
|
-
},
|
|
3404
|
-
/** @experimental */
|
|
3405
|
-
history: {
|
|
3406
|
-
compact: async () => connection.sendRequest("session.history.compact", { sessionId }),
|
|
3407
|
-
truncate: async (params) => connection.sendRequest("session.history.truncate", { sessionId, ...params })
|
|
3408
3391
|
}
|
|
3409
3392
|
};
|
|
3410
3393
|
}
|
|
3411
|
-
function registerClientSessionApiHandlers(connection, getHandlers) {
|
|
3412
|
-
connection.onRequest("sessionFs.readFile", async (params) => {
|
|
3413
|
-
const handler = getHandlers(params.sessionId).sessionFs;
|
|
3414
|
-
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
3415
|
-
return handler.readFile(params);
|
|
3416
|
-
});
|
|
3417
|
-
connection.onRequest("sessionFs.writeFile", async (params) => {
|
|
3418
|
-
const handler = getHandlers(params.sessionId).sessionFs;
|
|
3419
|
-
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
3420
|
-
return handler.writeFile(params);
|
|
3421
|
-
});
|
|
3422
|
-
connection.onRequest("sessionFs.appendFile", async (params) => {
|
|
3423
|
-
const handler = getHandlers(params.sessionId).sessionFs;
|
|
3424
|
-
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
3425
|
-
return handler.appendFile(params);
|
|
3426
|
-
});
|
|
3427
|
-
connection.onRequest("sessionFs.exists", async (params) => {
|
|
3428
|
-
const handler = getHandlers(params.sessionId).sessionFs;
|
|
3429
|
-
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
3430
|
-
return handler.exists(params);
|
|
3431
|
-
});
|
|
3432
|
-
connection.onRequest("sessionFs.stat", async (params) => {
|
|
3433
|
-
const handler = getHandlers(params.sessionId).sessionFs;
|
|
3434
|
-
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
3435
|
-
return handler.stat(params);
|
|
3436
|
-
});
|
|
3437
|
-
connection.onRequest("sessionFs.mkdir", async (params) => {
|
|
3438
|
-
const handler = getHandlers(params.sessionId).sessionFs;
|
|
3439
|
-
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
3440
|
-
return handler.mkdir(params);
|
|
3441
|
-
});
|
|
3442
|
-
connection.onRequest("sessionFs.readdir", async (params) => {
|
|
3443
|
-
const handler = getHandlers(params.sessionId).sessionFs;
|
|
3444
|
-
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
3445
|
-
return handler.readdir(params);
|
|
3446
|
-
});
|
|
3447
|
-
connection.onRequest("sessionFs.readdirWithTypes", async (params) => {
|
|
3448
|
-
const handler = getHandlers(params.sessionId).sessionFs;
|
|
3449
|
-
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
3450
|
-
return handler.readdirWithTypes(params);
|
|
3451
|
-
});
|
|
3452
|
-
connection.onRequest("sessionFs.rm", async (params) => {
|
|
3453
|
-
const handler = getHandlers(params.sessionId).sessionFs;
|
|
3454
|
-
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
3455
|
-
return handler.rm(params);
|
|
3456
|
-
});
|
|
3457
|
-
connection.onRequest("sessionFs.rename", async (params) => {
|
|
3458
|
-
const handler = getHandlers(params.sessionId).sessionFs;
|
|
3459
|
-
if (!handler) throw new Error(`No sessionFs handler registered for session: ${params.sessionId}`);
|
|
3460
|
-
return handler.rename(params);
|
|
3461
|
-
});
|
|
3462
|
-
}
|
|
3463
3394
|
var init_rpc = __esm({
|
|
3464
3395
|
"node_modules/@github/copilot-sdk/dist/generated/rpc.js"() {
|
|
3465
3396
|
"use strict";
|
|
@@ -3494,25 +3425,6 @@ var init_telemetry = __esm({
|
|
|
3494
3425
|
});
|
|
3495
3426
|
|
|
3496
3427
|
// node_modules/@github/copilot-sdk/dist/session.js
|
|
3497
|
-
function isToolResultObject(value) {
|
|
3498
|
-
if (typeof value !== "object" || value === null) {
|
|
3499
|
-
return false;
|
|
3500
|
-
}
|
|
3501
|
-
if (!("textResultForLlm" in value) || typeof value.textResultForLlm !== "string") {
|
|
3502
|
-
return false;
|
|
3503
|
-
}
|
|
3504
|
-
if (!("resultType" in value) || typeof value.resultType !== "string") {
|
|
3505
|
-
return false;
|
|
3506
|
-
}
|
|
3507
|
-
const allowedResultTypes = [
|
|
3508
|
-
"success",
|
|
3509
|
-
"failure",
|
|
3510
|
-
"rejected",
|
|
3511
|
-
"denied",
|
|
3512
|
-
"timeout"
|
|
3513
|
-
];
|
|
3514
|
-
return allowedResultTypes.includes(value.resultType);
|
|
3515
|
-
}
|
|
3516
3428
|
var import_node, NO_RESULT_PERMISSION_V2_ERROR, CopilotSession;
|
|
3517
3429
|
var init_session = __esm({
|
|
3518
3430
|
"node_modules/@github/copilot-sdk/dist/session.js"() {
|
|
@@ -3540,17 +3452,12 @@ var init_session = __esm({
|
|
|
3540
3452
|
eventHandlers = /* @__PURE__ */ new Set();
|
|
3541
3453
|
typedEventHandlers = /* @__PURE__ */ new Map();
|
|
3542
3454
|
toolHandlers = /* @__PURE__ */ new Map();
|
|
3543
|
-
commandHandlers = /* @__PURE__ */ new Map();
|
|
3544
3455
|
permissionHandler;
|
|
3545
3456
|
userInputHandler;
|
|
3546
|
-
elicitationHandler;
|
|
3547
3457
|
hooks;
|
|
3548
3458
|
transformCallbacks;
|
|
3549
3459
|
_rpc = null;
|
|
3550
3460
|
traceContextProvider;
|
|
3551
|
-
_capabilities = {};
|
|
3552
|
-
/** @internal Client session API handlers, populated by CopilotClient during create/resume. */
|
|
3553
|
-
clientSessionApis = {};
|
|
3554
3461
|
/**
|
|
3555
3462
|
* Typed session-scoped RPC methods.
|
|
3556
3463
|
*/
|
|
@@ -3568,33 +3475,6 @@ var init_session = __esm({
|
|
|
3568
3475
|
get workspacePath() {
|
|
3569
3476
|
return this._workspacePath;
|
|
3570
3477
|
}
|
|
3571
|
-
/**
|
|
3572
|
-
* Host capabilities reported when the session was created or resumed.
|
|
3573
|
-
* Use this to check feature support before calling capability-gated APIs.
|
|
3574
|
-
*/
|
|
3575
|
-
get capabilities() {
|
|
3576
|
-
return this._capabilities;
|
|
3577
|
-
}
|
|
3578
|
-
/**
|
|
3579
|
-
* Interactive UI methods for showing dialogs to the user.
|
|
3580
|
-
* Only available when the CLI host supports elicitation
|
|
3581
|
-
* (`session.capabilities.ui?.elicitation === true`).
|
|
3582
|
-
*
|
|
3583
|
-
* @example
|
|
3584
|
-
* ```typescript
|
|
3585
|
-
* if (session.capabilities.ui?.elicitation) {
|
|
3586
|
-
* const ok = await session.ui.confirm("Deploy to production?");
|
|
3587
|
-
* }
|
|
3588
|
-
* ```
|
|
3589
|
-
*/
|
|
3590
|
-
get ui() {
|
|
3591
|
-
return {
|
|
3592
|
-
elicitation: (params) => this._elicitation(params),
|
|
3593
|
-
confirm: (message) => this._confirm(message),
|
|
3594
|
-
select: (message, options) => this._select(message, options),
|
|
3595
|
-
input: (message, options) => this._input(message, options)
|
|
3596
|
-
};
|
|
3597
|
-
}
|
|
3598
3478
|
/**
|
|
3599
3479
|
* Sends a message to this session and waits for the response.
|
|
3600
3480
|
*
|
|
@@ -3760,33 +3640,10 @@ var init_session = __esm({
|
|
|
3760
3640
|
);
|
|
3761
3641
|
}
|
|
3762
3642
|
} else if (event.type === "permission.requested") {
|
|
3763
|
-
const { requestId, permissionRequest
|
|
3764
|
-
if (resolvedByHook) {
|
|
3765
|
-
return;
|
|
3766
|
-
}
|
|
3643
|
+
const { requestId, permissionRequest } = event.data;
|
|
3767
3644
|
if (this.permissionHandler) {
|
|
3768
3645
|
void this._executePermissionAndRespond(requestId, permissionRequest);
|
|
3769
3646
|
}
|
|
3770
|
-
} else if (event.type === "command.execute") {
|
|
3771
|
-
const { requestId, commandName, command, args: args2 } = event.data;
|
|
3772
|
-
void this._executeCommandAndRespond(requestId, commandName, command, args2);
|
|
3773
|
-
} else if (event.type === "elicitation.requested") {
|
|
3774
|
-
if (this.elicitationHandler) {
|
|
3775
|
-
const { message, requestedSchema, mode, elicitationSource, url, requestId } = event.data;
|
|
3776
|
-
void this._handleElicitationRequest(
|
|
3777
|
-
{
|
|
3778
|
-
sessionId: this.sessionId,
|
|
3779
|
-
message,
|
|
3780
|
-
requestedSchema,
|
|
3781
|
-
mode,
|
|
3782
|
-
elicitationSource,
|
|
3783
|
-
url
|
|
3784
|
-
},
|
|
3785
|
-
requestId
|
|
3786
|
-
);
|
|
3787
|
-
}
|
|
3788
|
-
} else if (event.type === "capabilities.changed") {
|
|
3789
|
-
this._capabilities = { ...this._capabilities, ...event.data };
|
|
3790
3647
|
}
|
|
3791
3648
|
}
|
|
3792
3649
|
/**
|
|
@@ -3808,8 +3665,6 @@ var init_session = __esm({
|
|
|
3808
3665
|
result = "";
|
|
3809
3666
|
} else if (typeof rawResult === "string") {
|
|
3810
3667
|
result = rawResult;
|
|
3811
|
-
} else if (isToolResultObject(rawResult)) {
|
|
3812
|
-
result = rawResult;
|
|
3813
3668
|
} else {
|
|
3814
3669
|
result = JSON.stringify(rawResult);
|
|
3815
3670
|
}
|
|
@@ -3853,39 +3708,6 @@ var init_session = __esm({
|
|
|
3853
3708
|
}
|
|
3854
3709
|
}
|
|
3855
3710
|
}
|
|
3856
|
-
/**
|
|
3857
|
-
* Executes a command handler and sends the result back via RPC.
|
|
3858
|
-
* @internal
|
|
3859
|
-
*/
|
|
3860
|
-
async _executeCommandAndRespond(requestId, commandName, command, args2) {
|
|
3861
|
-
const handler = this.commandHandlers.get(commandName);
|
|
3862
|
-
if (!handler) {
|
|
3863
|
-
try {
|
|
3864
|
-
await this.rpc.commands.handlePendingCommand({
|
|
3865
|
-
requestId,
|
|
3866
|
-
error: `Unknown command: ${commandName}`
|
|
3867
|
-
});
|
|
3868
|
-
} catch (rpcError) {
|
|
3869
|
-
if (!(rpcError instanceof import_node.ConnectionError || rpcError instanceof import_node.ResponseError)) {
|
|
3870
|
-
throw rpcError;
|
|
3871
|
-
}
|
|
3872
|
-
}
|
|
3873
|
-
return;
|
|
3874
|
-
}
|
|
3875
|
-
try {
|
|
3876
|
-
await handler({ sessionId: this.sessionId, command, commandName, args: args2 });
|
|
3877
|
-
await this.rpc.commands.handlePendingCommand({ requestId });
|
|
3878
|
-
} catch (error) {
|
|
3879
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
3880
|
-
try {
|
|
3881
|
-
await this.rpc.commands.handlePendingCommand({ requestId, error: message });
|
|
3882
|
-
} catch (rpcError) {
|
|
3883
|
-
if (!(rpcError instanceof import_node.ConnectionError || rpcError instanceof import_node.ResponseError)) {
|
|
3884
|
-
throw rpcError;
|
|
3885
|
-
}
|
|
3886
|
-
}
|
|
3887
|
-
}
|
|
3888
|
-
}
|
|
3889
3711
|
/**
|
|
3890
3712
|
* Registers custom tool handlers for this session.
|
|
3891
3713
|
*
|
|
@@ -3914,133 +3736,6 @@ var init_session = __esm({
|
|
|
3914
3736
|
getToolHandler(name) {
|
|
3915
3737
|
return this.toolHandlers.get(name);
|
|
3916
3738
|
}
|
|
3917
|
-
/**
|
|
3918
|
-
* Registers command handlers for this session.
|
|
3919
|
-
*
|
|
3920
|
-
* @param commands - An array of command definitions with handlers, or undefined to clear
|
|
3921
|
-
* @internal This method is typically called internally when creating/resuming a session.
|
|
3922
|
-
*/
|
|
3923
|
-
registerCommands(commands) {
|
|
3924
|
-
this.commandHandlers.clear();
|
|
3925
|
-
if (!commands) {
|
|
3926
|
-
return;
|
|
3927
|
-
}
|
|
3928
|
-
for (const cmd of commands) {
|
|
3929
|
-
this.commandHandlers.set(cmd.name, cmd.handler);
|
|
3930
|
-
}
|
|
3931
|
-
}
|
|
3932
|
-
/**
|
|
3933
|
-
* Registers the elicitation handler for this session.
|
|
3934
|
-
*
|
|
3935
|
-
* @param handler - The handler to invoke when the server dispatches an elicitation request
|
|
3936
|
-
* @internal This method is typically called internally when creating/resuming a session.
|
|
3937
|
-
*/
|
|
3938
|
-
registerElicitationHandler(handler) {
|
|
3939
|
-
this.elicitationHandler = handler;
|
|
3940
|
-
}
|
|
3941
|
-
/**
|
|
3942
|
-
* Handles an elicitation.requested broadcast event.
|
|
3943
|
-
* Invokes the registered handler and responds via handlePendingElicitation RPC.
|
|
3944
|
-
* @internal
|
|
3945
|
-
*/
|
|
3946
|
-
async _handleElicitationRequest(context, requestId) {
|
|
3947
|
-
if (!this.elicitationHandler) {
|
|
3948
|
-
return;
|
|
3949
|
-
}
|
|
3950
|
-
try {
|
|
3951
|
-
const result = await this.elicitationHandler(context);
|
|
3952
|
-
await this.rpc.ui.handlePendingElicitation({ requestId, result });
|
|
3953
|
-
} catch {
|
|
3954
|
-
try {
|
|
3955
|
-
await this.rpc.ui.handlePendingElicitation({
|
|
3956
|
-
requestId,
|
|
3957
|
-
result: { action: "cancel" }
|
|
3958
|
-
});
|
|
3959
|
-
} catch (rpcError) {
|
|
3960
|
-
if (!(rpcError instanceof import_node.ConnectionError || rpcError instanceof import_node.ResponseError)) {
|
|
3961
|
-
throw rpcError;
|
|
3962
|
-
}
|
|
3963
|
-
}
|
|
3964
|
-
}
|
|
3965
|
-
}
|
|
3966
|
-
/**
|
|
3967
|
-
* Sets the host capabilities for this session.
|
|
3968
|
-
*
|
|
3969
|
-
* @param capabilities - The capabilities object from the create/resume response
|
|
3970
|
-
* @internal This method is typically called internally when creating/resuming a session.
|
|
3971
|
-
*/
|
|
3972
|
-
setCapabilities(capabilities) {
|
|
3973
|
-
this._capabilities = capabilities ?? {};
|
|
3974
|
-
}
|
|
3975
|
-
assertElicitation() {
|
|
3976
|
-
if (!this._capabilities.ui?.elicitation) {
|
|
3977
|
-
throw new Error(
|
|
3978
|
-
"Elicitation is not supported by the host. Check session.capabilities.ui?.elicitation before calling UI methods."
|
|
3979
|
-
);
|
|
3980
|
-
}
|
|
3981
|
-
}
|
|
3982
|
-
async _elicitation(params) {
|
|
3983
|
-
this.assertElicitation();
|
|
3984
|
-
return this.rpc.ui.elicitation({
|
|
3985
|
-
message: params.message,
|
|
3986
|
-
requestedSchema: params.requestedSchema
|
|
3987
|
-
});
|
|
3988
|
-
}
|
|
3989
|
-
async _confirm(message) {
|
|
3990
|
-
this.assertElicitation();
|
|
3991
|
-
const result = await this.rpc.ui.elicitation({
|
|
3992
|
-
message,
|
|
3993
|
-
requestedSchema: {
|
|
3994
|
-
type: "object",
|
|
3995
|
-
properties: {
|
|
3996
|
-
confirmed: { type: "boolean", default: true }
|
|
3997
|
-
},
|
|
3998
|
-
required: ["confirmed"]
|
|
3999
|
-
}
|
|
4000
|
-
});
|
|
4001
|
-
return result.action === "accept" && result.content?.confirmed === true;
|
|
4002
|
-
}
|
|
4003
|
-
async _select(message, options) {
|
|
4004
|
-
this.assertElicitation();
|
|
4005
|
-
const result = await this.rpc.ui.elicitation({
|
|
4006
|
-
message,
|
|
4007
|
-
requestedSchema: {
|
|
4008
|
-
type: "object",
|
|
4009
|
-
properties: {
|
|
4010
|
-
selection: { type: "string", enum: options }
|
|
4011
|
-
},
|
|
4012
|
-
required: ["selection"]
|
|
4013
|
-
}
|
|
4014
|
-
});
|
|
4015
|
-
if (result.action === "accept" && result.content?.selection != null) {
|
|
4016
|
-
return result.content.selection;
|
|
4017
|
-
}
|
|
4018
|
-
return null;
|
|
4019
|
-
}
|
|
4020
|
-
async _input(message, options) {
|
|
4021
|
-
this.assertElicitation();
|
|
4022
|
-
const field = { type: "string" };
|
|
4023
|
-
if (options?.title) field.title = options.title;
|
|
4024
|
-
if (options?.description) field.description = options.description;
|
|
4025
|
-
if (options?.minLength != null) field.minLength = options.minLength;
|
|
4026
|
-
if (options?.maxLength != null) field.maxLength = options.maxLength;
|
|
4027
|
-
if (options?.format) field.format = options.format;
|
|
4028
|
-
if (options?.default != null) field.default = options.default;
|
|
4029
|
-
const result = await this.rpc.ui.elicitation({
|
|
4030
|
-
message,
|
|
4031
|
-
requestedSchema: {
|
|
4032
|
-
type: "object",
|
|
4033
|
-
properties: {
|
|
4034
|
-
value: field
|
|
4035
|
-
},
|
|
4036
|
-
required: ["value"]
|
|
4037
|
-
}
|
|
4038
|
-
});
|
|
4039
|
-
if (result.action === "accept" && result.content?.value != null) {
|
|
4040
|
-
return result.content.value;
|
|
4041
|
-
}
|
|
4042
|
-
return null;
|
|
4043
|
-
}
|
|
4044
3739
|
/**
|
|
4045
3740
|
* Registers a handler for permission requests.
|
|
4046
3741
|
*
|
|
@@ -4385,7 +4080,7 @@ var init_client = __esm({
|
|
|
4385
4080
|
init_session();
|
|
4386
4081
|
init_telemetry();
|
|
4387
4082
|
MIN_PROTOCOL_VERSION = 2;
|
|
4388
|
-
CopilotClient = class
|
|
4083
|
+
CopilotClient = class {
|
|
4389
4084
|
cliProcess = null;
|
|
4390
4085
|
connection = null;
|
|
4391
4086
|
socket = null;
|
|
@@ -4408,8 +4103,6 @@ var init_client = __esm({
|
|
|
4408
4103
|
processExitPromise = null;
|
|
4409
4104
|
// Rejects when CLI process exits
|
|
4410
4105
|
negotiatedProtocolVersion = null;
|
|
4411
|
-
/** Connection-level session filesystem config, set via constructor option. */
|
|
4412
|
-
sessionFsConfig = null;
|
|
4413
4106
|
/**
|
|
4414
4107
|
* Typed server-scoped RPC methods.
|
|
4415
4108
|
* @throws Error if the client is not connected
|
|
@@ -4458,9 +4151,6 @@ var init_client = __esm({
|
|
|
4458
4151
|
"githubToken and useLoggedInUser cannot be used with cliUrl (external server manages its own auth)"
|
|
4459
4152
|
);
|
|
4460
4153
|
}
|
|
4461
|
-
if (options.sessionFs) {
|
|
4462
|
-
this.validateSessionFsConfig(options.sessionFs);
|
|
4463
|
-
}
|
|
4464
4154
|
if (options.cliUrl) {
|
|
4465
4155
|
const { host, port } = this.parseCliUrl(options.cliUrl);
|
|
4466
4156
|
this.actualHost = host;
|
|
@@ -4472,10 +4162,8 @@ var init_client = __esm({
|
|
|
4472
4162
|
}
|
|
4473
4163
|
this.onListModels = options.onListModels;
|
|
4474
4164
|
this.onGetTraceContext = options.onGetTraceContext;
|
|
4475
|
-
this.sessionFsConfig = options.sessionFs ?? null;
|
|
4476
|
-
const effectiveEnv = options.env ?? process.env;
|
|
4477
4165
|
this.options = {
|
|
4478
|
-
cliPath: options.cliUrl ? void 0 : options.cliPath ||
|
|
4166
|
+
cliPath: options.cliUrl ? void 0 : options.cliPath || getBundledCliPath(),
|
|
4479
4167
|
cliArgs: options.cliArgs ?? [],
|
|
4480
4168
|
cwd: options.cwd ?? process.cwd(),
|
|
4481
4169
|
port: options.port || 0,
|
|
@@ -4486,7 +4174,7 @@ var init_client = __esm({
|
|
|
4486
4174
|
logLevel: options.logLevel || "debug",
|
|
4487
4175
|
autoStart: options.autoStart ?? true,
|
|
4488
4176
|
autoRestart: false,
|
|
4489
|
-
env:
|
|
4177
|
+
env: options.env ?? process.env,
|
|
4490
4178
|
githubToken: options.githubToken,
|
|
4491
4179
|
// Default useLoggedInUser to false when githubToken is provided, otherwise true
|
|
4492
4180
|
useLoggedInUser: options.useLoggedInUser ?? (options.githubToken ? false : true),
|
|
@@ -4515,17 +4203,6 @@ var init_client = __esm({
|
|
|
4515
4203
|
}
|
|
4516
4204
|
return { host, port };
|
|
4517
4205
|
}
|
|
4518
|
-
validateSessionFsConfig(config) {
|
|
4519
|
-
if (!config.initialCwd) {
|
|
4520
|
-
throw new Error("sessionFs.initialCwd is required");
|
|
4521
|
-
}
|
|
4522
|
-
if (!config.sessionStatePath) {
|
|
4523
|
-
throw new Error("sessionFs.sessionStatePath is required");
|
|
4524
|
-
}
|
|
4525
|
-
if (config.conventions !== "windows" && config.conventions !== "posix") {
|
|
4526
|
-
throw new Error("sessionFs.conventions must be either 'windows' or 'posix'");
|
|
4527
|
-
}
|
|
4528
|
-
}
|
|
4529
4206
|
/**
|
|
4530
4207
|
* Starts the CLI server and establishes a connection.
|
|
4531
4208
|
*
|
|
@@ -4555,13 +4232,6 @@ var init_client = __esm({
|
|
|
4555
4232
|
}
|
|
4556
4233
|
await this.connectToServer();
|
|
4557
4234
|
await this.verifyProtocolVersion();
|
|
4558
|
-
if (this.sessionFsConfig) {
|
|
4559
|
-
await this.connection.sendRequest("sessionFs.setProvider", {
|
|
4560
|
-
initialCwd: this.sessionFsConfig.initialCwd,
|
|
4561
|
-
sessionStatePath: this.sessionFsConfig.sessionStatePath,
|
|
4562
|
-
conventions: this.sessionFsConfig.conventions
|
|
4563
|
-
});
|
|
4564
|
-
}
|
|
4565
4235
|
this.state = "connected";
|
|
4566
4236
|
} catch (error) {
|
|
4567
4237
|
this.state = "error";
|
|
@@ -4768,14 +4438,10 @@ var init_client = __esm({
|
|
|
4768
4438
|
this.onGetTraceContext
|
|
4769
4439
|
);
|
|
4770
4440
|
session.registerTools(config.tools);
|
|
4771
|
-
session.registerCommands(config.commands);
|
|
4772
4441
|
session.registerPermissionHandler(config.onPermissionRequest);
|
|
4773
4442
|
if (config.onUserInputRequest) {
|
|
4774
4443
|
session.registerUserInputHandler(config.onUserInputRequest);
|
|
4775
4444
|
}
|
|
4776
|
-
if (config.onElicitationRequest) {
|
|
4777
|
-
session.registerElicitationHandler(config.onElicitationRequest);
|
|
4778
|
-
}
|
|
4779
4445
|
if (config.hooks) {
|
|
4780
4446
|
session.registerHooks(config.hooks);
|
|
4781
4447
|
}
|
|
@@ -4789,15 +4455,6 @@ var init_client = __esm({
|
|
|
4789
4455
|
session.on(config.onEvent);
|
|
4790
4456
|
}
|
|
4791
4457
|
this.sessions.set(sessionId, session);
|
|
4792
|
-
if (this.sessionFsConfig) {
|
|
4793
|
-
if (config.createSessionFsHandler) {
|
|
4794
|
-
session.clientSessionApis.sessionFs = config.createSessionFsHandler(session);
|
|
4795
|
-
} else {
|
|
4796
|
-
throw new Error(
|
|
4797
|
-
"createSessionFsHandler is required in session config when sessionFs is enabled in client options."
|
|
4798
|
-
);
|
|
4799
|
-
}
|
|
4800
|
-
}
|
|
4801
4458
|
try {
|
|
4802
4459
|
const response = await this.connection.sendRequest("session.create", {
|
|
4803
4460
|
...await getTraceContext(this.onGetTraceContext),
|
|
@@ -4812,18 +4469,12 @@ var init_client = __esm({
|
|
|
4812
4469
|
overridesBuiltInTool: tool.overridesBuiltInTool,
|
|
4813
4470
|
skipPermission: tool.skipPermission
|
|
4814
4471
|
})),
|
|
4815
|
-
commands: config.commands?.map((cmd) => ({
|
|
4816
|
-
name: cmd.name,
|
|
4817
|
-
description: cmd.description
|
|
4818
|
-
})),
|
|
4819
4472
|
systemMessage: wireSystemMessage,
|
|
4820
4473
|
availableTools: config.availableTools,
|
|
4821
4474
|
excludedTools: config.excludedTools,
|
|
4822
4475
|
provider: config.provider,
|
|
4823
|
-
modelCapabilities: config.modelCapabilities,
|
|
4824
4476
|
requestPermission: true,
|
|
4825
4477
|
requestUserInput: !!config.onUserInputRequest,
|
|
4826
|
-
requestElicitation: !!config.onElicitationRequest,
|
|
4827
4478
|
hooks: !!(config.hooks && Object.values(config.hooks).some(Boolean)),
|
|
4828
4479
|
workingDirectory: config.workingDirectory,
|
|
4829
4480
|
streaming: config.streaming,
|
|
@@ -4832,14 +4483,12 @@ var init_client = __esm({
|
|
|
4832
4483
|
customAgents: config.customAgents,
|
|
4833
4484
|
agent: config.agent,
|
|
4834
4485
|
configDir: config.configDir,
|
|
4835
|
-
enableConfigDiscovery: config.enableConfigDiscovery,
|
|
4836
4486
|
skillDirectories: config.skillDirectories,
|
|
4837
4487
|
disabledSkills: config.disabledSkills,
|
|
4838
4488
|
infiniteSessions: config.infiniteSessions
|
|
4839
4489
|
});
|
|
4840
|
-
const { workspacePath
|
|
4490
|
+
const { workspacePath } = response;
|
|
4841
4491
|
session["_workspacePath"] = workspacePath;
|
|
4842
|
-
session.setCapabilities(capabilities);
|
|
4843
4492
|
} catch (e) {
|
|
4844
4493
|
this.sessions.delete(sessionId);
|
|
4845
4494
|
throw e;
|
|
@@ -4890,14 +4539,10 @@ var init_client = __esm({
|
|
|
4890
4539
|
this.onGetTraceContext
|
|
4891
4540
|
);
|
|
4892
4541
|
session.registerTools(config.tools);
|
|
4893
|
-
session.registerCommands(config.commands);
|
|
4894
4542
|
session.registerPermissionHandler(config.onPermissionRequest);
|
|
4895
4543
|
if (config.onUserInputRequest) {
|
|
4896
4544
|
session.registerUserInputHandler(config.onUserInputRequest);
|
|
4897
4545
|
}
|
|
4898
|
-
if (config.onElicitationRequest) {
|
|
4899
|
-
session.registerElicitationHandler(config.onElicitationRequest);
|
|
4900
|
-
}
|
|
4901
4546
|
if (config.hooks) {
|
|
4902
4547
|
session.registerHooks(config.hooks);
|
|
4903
4548
|
}
|
|
@@ -4911,15 +4556,6 @@ var init_client = __esm({
|
|
|
4911
4556
|
session.on(config.onEvent);
|
|
4912
4557
|
}
|
|
4913
4558
|
this.sessions.set(sessionId, session);
|
|
4914
|
-
if (this.sessionFsConfig) {
|
|
4915
|
-
if (config.createSessionFsHandler) {
|
|
4916
|
-
session.clientSessionApis.sessionFs = config.createSessionFsHandler(session);
|
|
4917
|
-
} else {
|
|
4918
|
-
throw new Error(
|
|
4919
|
-
"createSessionFsHandler is required in session config when sessionFs is enabled in client options."
|
|
4920
|
-
);
|
|
4921
|
-
}
|
|
4922
|
-
}
|
|
4923
4559
|
try {
|
|
4924
4560
|
const response = await this.connection.sendRequest("session.resume", {
|
|
4925
4561
|
...await getTraceContext(this.onGetTraceContext),
|
|
@@ -4937,19 +4573,12 @@ var init_client = __esm({
|
|
|
4937
4573
|
overridesBuiltInTool: tool.overridesBuiltInTool,
|
|
4938
4574
|
skipPermission: tool.skipPermission
|
|
4939
4575
|
})),
|
|
4940
|
-
commands: config.commands?.map((cmd) => ({
|
|
4941
|
-
name: cmd.name,
|
|
4942
|
-
description: cmd.description
|
|
4943
|
-
})),
|
|
4944
4576
|
provider: config.provider,
|
|
4945
|
-
modelCapabilities: config.modelCapabilities,
|
|
4946
4577
|
requestPermission: true,
|
|
4947
4578
|
requestUserInput: !!config.onUserInputRequest,
|
|
4948
|
-
requestElicitation: !!config.onElicitationRequest,
|
|
4949
4579
|
hooks: !!(config.hooks && Object.values(config.hooks).some(Boolean)),
|
|
4950
4580
|
workingDirectory: config.workingDirectory,
|
|
4951
4581
|
configDir: config.configDir,
|
|
4952
|
-
enableConfigDiscovery: config.enableConfigDiscovery,
|
|
4953
4582
|
streaming: config.streaming,
|
|
4954
4583
|
mcpServers: config.mcpServers,
|
|
4955
4584
|
envValueMode: "direct",
|
|
@@ -4960,9 +4589,8 @@ var init_client = __esm({
|
|
|
4960
4589
|
infiniteSessions: config.infiniteSessions,
|
|
4961
4590
|
disableResume: config.disableResume
|
|
4962
4591
|
});
|
|
4963
|
-
const { workspacePath
|
|
4592
|
+
const { workspacePath } = response;
|
|
4964
4593
|
session["_workspacePath"] = workspacePath;
|
|
4965
|
-
session.setCapabilities(capabilities);
|
|
4966
4594
|
} catch (e) {
|
|
4967
4595
|
this.sessions.delete(sessionId);
|
|
4968
4596
|
throw e;
|
|
@@ -5158,50 +4786,16 @@ var init_client = __esm({
|
|
|
5158
4786
|
if (!this.connection) {
|
|
5159
4787
|
throw new Error("Client not connected");
|
|
5160
4788
|
}
|
|
5161
|
-
const response = await this.connection.sendRequest("session.list", {
|
|
5162
|
-
filter
|
|
5163
|
-
});
|
|
4789
|
+
const response = await this.connection.sendRequest("session.list", { filter });
|
|
5164
4790
|
const { sessions } = response;
|
|
5165
|
-
return sessions.map(
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
* @param sessionId - The ID of the session to look up
|
|
5174
|
-
* @returns A promise that resolves with the session metadata, or undefined if not found
|
|
5175
|
-
* @throws Error if the client is not connected
|
|
5176
|
-
*
|
|
5177
|
-
* @example
|
|
5178
|
-
* ```typescript
|
|
5179
|
-
* const metadata = await client.getSessionMetadata("session-123");
|
|
5180
|
-
* if (metadata) {
|
|
5181
|
-
* console.log(`Session started at: ${metadata.startTime}`);
|
|
5182
|
-
* }
|
|
5183
|
-
* ```
|
|
5184
|
-
*/
|
|
5185
|
-
async getSessionMetadata(sessionId) {
|
|
5186
|
-
if (!this.connection) {
|
|
5187
|
-
throw new Error("Client not connected");
|
|
5188
|
-
}
|
|
5189
|
-
const response = await this.connection.sendRequest("session.getMetadata", { sessionId });
|
|
5190
|
-
const { session } = response;
|
|
5191
|
-
if (!session) {
|
|
5192
|
-
return void 0;
|
|
5193
|
-
}
|
|
5194
|
-
return _CopilotClient.toSessionMetadata(session);
|
|
5195
|
-
}
|
|
5196
|
-
static toSessionMetadata(raw) {
|
|
5197
|
-
return {
|
|
5198
|
-
sessionId: raw.sessionId,
|
|
5199
|
-
startTime: new Date(raw.startTime),
|
|
5200
|
-
modifiedTime: new Date(raw.modifiedTime),
|
|
5201
|
-
summary: raw.summary,
|
|
5202
|
-
isRemote: raw.isRemote,
|
|
5203
|
-
context: raw.context
|
|
5204
|
-
};
|
|
4791
|
+
return sessions.map((s) => ({
|
|
4792
|
+
sessionId: s.sessionId,
|
|
4793
|
+
startTime: new Date(s.startTime),
|
|
4794
|
+
modifiedTime: new Date(s.modifiedTime),
|
|
4795
|
+
summary: s.summary,
|
|
4796
|
+
isRemote: s.isRemote,
|
|
4797
|
+
context: s.context
|
|
4798
|
+
}));
|
|
5205
4799
|
}
|
|
5206
4800
|
/**
|
|
5207
4801
|
* Gets the foreground session ID in TUI+server mode.
|
|
@@ -5531,12 +5125,6 @@ stderr: ${stderrOutput}`
|
|
|
5531
5125
|
"systemMessage.transform",
|
|
5532
5126
|
async (params) => await this.handleSystemMessageTransform(params)
|
|
5533
5127
|
);
|
|
5534
|
-
const sessions = this.sessions;
|
|
5535
|
-
registerClientSessionApiHandlers(this.connection, (sessionId) => {
|
|
5536
|
-
const session = sessions.get(sessionId);
|
|
5537
|
-
if (!session) throw new Error(`No session found for sessionId: ${sessionId}`);
|
|
5538
|
-
return session.clientSessionApis;
|
|
5539
|
-
});
|
|
5540
5128
|
this.connection.onClose(() => {
|
|
5541
5129
|
this.state = "disconnected";
|
|
5542
5130
|
});
|
|
@@ -7736,10 +7324,8 @@ async function assertCopilotCliReady() {
|
|
|
7736
7324
|
const desc = config.cliArgs ? `${config.cliPath} ${config.cliArgs.join(" ")}` : config.cliPath;
|
|
7737
7325
|
logCopilotDebug(`validating CLI compatibility with ${desc}`);
|
|
7738
7326
|
try {
|
|
7739
|
-
const isNpx = config.cliArgs?.includes("@github/copilot") ?? false;
|
|
7740
|
-
const timeout = isNpx ? 3e4 : 5e3;
|
|
7741
7327
|
const [cmd, args2] = buildExecArgs(config, ["--headless", "--version"]);
|
|
7742
|
-
await execFileAsync2(cmd, args2, { timeout });
|
|
7328
|
+
await execFileAsync2(cmd, args2, { timeout: 5e3 });
|
|
7743
7329
|
} catch {
|
|
7744
7330
|
cachedCliConfig = null;
|
|
7745
7331
|
throw new Error(
|
|
@@ -7839,18 +7425,6 @@ async function findCopilotCliConfig() {
|
|
|
7839
7425
|
}
|
|
7840
7426
|
} catch {
|
|
7841
7427
|
}
|
|
7842
|
-
try {
|
|
7843
|
-
const { stdout } = await execFileAsync2(whichCmd, ["npx"], { timeout: 5e3 });
|
|
7844
|
-
const npxPath = stdout.trim().split(/\r?\n/)[0];
|
|
7845
|
-
if (npxPath) {
|
|
7846
|
-
candidates.push({
|
|
7847
|
-
config: { cliPath: npxPath, cliArgs: ["--yes", "@github/copilot"] },
|
|
7848
|
-
source: "npx @github/copilot"
|
|
7849
|
-
});
|
|
7850
|
-
logCopilotDebug(`discovered candidate from npx: ${npxPath} --yes @github/copilot`);
|
|
7851
|
-
}
|
|
7852
|
-
} catch {
|
|
7853
|
-
}
|
|
7854
7428
|
const staticLocations = [];
|
|
7855
7429
|
if (process.platform === "darwin") {
|
|
7856
7430
|
staticLocations.push(
|
|
@@ -7932,11 +7506,9 @@ async function findFirstCompatibleCandidate(candidates) {
|
|
|
7932
7506
|
return null;
|
|
7933
7507
|
}
|
|
7934
7508
|
async function isHeadlessCompatible(config) {
|
|
7935
|
-
const isNpx = config.cliArgs?.includes("@github/copilot") ?? false;
|
|
7936
|
-
const timeout = isNpx ? 3e4 : 5e3;
|
|
7937
7509
|
try {
|
|
7938
7510
|
const [cmd, args2] = buildExecArgs(config, ["--headless", "--version"]);
|
|
7939
|
-
await execFileAsync2(cmd, args2, { timeout });
|
|
7511
|
+
await execFileAsync2(cmd, args2, { timeout: 5e3 });
|
|
7940
7512
|
return true;
|
|
7941
7513
|
} catch {
|
|
7942
7514
|
return false;
|
|
@@ -8018,6 +7590,8 @@ async function startExternalServer(cliConfig) {
|
|
|
8018
7590
|
clearTimeout(timer);
|
|
8019
7591
|
cliProcess.stdout?.removeAllListeners("data");
|
|
8020
7592
|
cliProcess.stderr?.removeAllListeners("data");
|
|
7593
|
+
cliProcess.stdout?.resume();
|
|
7594
|
+
cliProcess.stderr?.resume();
|
|
8021
7595
|
resolve({
|
|
8022
7596
|
cliProcess,
|
|
8023
7597
|
cliUrl: `localhost:${port}`
|
|
@@ -8037,8 +7611,7 @@ async function startExternalServer(cliConfig) {
|
|
|
8037
7611
|
const lines = chunk.split("\n");
|
|
8038
7612
|
for (const line of lines) {
|
|
8039
7613
|
if (line.trim()) {
|
|
8040
|
-
|
|
8041
|
-
`);
|
|
7614
|
+
logCopilotDebug(`CLI subprocess: ${line}`);
|
|
8042
7615
|
}
|
|
8043
7616
|
}
|
|
8044
7617
|
});
|
|
@@ -8061,11 +7634,11 @@ ${details}` : `External CLI server exited with code ${code}`
|
|
|
8061
7634
|
});
|
|
8062
7635
|
}
|
|
8063
7636
|
function attachDefaultPermissionHandler(client) {
|
|
8064
|
-
const
|
|
7637
|
+
const readOnly = (request) => request.kind === "read" ? { kind: "approved" } : { kind: "denied-no-approval-rule-and-could-not-request-from-user" };
|
|
8065
7638
|
const originalCreateSession = client.createSession.bind(client);
|
|
8066
7639
|
client.createSession = (config) => originalCreateSession({
|
|
8067
7640
|
...config,
|
|
8068
|
-
onPermissionRequest: config.onPermissionRequest ??
|
|
7641
|
+
onPermissionRequest: config.onPermissionRequest ?? readOnly
|
|
8069
7642
|
});
|
|
8070
7643
|
}
|
|
8071
7644
|
function killProcessTree(cliProcess) {
|
|
@@ -8086,9 +7659,11 @@ function killProcessTree(cliProcess) {
|
|
|
8086
7659
|
function attachExternalServerCleanup(client, cliProcess) {
|
|
8087
7660
|
const originalStop = client.stop.bind(client);
|
|
8088
7661
|
client.stop = (async () => {
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
7662
|
+
try {
|
|
7663
|
+
return await originalStop();
|
|
7664
|
+
} finally {
|
|
7665
|
+
killProcessTree(cliProcess);
|
|
7666
|
+
}
|
|
8092
7667
|
});
|
|
8093
7668
|
}
|
|
8094
7669
|
async function loadCopilotSdk() {
|
|
@@ -8141,9 +7716,7 @@ async function createCopilotClient(cliConfig) {
|
|
|
8141
7716
|
try {
|
|
8142
7717
|
await fallbackClient.start();
|
|
8143
7718
|
} catch (fallbackError) {
|
|
8144
|
-
|
|
8145
|
-
external.cliProcess.kill();
|
|
8146
|
-
}
|
|
7719
|
+
killProcessTree(external.cliProcess);
|
|
8147
7720
|
throw normalizeError(fallbackError);
|
|
8148
7721
|
}
|
|
8149
7722
|
attachExternalServerCleanup(fallbackClient, external.cliProcess);
|
|
@@ -8255,6 +7828,31 @@ function buildExistingInstructionsSection(ctx) {
|
|
|
8255
7828
|
];
|
|
8256
7829
|
return lines.join("\n");
|
|
8257
7830
|
}
|
|
7831
|
+
function buildRootContextSection(rootContent) {
|
|
7832
|
+
const trimmed = rootContent?.trim();
|
|
7833
|
+
if (!trimmed) return "";
|
|
7834
|
+
return [
|
|
7835
|
+
"",
|
|
7836
|
+
"## Root instructions already cover",
|
|
7837
|
+
"The root instruction file already covers the following workspace-wide content. Do NOT repeat or restate it in this file; cover only this area/crate's unique details:",
|
|
7838
|
+
"",
|
|
7839
|
+
trimmed,
|
|
7840
|
+
""
|
|
7841
|
+
].join("\n");
|
|
7842
|
+
}
|
|
7843
|
+
function normalizeAgentsHeading(content, componentName) {
|
|
7844
|
+
const headingRe = /^(?:\uFEFF)?#\s+Copilot Instructions(?:\s*:\s*(.*))?\s*$/iu;
|
|
7845
|
+
const firstLineEnd = content.indexOf("\n");
|
|
7846
|
+
const firstLine = (firstLineEnd === -1 ? content : content.slice(0, firstLineEnd)).trimEnd();
|
|
7847
|
+
const match = headingRe.exec(firstLine);
|
|
7848
|
+
if (!match) return content;
|
|
7849
|
+
const fallback = match[1]?.trim();
|
|
7850
|
+
const heading = componentName?.trim() || fallback;
|
|
7851
|
+
if (!heading) return content;
|
|
7852
|
+
const replacedFirstLine = firstLine.replace(headingRe, `# ${heading}`);
|
|
7853
|
+
return firstLineEnd === -1 ? replacedFirstLine : `${replacedFirstLine}
|
|
7854
|
+
${content.slice(firstLineEnd + 1)}`;
|
|
7855
|
+
}
|
|
8258
7856
|
function stripMarkdownFences(content) {
|
|
8259
7857
|
const trimmed = content.trim();
|
|
8260
7858
|
const fenceRe = /^```(?:markdown|md)?[ \t]*\n([\s\S]*?)\n```[ \t]*$/;
|
|
@@ -8646,12 +8244,13 @@ ${options.childAreas.map((c) => `- ${c.name} (${c.path ?? "unknown path"})`).joi
|
|
|
8646
8244
|
Include a "## Sub-Projects" section with links to each child's AGENTS.md.` : "";
|
|
8647
8245
|
const parentContext = options.area?.parentArea ? `
|
|
8648
8246
|
This is a sub-project of "${options.area.parentArea}". Include a note linking back to the parent area.` : "";
|
|
8247
|
+
const rootContextSection = buildRootContextSection(options.rootContent);
|
|
8649
8248
|
const prompt = `/nested-hub Generate a lean AGENTS.md hub file (~90-120 lines).${areaContext}${parentContext}
|
|
8650
8249
|
|
|
8651
8250
|
Detail files go in \`${options.detailDir}/\`.${childContext}
|
|
8652
8251
|
|
|
8653
8252
|
Recommend 3-5 topics for deep-dive detail files. Each slug becomes: \`${options.detailDir}/{slug}.md\`.
|
|
8654
|
-
${existingSection ? `
|
|
8253
|
+
${rootContextSection}${existingSection ? `
|
|
8655
8254
|
Do NOT duplicate content from existing instruction files
|
|
8656
8255
|
${existingSection}` : ""}`;
|
|
8657
8256
|
let sendError;
|
|
@@ -8711,8 +8310,9 @@ async function generateNestedDetail(client, options) {
|
|
|
8711
8310
|
}
|
|
8712
8311
|
});
|
|
8713
8312
|
const areaContext = options.area ? `Focus on the "${options.area.name}" area (files matching: ${Array.isArray(options.area.applyTo) ? options.area.applyTo.join(", ") : options.area.applyTo}).` : "Focus on the entire repository.";
|
|
8313
|
+
const rootContextSection = buildRootContextSection(options.rootContent);
|
|
8714
8314
|
const prompt = `/nested-detail Generate a deep-dive instruction file about "${options.topic.title}" for this codebase.
|
|
8715
|
-
${areaContext}
|
|
8315
|
+
${areaContext}${rootContextSection}
|
|
8716
8316
|
|
|
8717
8317
|
Topic: ${options.topic.title}
|
|
8718
8318
|
Description: ${options.topic.description}`;
|
|
@@ -8747,15 +8347,18 @@ async function generateNestedInstructions(options) {
|
|
|
8747
8347
|
area: options.area,
|
|
8748
8348
|
childAreas: options.childAreas,
|
|
8749
8349
|
model: options.model,
|
|
8750
|
-
onProgress: options.onProgress
|
|
8350
|
+
onProgress: options.onProgress,
|
|
8351
|
+
rootContent: options.rootContent
|
|
8751
8352
|
});
|
|
8752
8353
|
const basePath = options.area?.path ?? ".";
|
|
8753
8354
|
const hubRelativePath = path7.join(basePath, "AGENTS.md");
|
|
8754
|
-
|
|
8355
|
+
const componentName = options.area?.name ?? path7.basename(options.repoPath);
|
|
8356
|
+
const normalizedHubContent = normalizeAgentsHeading(hubContent, componentName);
|
|
8357
|
+
let finalHubContent = normalizedHubContent;
|
|
8755
8358
|
if (options.area) {
|
|
8756
8359
|
finalHubContent = `${buildAreaFrontmatter(options.area)}
|
|
8757
8360
|
|
|
8758
|
-
${
|
|
8361
|
+
${normalizedHubContent}`;
|
|
8759
8362
|
}
|
|
8760
8363
|
const result = {
|
|
8761
8364
|
hub: { relativePath: hubRelativePath, content: finalHubContent },
|
|
@@ -8770,7 +8373,8 @@ ${hubContent}`;
|
|
|
8770
8373
|
topic,
|
|
8771
8374
|
area: options.area,
|
|
8772
8375
|
model: options.model,
|
|
8773
|
-
onProgress: options.onProgress
|
|
8376
|
+
onProgress: options.onProgress,
|
|
8377
|
+
rootContent: options.rootContent
|
|
8774
8378
|
});
|
|
8775
8379
|
if (detailContent) {
|
|
8776
8380
|
result.details.push({
|
|
@@ -8806,7 +8410,8 @@ async function generateNestedAreaInstructions(options) {
|
|
|
8806
8410
|
model: options.model,
|
|
8807
8411
|
onProgress: options.onProgress,
|
|
8808
8412
|
detailDir: options.detailDir,
|
|
8809
|
-
claudeMd: options.claudeMd
|
|
8413
|
+
claudeMd: options.claudeMd,
|
|
8414
|
+
rootContent: options.rootContent
|
|
8810
8415
|
});
|
|
8811
8416
|
}
|
|
8812
8417
|
|
|
@@ -9607,6 +9212,24 @@ function wrapImperativePolicy(config, baseCriteria) {
|
|
|
9607
9212
|
// packages/core/src/services/readiness/checkers.ts
|
|
9608
9213
|
import fs7 from "fs/promises";
|
|
9609
9214
|
import path9 from "path";
|
|
9215
|
+
import fg3 from "fast-glob";
|
|
9216
|
+
var AGENT_PLUGINS_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json";
|
|
9217
|
+
var AGENT_PLUGIN_NAME_PATTERN = /^(?!.*(?:--|\.\.))[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?$/u;
|
|
9218
|
+
var AGENT_PLUGIN_SCAN_IGNORES = [
|
|
9219
|
+
"**/.git/**",
|
|
9220
|
+
"**/.agentrc-cache/**",
|
|
9221
|
+
"**/.primer-cache/**",
|
|
9222
|
+
"**/coverage/**",
|
|
9223
|
+
"**/dist/**",
|
|
9224
|
+
"**/node_modules/**",
|
|
9225
|
+
"**/out/**"
|
|
9226
|
+
];
|
|
9227
|
+
var COPILOT_REPO_SETTINGS_FILES = [
|
|
9228
|
+
".claude/settings.json",
|
|
9229
|
+
".claude/settings.local.json",
|
|
9230
|
+
".github/copilot/settings.json",
|
|
9231
|
+
".github/copilot/settings.local.json"
|
|
9232
|
+
];
|
|
9610
9233
|
function hasAnyFile(files, candidates) {
|
|
9611
9234
|
return candidates.some((candidate) => files.includes(candidate));
|
|
9612
9235
|
}
|
|
@@ -9775,6 +9398,7 @@ async function hasCustomInstructions(repoPath) {
|
|
|
9775
9398
|
"CLAUDE.md",
|
|
9776
9399
|
".claude/CLAUDE.md",
|
|
9777
9400
|
"AGENTS.md",
|
|
9401
|
+
"GEMINI.md",
|
|
9778
9402
|
".github/AGENTS.md",
|
|
9779
9403
|
".cursorrules",
|
|
9780
9404
|
".cursorignore",
|
|
@@ -9789,26 +9413,53 @@ async function hasCustomInstructions(repoPath) {
|
|
|
9789
9413
|
}
|
|
9790
9414
|
return found;
|
|
9791
9415
|
}
|
|
9792
|
-
async function
|
|
9416
|
+
async function hasAgentPluginInstructions(repoPath) {
|
|
9417
|
+
const pluginComponents = await discoverAgentPluginComponents(repoPath);
|
|
9418
|
+
return [...new Set(pluginComponents.instructions)];
|
|
9419
|
+
}
|
|
9420
|
+
async function hasNestedCopilotInstructions(repoPath) {
|
|
9421
|
+
const matches = await fg3(
|
|
9422
|
+
["**/.github/copilot-instructions.md", "**/AGENTS.md", "**/CLAUDE.md", "**/GEMINI.md"],
|
|
9423
|
+
{
|
|
9424
|
+
cwd: repoPath,
|
|
9425
|
+
onlyFiles: true,
|
|
9426
|
+
dot: true,
|
|
9427
|
+
followSymbolicLinks: false,
|
|
9428
|
+
ignore: AGENT_PLUGIN_SCAN_IGNORES,
|
|
9429
|
+
unique: true
|
|
9430
|
+
}
|
|
9431
|
+
);
|
|
9432
|
+
return matches.map((entry) => entry.replace(/\\/gu, "/")).sort();
|
|
9433
|
+
}
|
|
9434
|
+
async function hasCopilotPluginSetting(repoPath, key) {
|
|
9793
9435
|
const found = [];
|
|
9794
|
-
const
|
|
9795
|
-
|
|
9796
|
-
const
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
|
|
9800
|
-
|
|
9436
|
+
for (const settingsPath of COPILOT_REPO_SETTINGS_FILES) {
|
|
9437
|
+
const settings = await readJson(path9.join(repoPath, settingsPath));
|
|
9438
|
+
const value = settings?.[key];
|
|
9439
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
9440
|
+
continue;
|
|
9441
|
+
}
|
|
9442
|
+
const entries = Object.values(value);
|
|
9443
|
+
const configured = key === "enabledPlugins" ? entries.some((entry) => entry === true) : entries.length > 0;
|
|
9444
|
+
if (configured) {
|
|
9445
|
+
found.push(`${settingsPath} (${key})`);
|
|
9446
|
+
}
|
|
9801
9447
|
}
|
|
9802
|
-
|
|
9803
|
-
|
|
9448
|
+
return found;
|
|
9449
|
+
}
|
|
9450
|
+
async function hasFileBasedInstructions(repoPath, extraDirs) {
|
|
9451
|
+
const found = [];
|
|
9452
|
+
const instructionDirs = [".github/instructions", ...extraDirs ?? []];
|
|
9453
|
+
for (const dir of instructionDirs) {
|
|
9804
9454
|
const normalizedDir = dir.replace(/\\/gu, "/").replace(/\/+$/u, "");
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
}
|
|
9455
|
+
const entries = await fg3("**/*.instructions.md", {
|
|
9456
|
+
cwd: path9.join(repoPath, dir),
|
|
9457
|
+
onlyFiles: true,
|
|
9458
|
+
dot: true,
|
|
9459
|
+
followSymbolicLinks: false,
|
|
9460
|
+
suppressErrors: true
|
|
9461
|
+
});
|
|
9462
|
+
found.push(...entries.map((entry) => `${normalizedDir}/${entry.replace(/\\/gu, "/")}`));
|
|
9812
9463
|
}
|
|
9813
9464
|
return [...new Set(found)];
|
|
9814
9465
|
}
|
|
@@ -9866,11 +9517,136 @@ async function checkInstructionConsistency(repoPath, foundFiles) {
|
|
|
9866
9517
|
similarity: Math.round(minSimilarity * 100) / 100
|
|
9867
9518
|
};
|
|
9868
9519
|
}
|
|
9520
|
+
function isAgentPluginsManifest(value) {
|
|
9521
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
9522
|
+
return false;
|
|
9523
|
+
}
|
|
9524
|
+
const manifest = value;
|
|
9525
|
+
const name = manifest.name;
|
|
9526
|
+
return manifest.$schema === AGENT_PLUGINS_SCHEMA && typeof name === "string" && name.length <= 64 && AGENT_PLUGIN_NAME_PATTERN.test(name);
|
|
9527
|
+
}
|
|
9528
|
+
function isUnavailablePathError(error) {
|
|
9529
|
+
const code = error.code;
|
|
9530
|
+
return code === "ENOENT" || code === "ENOTDIR" || code === "ELOOP";
|
|
9531
|
+
}
|
|
9532
|
+
async function isRegularFile(filePath) {
|
|
9533
|
+
try {
|
|
9534
|
+
return (await fs7.lstat(filePath)).isFile();
|
|
9535
|
+
} catch (error) {
|
|
9536
|
+
if (isUnavailablePathError(error)) {
|
|
9537
|
+
return false;
|
|
9538
|
+
}
|
|
9539
|
+
throw error;
|
|
9540
|
+
}
|
|
9541
|
+
}
|
|
9542
|
+
async function hasAgentPluginSkills(skillsDir) {
|
|
9543
|
+
try {
|
|
9544
|
+
if (!(await fs7.lstat(skillsDir)).isDirectory()) {
|
|
9545
|
+
return false;
|
|
9546
|
+
}
|
|
9547
|
+
const entries = await fs7.readdir(skillsDir, { withFileTypes: true });
|
|
9548
|
+
for (const entry of entries) {
|
|
9549
|
+
if (entry.isDirectory() && await isRegularFile(path9.join(skillsDir, entry.name, "SKILL.md"))) {
|
|
9550
|
+
return true;
|
|
9551
|
+
}
|
|
9552
|
+
}
|
|
9553
|
+
return false;
|
|
9554
|
+
} catch (error) {
|
|
9555
|
+
if (isUnavailablePathError(error)) {
|
|
9556
|
+
return false;
|
|
9557
|
+
}
|
|
9558
|
+
throw error;
|
|
9559
|
+
}
|
|
9560
|
+
}
|
|
9561
|
+
async function hasMarkdownFiles(directory) {
|
|
9562
|
+
const files = await fg3("**/*.md", {
|
|
9563
|
+
cwd: directory,
|
|
9564
|
+
onlyFiles: true,
|
|
9565
|
+
dot: true,
|
|
9566
|
+
followSymbolicLinks: false,
|
|
9567
|
+
suppressErrors: true
|
|
9568
|
+
});
|
|
9569
|
+
return files.length > 0;
|
|
9570
|
+
}
|
|
9571
|
+
function relativeEvidencePath(repoPath, absolutePath) {
|
|
9572
|
+
return path9.relative(repoPath, absolutePath).replace(/\\/gu, "/");
|
|
9573
|
+
}
|
|
9574
|
+
function resolveAgentPluginRoot(manifestPath) {
|
|
9575
|
+
const manifestDir = path9.dirname(manifestPath);
|
|
9576
|
+
const manifestDirName = path9.basename(manifestDir);
|
|
9577
|
+
if (manifestDirName === ".plugin" || manifestDirName === ".claude-plugin") {
|
|
9578
|
+
return path9.dirname(manifestDir);
|
|
9579
|
+
}
|
|
9580
|
+
if (manifestDirName === "plugin" && path9.basename(path9.dirname(manifestDir)) === ".github") {
|
|
9581
|
+
return path9.dirname(path9.dirname(manifestDir));
|
|
9582
|
+
}
|
|
9583
|
+
return manifestDir;
|
|
9584
|
+
}
|
|
9585
|
+
async function discoverAgentPluginComponents(repoPath) {
|
|
9586
|
+
const manifestPaths = await fg3(["plugin.json", "**/plugin.json"], {
|
|
9587
|
+
cwd: repoPath,
|
|
9588
|
+
absolute: true,
|
|
9589
|
+
onlyFiles: true,
|
|
9590
|
+
dot: true,
|
|
9591
|
+
followSymbolicLinks: false,
|
|
9592
|
+
ignore: AGENT_PLUGIN_SCAN_IGNORES,
|
|
9593
|
+
unique: true
|
|
9594
|
+
});
|
|
9595
|
+
const components = {
|
|
9596
|
+
agents: [],
|
|
9597
|
+
instructions: [],
|
|
9598
|
+
skills: [],
|
|
9599
|
+
mcp: []
|
|
9600
|
+
};
|
|
9601
|
+
for (const manifestPath of manifestPaths.sort()) {
|
|
9602
|
+
let rawManifest;
|
|
9603
|
+
try {
|
|
9604
|
+
rawManifest = JSON.parse(await fs7.readFile(manifestPath, "utf8"));
|
|
9605
|
+
} catch (error) {
|
|
9606
|
+
if (error instanceof SyntaxError || isUnavailablePathError(error)) {
|
|
9607
|
+
continue;
|
|
9608
|
+
}
|
|
9609
|
+
throw error;
|
|
9610
|
+
}
|
|
9611
|
+
if (!isAgentPluginsManifest(rawManifest)) {
|
|
9612
|
+
continue;
|
|
9613
|
+
}
|
|
9614
|
+
const pluginRoot = resolveAgentPluginRoot(manifestPath);
|
|
9615
|
+
const skillsDir = path9.join(pluginRoot, "skills");
|
|
9616
|
+
if (await hasAgentPluginSkills(skillsDir)) {
|
|
9617
|
+
components.skills.push(relativeEvidencePath(repoPath, skillsDir));
|
|
9618
|
+
}
|
|
9619
|
+
const mcpPath = path9.join(pluginRoot, "mcp.json");
|
|
9620
|
+
if (await isRegularFile(mcpPath)) {
|
|
9621
|
+
components.mcp.push(relativeEvidencePath(repoPath, mcpPath));
|
|
9622
|
+
}
|
|
9623
|
+
const copilotExtensionDir = path9.join(pluginRoot, "com.github.copilot");
|
|
9624
|
+
const agentsDir = path9.join(copilotExtensionDir, "agents");
|
|
9625
|
+
if (await hasMarkdownFiles(agentsDir)) {
|
|
9626
|
+
components.agents.push(relativeEvidencePath(repoPath, agentsDir));
|
|
9627
|
+
}
|
|
9628
|
+
const rulesDir = path9.join(copilotExtensionDir, "rules");
|
|
9629
|
+
if (await hasMarkdownFiles(rulesDir)) {
|
|
9630
|
+
components.instructions.push(relativeEvidencePath(repoPath, rulesDir));
|
|
9631
|
+
}
|
|
9632
|
+
}
|
|
9633
|
+
return components;
|
|
9634
|
+
}
|
|
9869
9635
|
async function hasMcpConfig(repoPath) {
|
|
9870
9636
|
const found = [];
|
|
9871
9637
|
if (await fileExists(path9.join(repoPath, ".vscode", "mcp.json"))) {
|
|
9872
9638
|
found.push(".vscode/mcp.json");
|
|
9873
9639
|
}
|
|
9640
|
+
found.push(
|
|
9641
|
+
...(await fg3([".mcp.json", ".github/mcp.json", "**/.mcp.json", "**/.github/mcp.json"], {
|
|
9642
|
+
cwd: repoPath,
|
|
9643
|
+
onlyFiles: true,
|
|
9644
|
+
dot: true,
|
|
9645
|
+
followSymbolicLinks: false,
|
|
9646
|
+
ignore: AGENT_PLUGIN_SCAN_IGNORES,
|
|
9647
|
+
unique: true
|
|
9648
|
+
})).map((entry) => entry.replace(/\\/gu, "/")).sort()
|
|
9649
|
+
);
|
|
9874
9650
|
if (await fileExists(path9.join(repoPath, "mcp.json"))) {
|
|
9875
9651
|
found.push("mcp.json");
|
|
9876
9652
|
}
|
|
@@ -9881,11 +9657,22 @@ async function hasMcpConfig(repoPath) {
|
|
|
9881
9657
|
if (await fileExists(path9.join(repoPath, ".claude", "mcp.json"))) {
|
|
9882
9658
|
found.push(".claude/mcp.json");
|
|
9883
9659
|
}
|
|
9884
|
-
|
|
9660
|
+
const pluginComponents = await discoverAgentPluginComponents(repoPath);
|
|
9661
|
+
return [.../* @__PURE__ */ new Set([...found, ...pluginComponents.mcp])];
|
|
9885
9662
|
}
|
|
9886
9663
|
async function hasCustomAgents(repoPath, extraDirs) {
|
|
9887
9664
|
const found = [];
|
|
9888
|
-
|
|
9665
|
+
found.push(
|
|
9666
|
+
...(await fg3([".github/agents", ".claude/agents", "**/.github/agents", "**/.claude/agents"], {
|
|
9667
|
+
cwd: repoPath,
|
|
9668
|
+
onlyDirectories: true,
|
|
9669
|
+
dot: true,
|
|
9670
|
+
followSymbolicLinks: false,
|
|
9671
|
+
ignore: AGENT_PLUGIN_SCAN_IGNORES,
|
|
9672
|
+
unique: true
|
|
9673
|
+
})).map((entry) => entry.replace(/\\/gu, "/")).sort()
|
|
9674
|
+
);
|
|
9675
|
+
const agentDirs = [".copilot/agents", ".github/copilot/agents"];
|
|
9889
9676
|
for (const dir of agentDirs) {
|
|
9890
9677
|
if (await fileExists(path9.join(repoPath, dir))) {
|
|
9891
9678
|
found.push(dir);
|
|
@@ -9902,16 +9689,32 @@ async function hasCustomAgents(repoPath, extraDirs) {
|
|
|
9902
9689
|
found.push(dir);
|
|
9903
9690
|
}
|
|
9904
9691
|
}
|
|
9905
|
-
|
|
9692
|
+
const pluginComponents = await discoverAgentPluginComponents(repoPath);
|
|
9693
|
+
return [.../* @__PURE__ */ new Set([...found, ...pluginComponents.agents])];
|
|
9906
9694
|
}
|
|
9907
9695
|
async function hasCopilotSkills(repoPath, extraDirs) {
|
|
9908
9696
|
const found = [];
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
9914
|
-
|
|
9697
|
+
found.push(
|
|
9698
|
+
...(await fg3(
|
|
9699
|
+
[
|
|
9700
|
+
".github/skills",
|
|
9701
|
+
".agents/skills",
|
|
9702
|
+
".claude/skills",
|
|
9703
|
+
"**/.github/skills",
|
|
9704
|
+
"**/.agents/skills",
|
|
9705
|
+
"**/.claude/skills"
|
|
9706
|
+
],
|
|
9707
|
+
{
|
|
9708
|
+
cwd: repoPath,
|
|
9709
|
+
onlyDirectories: true,
|
|
9710
|
+
dot: true,
|
|
9711
|
+
followSymbolicLinks: false,
|
|
9712
|
+
ignore: AGENT_PLUGIN_SCAN_IGNORES,
|
|
9713
|
+
unique: true
|
|
9714
|
+
}
|
|
9715
|
+
)).map((entry) => entry.replace(/\\/gu, "/")).sort()
|
|
9716
|
+
);
|
|
9717
|
+
const skillDirs = [".copilot/skills", ".github/copilot/skills"];
|
|
9915
9718
|
for (const dir of skillDirs) {
|
|
9916
9719
|
if (await fileExists(path9.join(repoPath, dir))) {
|
|
9917
9720
|
found.push(dir);
|
|
@@ -9922,7 +9725,8 @@ async function hasCopilotSkills(repoPath, extraDirs) {
|
|
|
9922
9725
|
found.push(dir);
|
|
9923
9726
|
}
|
|
9924
9727
|
}
|
|
9925
|
-
|
|
9728
|
+
const pluginComponents = await discoverAgentPluginComponents(repoPath);
|
|
9729
|
+
return [.../* @__PURE__ */ new Set([...found, ...pluginComponents.skills])];
|
|
9926
9730
|
}
|
|
9927
9731
|
async function hasApmConfig(repoPath) {
|
|
9928
9732
|
return fileExists(path9.join(repoPath, "apm.yml"));
|
|
@@ -10012,7 +9816,7 @@ function buildCriteria() {
|
|
|
10012
9816
|
return {
|
|
10013
9817
|
status: found ? "pass" : "fail",
|
|
10014
9818
|
reason: found ? void 0 : "Missing type checking config (tsconfig or equivalent).",
|
|
10015
|
-
evidence: ["tsconfig.json", "pyproject.toml", "mypy.ini"]
|
|
9819
|
+
evidence: ["tsconfig.json", "tsconfig.base.json", "pyproject.toml", "mypy.ini"]
|
|
10016
9820
|
};
|
|
10017
9821
|
}
|
|
10018
9822
|
},
|
|
@@ -10244,43 +10048,62 @@ function buildCriteria() {
|
|
|
10244
10048
|
effort: "low",
|
|
10245
10049
|
check: async (context) => {
|
|
10246
10050
|
const rootFound = await hasCustomInstructions(context.repoPath);
|
|
10247
|
-
|
|
10051
|
+
const pluginInstructions = await hasAgentPluginInstructions(context.repoPath);
|
|
10052
|
+
const nestedInstructions = (await hasNestedCopilotInstructions(context.repoPath)).filter(
|
|
10053
|
+
(instruction) => !rootFound.includes(instruction)
|
|
10054
|
+
);
|
|
10055
|
+
const fileBasedInstructions = await hasFileBasedInstructions(
|
|
10056
|
+
context.repoPath,
|
|
10057
|
+
context.vscodeLocations?.instructionsLocations
|
|
10058
|
+
);
|
|
10059
|
+
const found = [
|
|
10060
|
+
.../* @__PURE__ */ new Set([
|
|
10061
|
+
...rootFound,
|
|
10062
|
+
...nestedInstructions,
|
|
10063
|
+
...fileBasedInstructions,
|
|
10064
|
+
...pluginInstructions
|
|
10065
|
+
])
|
|
10066
|
+
];
|
|
10067
|
+
if (found.length === 0) {
|
|
10248
10068
|
return {
|
|
10249
10069
|
status: "fail",
|
|
10250
|
-
reason: "Missing custom instructions (e.g. copilot-instructions.md, CLAUDE.md,
|
|
10070
|
+
reason: "Missing custom instructions (e.g. copilot-instructions.md, AGENTS.md, CLAUDE.md, GEMINI.md, or *.instructions.md).",
|
|
10251
10071
|
evidence: [
|
|
10252
|
-
"copilot-instructions.md",
|
|
10072
|
+
".github/copilot-instructions.md",
|
|
10253
10073
|
"CLAUDE.md",
|
|
10254
10074
|
"AGENTS.md",
|
|
10255
|
-
".
|
|
10256
|
-
".github/
|
|
10075
|
+
"GEMINI.md",
|
|
10076
|
+
".github/instructions/*.instructions.md"
|
|
10257
10077
|
]
|
|
10258
10078
|
};
|
|
10259
10079
|
}
|
|
10260
|
-
const fileBasedInstructions = await hasFileBasedInstructions(
|
|
10261
|
-
context.repoPath,
|
|
10262
|
-
context.vscodeLocations?.instructionsLocations
|
|
10263
|
-
);
|
|
10264
10080
|
const areas = context.analysis.areas ?? [];
|
|
10265
10081
|
if (areas.length > 0) {
|
|
10266
10082
|
if (fileBasedInstructions.length === 0) {
|
|
10267
10083
|
return {
|
|
10268
10084
|
status: "pass",
|
|
10269
|
-
reason: `
|
|
10270
|
-
evidence: [...
|
|
10085
|
+
reason: rootFound.length > 0 || nestedInstructions.length > 0 ? `Repository instructions found, but no area instructions for ${areas.length} detected areas. Run \`agentrc instructions --areas\` to generate.` : `${pluginInstructions.length} Agent Plugin rule source(s) found, but no repository or area instructions.`,
|
|
10086
|
+
evidence: [...found, ...areas.map((a) => `${a.name}: missing .instructions.md`)]
|
|
10087
|
+
};
|
|
10088
|
+
}
|
|
10089
|
+
if (rootFound.length === 0) {
|
|
10090
|
+
return {
|
|
10091
|
+
status: "pass",
|
|
10092
|
+
reason: `${fileBasedInstructions.length} file-based instruction(s) found, but no repository-wide instructions.`,
|
|
10093
|
+
evidence: [...fileBasedInstructions, ...pluginInstructions]
|
|
10271
10094
|
};
|
|
10272
10095
|
}
|
|
10273
10096
|
return {
|
|
10274
10097
|
status: "pass",
|
|
10275
10098
|
reason: `Root + ${fileBasedInstructions.length} area instruction(s) found.`,
|
|
10276
|
-
evidence:
|
|
10099
|
+
evidence: found
|
|
10277
10100
|
};
|
|
10278
10101
|
}
|
|
10279
10102
|
if (fileBasedInstructions.length > 0) {
|
|
10280
10103
|
return {
|
|
10281
10104
|
status: "pass",
|
|
10282
|
-
reason: `Root + ${fileBasedInstructions.length} file-based instruction(s) found.`,
|
|
10283
|
-
evidence:
|
|
10105
|
+
reason: rootFound.length > 0 ? `Root + ${fileBasedInstructions.length} file-based instruction(s) found.` : `${fileBasedInstructions.length} file-based instruction(s) found, but no repository-wide instructions.`,
|
|
10106
|
+
evidence: found
|
|
10284
10107
|
};
|
|
10285
10108
|
}
|
|
10286
10109
|
if (context.analysis.isMonorepo && context.apps.length > 1) {
|
|
@@ -10304,7 +10127,8 @@ function buildCriteria() {
|
|
|
10304
10127
|
}
|
|
10305
10128
|
return {
|
|
10306
10129
|
status: "pass",
|
|
10307
|
-
|
|
10130
|
+
reason: rootFound.length === 0 && pluginInstructions.length > 0 ? `${pluginInstructions.length} Agent Plugin rule source(s) found, but no repository-wide instructions.` : void 0,
|
|
10131
|
+
evidence: found
|
|
10308
10132
|
};
|
|
10309
10133
|
}
|
|
10310
10134
|
},
|
|
@@ -10348,8 +10172,14 @@ function buildCriteria() {
|
|
|
10348
10172
|
const found = await hasMcpConfig(context.repoPath);
|
|
10349
10173
|
return {
|
|
10350
10174
|
status: found.length > 0 ? "pass" : "fail",
|
|
10351
|
-
reason: "Missing MCP (Model Context Protocol) configuration (e.g. .vscode/mcp.json).",
|
|
10352
|
-
evidence: found.length > 0 ? found : [
|
|
10175
|
+
reason: found.length > 0 ? void 0 : "Missing MCP (Model Context Protocol) configuration (e.g. .vscode/mcp.json or an Agent Plugin mcp.json).",
|
|
10176
|
+
evidence: found.length > 0 ? found : [
|
|
10177
|
+
".vscode/mcp.json",
|
|
10178
|
+
".vscode/settings.json (mcp section)",
|
|
10179
|
+
".mcp.json",
|
|
10180
|
+
".github/mcp.json",
|
|
10181
|
+
"<agent-plugin>/mcp.json"
|
|
10182
|
+
]
|
|
10353
10183
|
};
|
|
10354
10184
|
}
|
|
10355
10185
|
},
|
|
@@ -10368,14 +10198,14 @@ function buildCriteria() {
|
|
|
10368
10198
|
);
|
|
10369
10199
|
return {
|
|
10370
10200
|
status: found.length > 0 ? "pass" : "fail",
|
|
10371
|
-
reason: "No custom AI agents configured (e.g. .github/agents/, .
|
|
10372
|
-
evidence: found.length > 0 ? found : [".github/agents/", ".
|
|
10201
|
+
reason: found.length > 0 ? void 0 : "No custom AI agents configured (e.g. .github/agents/, .claude/agents/, or an Agent Plugin agents/ directory).",
|
|
10202
|
+
evidence: found.length > 0 ? found : [".github/agents/", ".claude/agents/", "<agent-plugin>/com.github.copilot/agents/"]
|
|
10373
10203
|
};
|
|
10374
10204
|
}
|
|
10375
10205
|
},
|
|
10376
10206
|
{
|
|
10377
10207
|
id: "copilot-skills",
|
|
10378
|
-
title: "
|
|
10208
|
+
title: "AI skills present",
|
|
10379
10209
|
pillar: "ai-tooling",
|
|
10380
10210
|
level: 3,
|
|
10381
10211
|
scope: "repo",
|
|
@@ -10388,8 +10218,42 @@ function buildCriteria() {
|
|
|
10388
10218
|
);
|
|
10389
10219
|
return {
|
|
10390
10220
|
status: found.length > 0 ? "pass" : "fail",
|
|
10391
|
-
reason: "No
|
|
10392
|
-
evidence: found.length > 0 ? found : [".
|
|
10221
|
+
reason: found.length > 0 ? void 0 : "No AI skills found (e.g. .github/skills/, .agents/skills/, .claude/skills/, or an Agent Plugin skills/ directory).",
|
|
10222
|
+
evidence: found.length > 0 ? found : [".github/skills/", ".agents/skills/", ".claude/skills/", "<agent-plugin>/skills/"]
|
|
10223
|
+
};
|
|
10224
|
+
}
|
|
10225
|
+
},
|
|
10226
|
+
{
|
|
10227
|
+
id: "plugin-marketplaces",
|
|
10228
|
+
title: "Additional Copilot plugin marketplaces configured",
|
|
10229
|
+
pillar: "ai-tooling",
|
|
10230
|
+
level: 3,
|
|
10231
|
+
scope: "repo",
|
|
10232
|
+
impact: "low",
|
|
10233
|
+
effort: "low",
|
|
10234
|
+
check: async (context) => {
|
|
10235
|
+
const found = await hasCopilotPluginSetting(context.repoPath, "extraKnownMarketplaces");
|
|
10236
|
+
return {
|
|
10237
|
+
status: found.length > 0 ? "pass" : "skip",
|
|
10238
|
+
reason: found.length > 0 ? void 0 : "No repository-scoped extraKnownMarketplaces setting found.",
|
|
10239
|
+
evidence: found
|
|
10240
|
+
};
|
|
10241
|
+
}
|
|
10242
|
+
},
|
|
10243
|
+
{
|
|
10244
|
+
id: "enabled-plugins",
|
|
10245
|
+
title: "Copilot plugins enabled in repository settings",
|
|
10246
|
+
pillar: "ai-tooling",
|
|
10247
|
+
level: 3,
|
|
10248
|
+
scope: "repo",
|
|
10249
|
+
impact: "low",
|
|
10250
|
+
effort: "low",
|
|
10251
|
+
check: async (context) => {
|
|
10252
|
+
const found = await hasCopilotPluginSetting(context.repoPath, "enabledPlugins");
|
|
10253
|
+
return {
|
|
10254
|
+
status: found.length > 0 ? "pass" : "skip",
|
|
10255
|
+
reason: found.length > 0 ? void 0 : "No repository-scoped enabledPlugins setting found.",
|
|
10256
|
+
evidence: found
|
|
10393
10257
|
};
|
|
10394
10258
|
}
|
|
10395
10259
|
},
|
|
@@ -13622,8 +13486,7 @@ var DEFAULT_SYSTEM_MESSAGE = "Research using read-only tools and make a plan for
|
|
|
13622
13486
|
async function runEval(options) {
|
|
13623
13487
|
const config = await loadConfig(options.configPath);
|
|
13624
13488
|
const instructionFile = config.instructionFile ?? ".github/copilot-instructions.md";
|
|
13625
|
-
const
|
|
13626
|
-
const instructionText = await readOptionalFile(instructionPath);
|
|
13489
|
+
const instructionText = await readRepoFile(options.repoPath, instructionFile);
|
|
13627
13490
|
const baseSystemMessage = config.systemMessage ?? DEFAULT_SYSTEM_MESSAGE;
|
|
13628
13491
|
const progress = options.onProgress ?? (() => {
|
|
13629
13492
|
});
|
|
@@ -13645,17 +13508,10 @@ async function runEval(options) {
|
|
|
13645
13508
|
const id = testCase.id ?? `case-${index + 1}`;
|
|
13646
13509
|
const prompt = buildPrompt(options.repoPath, testCase.prompt);
|
|
13647
13510
|
const caseStartedAt = Date.now();
|
|
13648
|
-
|
|
13649
|
-
|
|
13650
|
-
|
|
13651
|
-
|
|
13652
|
-
if (resolved !== root && !resolved.startsWith(root + path15.sep)) {
|
|
13653
|
-
throw new Error(
|
|
13654
|
-
`Invalid workingDirectory "${testCase.workingDirectory}": escapes repo boundary`
|
|
13655
|
-
);
|
|
13656
|
-
}
|
|
13657
|
-
caseWorkingDir = resolved;
|
|
13658
|
-
}
|
|
13511
|
+
const caseWorkingDir = await resolveRepoDirectory(
|
|
13512
|
+
options.repoPath,
|
|
13513
|
+
testCase.workingDirectory
|
|
13514
|
+
);
|
|
13659
13515
|
progress(`Running eval ${index + 1}/${total}: ${id} (without instructions)...`);
|
|
13660
13516
|
const withoutResult = await askOnce(client, {
|
|
13661
13517
|
prompt,
|
|
@@ -13722,9 +13578,9 @@ async function runEval(options) {
|
|
|
13722
13578
|
let viewerPath;
|
|
13723
13579
|
if (outputPath) {
|
|
13724
13580
|
await fs9.mkdir(path15.dirname(outputPath), { recursive: true });
|
|
13725
|
-
await
|
|
13581
|
+
await writeEvalArtifact(outputPath, JSON.stringify(output, null, 2));
|
|
13726
13582
|
viewerPath = buildViewerPath(outputPath);
|
|
13727
|
-
await
|
|
13583
|
+
await writeEvalArtifact(viewerPath, buildTrajectoryViewerHtml(output));
|
|
13728
13584
|
}
|
|
13729
13585
|
const summary = formatSummary(results, runFinishedAt - runStartedAt);
|
|
13730
13586
|
return { summary, results, viewerPath };
|
|
@@ -13770,7 +13626,8 @@ async function judge(client, options) {
|
|
|
13770
13626
|
infiniteSessions: { enabled: false },
|
|
13771
13627
|
systemMessage: {
|
|
13772
13628
|
content: "You are a strict evaluator. Return JSON with keys: verdict (pass|fail|unknown), score (0-100), rationale. Do not include any other text."
|
|
13773
|
-
}
|
|
13629
|
+
},
|
|
13630
|
+
availableTools: []
|
|
13774
13631
|
});
|
|
13775
13632
|
let content = "";
|
|
13776
13633
|
const telemetry = createTelemetry("judge");
|
|
@@ -13814,10 +13671,16 @@ function parseJudge(content) {
|
|
|
13814
13671
|
const match = content.match(/\{[\s\S]*\}/);
|
|
13815
13672
|
if (!match) throw new Error("No JSON detected");
|
|
13816
13673
|
const parsed = JSON.parse(match[0]);
|
|
13817
|
-
if (!parsed.verdict)
|
|
13674
|
+
if (!["pass", "fail", "unknown"].includes(parsed.verdict)) {
|
|
13675
|
+
throw new Error("Invalid verdict");
|
|
13676
|
+
}
|
|
13677
|
+
const score = Number(parsed.score);
|
|
13678
|
+
if (!Number.isFinite(score) || score < 0 || score > 100) {
|
|
13679
|
+
throw new Error("Invalid score");
|
|
13680
|
+
}
|
|
13818
13681
|
return {
|
|
13819
13682
|
verdict: parsed.verdict,
|
|
13820
|
-
score
|
|
13683
|
+
score,
|
|
13821
13684
|
rationale: String(parsed.rationale ?? "")
|
|
13822
13685
|
};
|
|
13823
13686
|
} catch {
|
|
@@ -13836,12 +13699,44 @@ async function loadConfig(configPath) {
|
|
|
13836
13699
|
}
|
|
13837
13700
|
return parsed;
|
|
13838
13701
|
}
|
|
13839
|
-
async function
|
|
13702
|
+
async function readRepoFile(repoPath, relativePath) {
|
|
13703
|
+
const repoRoot = path15.resolve(repoPath);
|
|
13704
|
+
const filePath = path15.resolve(repoRoot, relativePath);
|
|
13705
|
+
if (!isWithinRoot(repoRoot, filePath)) {
|
|
13706
|
+
throw new Error(`Invalid instructionFile "${relativePath}": escapes repo boundary`);
|
|
13707
|
+
}
|
|
13708
|
+
let realFilePath;
|
|
13840
13709
|
try {
|
|
13841
|
-
|
|
13842
|
-
} catch {
|
|
13843
|
-
|
|
13710
|
+
realFilePath = await fs9.realpath(filePath);
|
|
13711
|
+
} catch (error) {
|
|
13712
|
+
if (error.code === "ENOENT") {
|
|
13713
|
+
throw new Error(`Instruction file not found: ${relativePath}`);
|
|
13714
|
+
}
|
|
13715
|
+
throw error;
|
|
13716
|
+
}
|
|
13717
|
+
const realRepoRoot = await fs9.realpath(repoRoot);
|
|
13718
|
+
if (!isWithinRoot(realRepoRoot, realFilePath)) {
|
|
13719
|
+
throw new Error(`Invalid instructionFile "${relativePath}": resolves outside repo boundary`);
|
|
13844
13720
|
}
|
|
13721
|
+
return fs9.readFile(realFilePath, "utf8");
|
|
13722
|
+
}
|
|
13723
|
+
async function resolveRepoDirectory(repoPath, relativePath) {
|
|
13724
|
+
const repoRoot = path15.resolve(repoPath);
|
|
13725
|
+
const directoryPath = path15.resolve(repoRoot, relativePath ?? ".");
|
|
13726
|
+
if (!isWithinRoot(repoRoot, directoryPath)) {
|
|
13727
|
+
throw new Error(`Invalid workingDirectory "${relativePath}": escapes repo boundary`);
|
|
13728
|
+
}
|
|
13729
|
+
const [realRepoRoot, realDirectoryPath] = await Promise.all([
|
|
13730
|
+
fs9.realpath(repoRoot),
|
|
13731
|
+
fs9.realpath(directoryPath)
|
|
13732
|
+
]);
|
|
13733
|
+
if (!isWithinRoot(realRepoRoot, realDirectoryPath)) {
|
|
13734
|
+
throw new Error(`Invalid workingDirectory "${relativePath}": resolves outside repo boundary`);
|
|
13735
|
+
}
|
|
13736
|
+
return realDirectoryPath;
|
|
13737
|
+
}
|
|
13738
|
+
function isWithinRoot(root, candidate) {
|
|
13739
|
+
return candidate === root || candidate.startsWith(root + path15.sep);
|
|
13845
13740
|
}
|
|
13846
13741
|
function buildPrompt(repoPath, userPrompt) {
|
|
13847
13742
|
return [
|
|
@@ -14034,9 +13929,22 @@ function formatTokenUsage(usage) {
|
|
|
14034
13929
|
return `prompt ${prompt}, completion ${completion}, total ${total}`;
|
|
14035
13930
|
}
|
|
14036
13931
|
function resolveOutputPath(repoPath, override, configValue) {
|
|
14037
|
-
|
|
14038
|
-
|
|
14039
|
-
|
|
13932
|
+
if (override) {
|
|
13933
|
+
return path15.isAbsolute(override) ? override : path15.resolve(repoPath, override);
|
|
13934
|
+
}
|
|
13935
|
+
if (!configValue) return void 0;
|
|
13936
|
+
const repoRoot = path15.resolve(repoPath);
|
|
13937
|
+
const outputPath = path15.resolve(repoRoot, configValue);
|
|
13938
|
+
if (!isWithinRoot(repoRoot, outputPath)) {
|
|
13939
|
+
throw new Error(`Invalid outputPath "${configValue}": escapes repo boundary`);
|
|
13940
|
+
}
|
|
13941
|
+
return outputPath;
|
|
13942
|
+
}
|
|
13943
|
+
async function writeEvalArtifact(filePath, content) {
|
|
13944
|
+
const result = await safeWriteFile(filePath, content, true);
|
|
13945
|
+
if (!result.wrote) {
|
|
13946
|
+
throw new Error(`Failed to write ${filePath}: ${result.reason ?? "unknown reason"}`);
|
|
13947
|
+
}
|
|
14040
13948
|
}
|
|
14041
13949
|
function buildViewerPath(outputPath) {
|
|
14042
13950
|
if (outputPath.endsWith(".json")) {
|
|
@@ -14549,7 +14457,7 @@ async function generateConfigs(options) {
|
|
|
14549
14457
|
files.push(
|
|
14550
14458
|
await writeOrPreview(
|
|
14551
14459
|
path17.join(repoPath, ".vscode", "settings.json"),
|
|
14552
|
-
renderVscodeSettings(analysis),
|
|
14460
|
+
renderVscodeSettings(analysis, options.instructionFile),
|
|
14553
14461
|
{ dryRun, force }
|
|
14554
14462
|
)
|
|
14555
14463
|
);
|
|
@@ -14584,13 +14492,11 @@ function renderMcp() {
|
|
|
14584
14492
|
2
|
|
14585
14493
|
);
|
|
14586
14494
|
}
|
|
14587
|
-
function renderVscodeSettings(analysis) {
|
|
14495
|
+
function renderVscodeSettings(analysis, instructionFile = ".github/copilot-instructions.md") {
|
|
14588
14496
|
const reviewFocus = analysis.frameworks.length ? `Focus on ${analysis.frameworks.join(", ")} best practices and repo conventions.` : "Focus on repo conventions and maintainability.";
|
|
14589
14497
|
return JSON.stringify(
|
|
14590
14498
|
{
|
|
14591
|
-
"github.copilot.chat.codeGeneration.instructions": [
|
|
14592
|
-
{ file: ".github/copilot-instructions.md" }
|
|
14593
|
-
],
|
|
14499
|
+
"github.copilot.chat.codeGeneration.instructions": [{ file: instructionFile }],
|
|
14594
14500
|
"github.copilot.chat.reviewSelection.instructions": [{ text: reviewFocus }],
|
|
14595
14501
|
"chat.promptFiles": true,
|
|
14596
14502
|
"chat.mcp.enabled": true
|
|
@@ -14601,6 +14507,7 @@ function renderVscodeSettings(analysis) {
|
|
|
14601
14507
|
}
|
|
14602
14508
|
|
|
14603
14509
|
// src/commands/instructions.ts
|
|
14510
|
+
import fs10 from "fs/promises";
|
|
14604
14511
|
import path18 from "path";
|
|
14605
14512
|
function skipReason(action) {
|
|
14606
14513
|
if (action === "symlink") return "symlink";
|
|
@@ -14634,6 +14541,7 @@ async function instructionsCommand(options) {
|
|
|
14634
14541
|
}
|
|
14635
14542
|
try {
|
|
14636
14543
|
const dryRunFiles = [];
|
|
14544
|
+
let rootContent;
|
|
14637
14545
|
if (!options.areasOnly && !options.area) {
|
|
14638
14546
|
if (strategy === "nested") {
|
|
14639
14547
|
try {
|
|
@@ -14646,6 +14554,7 @@ async function instructionsCommand(options) {
|
|
|
14646
14554
|
claudeMd
|
|
14647
14555
|
});
|
|
14648
14556
|
if (options.dryRun) {
|
|
14557
|
+
rootContent = nestedResult.hub.content;
|
|
14649
14558
|
const dryFiles = [
|
|
14650
14559
|
{ path: nestedResult.hub.relativePath, content: nestedResult.hub.content },
|
|
14651
14560
|
...nestedResult.details.map((d) => ({ path: d.relativePath, content: d.content })),
|
|
@@ -14677,6 +14586,12 @@ async function instructionsCommand(options) {
|
|
|
14677
14586
|
}
|
|
14678
14587
|
} else {
|
|
14679
14588
|
const actions = await writeNestedInstructions(repoPath, nestedResult, options.force);
|
|
14589
|
+
const hubAction = actions[0];
|
|
14590
|
+
if (hubAction?.action === "wrote") {
|
|
14591
|
+
rootContent = nestedResult.hub.content;
|
|
14592
|
+
} else if (hubAction?.action === "skipped") {
|
|
14593
|
+
rootContent = await fs10.readFile(hubAction.path, "utf8").catch(() => void 0);
|
|
14594
|
+
}
|
|
14680
14595
|
for (const action of actions) {
|
|
14681
14596
|
const relPath = path18.relative(process.cwd(), action.path);
|
|
14682
14597
|
if (action.action === "wrote") {
|
|
@@ -14813,7 +14728,8 @@ async function instructionsCommand(options) {
|
|
|
14813
14728
|
model: options.model,
|
|
14814
14729
|
onProgress: shouldLog(options) ? (msg) => progress.update(msg) : void 0,
|
|
14815
14730
|
detailDir,
|
|
14816
|
-
claudeMd
|
|
14731
|
+
claudeMd,
|
|
14732
|
+
rootContent
|
|
14817
14733
|
});
|
|
14818
14734
|
if (options.dryRun) {
|
|
14819
14735
|
const dryFiles = [
|
|
@@ -15774,7 +15690,7 @@ import path25 from "path";
|
|
|
15774
15690
|
import { render as render3 } from "ink";
|
|
15775
15691
|
|
|
15776
15692
|
// src/ui/tui.tsx
|
|
15777
|
-
import
|
|
15693
|
+
import fs11 from "fs/promises";
|
|
15778
15694
|
import path24 from "path";
|
|
15779
15695
|
import { Box as Box5, Text as Text5, useApp as useApp4, useInput as useInput4, useStdout, useIsScreenReaderEnabled as useIsScreenReaderEnabled5 } from "ink";
|
|
15780
15696
|
import { useEffect as useEffect5, useMemo, useState as useState5 } from "react";
|
|
@@ -15903,14 +15819,14 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
|
|
|
15903
15819
|
};
|
|
15904
15820
|
useEffect5(() => {
|
|
15905
15821
|
const configPath = path24.join(repoPath, "agentrc.eval.json");
|
|
15906
|
-
|
|
15822
|
+
fs11.access(configPath).then(() => setHasEvalConfig(true)).catch(() => setHasEvalConfig(false));
|
|
15907
15823
|
const agentrcConfigCandidates = [
|
|
15908
15824
|
path24.join(repoPath, "agentrc.config.json"),
|
|
15909
15825
|
path24.join(repoPath, ".github", "agentrc.config.json")
|
|
15910
15826
|
];
|
|
15911
15827
|
Promise.all(
|
|
15912
15828
|
agentrcConfigCandidates.map(
|
|
15913
|
-
(p) =>
|
|
15829
|
+
(p) => fs11.access(p).then(() => true).catch(() => false)
|
|
15914
15830
|
)
|
|
15915
15831
|
).then((results) => setHasAgentrcConfig(results.some(Boolean))).catch(() => setHasAgentrcConfig(false));
|
|
15916
15832
|
analyzeRepo(repoPath).then((analysis) => {
|
|
@@ -15974,7 +15890,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
|
|
|
15974
15890
|
useEffect5(() => {
|
|
15975
15891
|
let active = true;
|
|
15976
15892
|
const configPath = path24.join(repoPath, "agentrc.eval.json");
|
|
15977
|
-
|
|
15893
|
+
fs11.readFile(configPath, "utf8").then((raw) => {
|
|
15978
15894
|
if (!active) return;
|
|
15979
15895
|
const parsed = JSON.parse(raw);
|
|
15980
15896
|
const setting = parsed.ui?.modelPicker;
|
|
@@ -16028,7 +15944,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
|
|
|
16028
15944
|
if (input.toLowerCase() === "s") {
|
|
16029
15945
|
try {
|
|
16030
15946
|
const outputPath = generateSavePath || path24.join(repoPath, ".github", "copilot-instructions.md");
|
|
16031
|
-
await
|
|
15947
|
+
await fs11.mkdir(path24.dirname(outputPath), { recursive: true });
|
|
16032
15948
|
const { wrote, reason } = await safeWriteFile(outputPath, generatedContent, true);
|
|
16033
15949
|
if (!wrote)
|
|
16034
15950
|
throw new Error(reason === "symlink" ? "Path is a symlink" : "Write failed");
|
|
@@ -16070,7 +15986,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
|
|
|
16070
15986
|
const configPath = path24.join(repoPath, "agentrc.eval.json");
|
|
16071
15987
|
setEvalBootstrapCount(count);
|
|
16072
15988
|
try {
|
|
16073
|
-
await
|
|
15989
|
+
await fs11.access(configPath);
|
|
16074
15990
|
setStatus("bootstrapEvalConfirm");
|
|
16075
15991
|
setMessage("agentrc.eval.json exists. Overwrite? (Y/N)");
|
|
16076
15992
|
} catch {
|
|
@@ -16181,7 +16097,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
|
|
|
16181
16097
|
onProgress: (msg) => setMessage(`${app2.name}: ${msg}`)
|
|
16182
16098
|
});
|
|
16183
16099
|
if (content.trim()) {
|
|
16184
|
-
await
|
|
16100
|
+
await fs11.mkdir(path24.dirname(savePath), { recursive: true });
|
|
16185
16101
|
const { wrote: saved } = await safeWriteFile(savePath, content, true);
|
|
16186
16102
|
if (!saved) continue;
|
|
16187
16103
|
count++;
|
|
@@ -16329,7 +16245,7 @@ function AgentRCTui({ repoPath, skipAnimation = false }) {
|
|
|
16329
16245
|
buildTimestampedName("eval-results")
|
|
16330
16246
|
);
|
|
16331
16247
|
try {
|
|
16332
|
-
await
|
|
16248
|
+
await fs11.access(configPath);
|
|
16333
16249
|
} catch {
|
|
16334
16250
|
setStatus("error");
|
|
16335
16251
|
const msg = "No agentrc.eval.json found. Press [E] then [I] to create one.";
|