(ctx)
| 775 | }, |
| 776 | newMessages, |
| 777 | contextModifier(ctx) { |
| 778 | let modifiedContext = ctx |
| 779 | |
| 780 | // Update allowed tools if specified |
| 781 | if (allowedTools.length > 0) { |
| 782 | // Capture the current getAppState to chain modifications properly |
| 783 | const previousGetAppState = modifiedContext.getAppState |
| 784 | modifiedContext = { |
| 785 | ...modifiedContext, |
| 786 | getAppState() { |
| 787 | // Use the previous getAppState, not the closure's context.getAppState, |
| 788 | // to properly chain context modifications |
| 789 | const appState = previousGetAppState() |
| 790 | return { |
| 791 | ...appState, |
| 792 | toolPermissionContext: { |
| 793 | ...appState.toolPermissionContext, |
| 794 | alwaysAllowRules: { |
| 795 | ...appState.toolPermissionContext.alwaysAllowRules, |
| 796 | command: [ |
| 797 | ...new Set([ |
| 798 | ...(appState.toolPermissionContext.alwaysAllowRules |
| 799 | .command || []), |
| 800 | ...allowedTools, |
| 801 | ]), |
| 802 | ], |
| 803 | }, |
| 804 | }, |
| 805 | } |
| 806 | }, |
| 807 | } |
| 808 | } |
| 809 | |
| 810 | // Carry [1m] suffix over — otherwise a skill with `model: opus` on an |
| 811 | // opus[1m] session drops the effective window to 200K and trips autocompact. |
| 812 | if (model) { |
| 813 | modifiedContext = { |
| 814 | ...modifiedContext, |
| 815 | options: { |
| 816 | ...modifiedContext.options, |
| 817 | mainLoopModel: resolveSkillModelOverride( |
| 818 | model, |
| 819 | ctx.options.mainLoopModel, |
| 820 | ), |
| 821 | }, |
| 822 | } |
| 823 | } |
| 824 | |
| 825 | // Override effort level if skill specifies one |
| 826 | if (effort !== undefined) { |
| 827 | const previousGetAppState = modifiedContext.getAppState |
| 828 | modifiedContext = { |
| 829 | ...modifiedContext, |
| 830 | getAppState() { |
| 831 | const appState = previousGetAppState() |
| 832 | return { |
| 833 | ...appState, |
| 834 | effortValue: effort, |
nothing calls this directly
no test coverage detected