feat(skills): map runner outcomes into step receipts
This commit is contained in:
+52
-3
@@ -20,6 +20,7 @@ import {
|
||||
toSkillInstallerExecutionStubFromPreflight,
|
||||
evaluateInstallerExecutionPolicy,
|
||||
toInstallerExecutionStepEnvelopes,
|
||||
mergeInstallerExecutionResults,
|
||||
runInstallerCommandsWithPolicy,
|
||||
noOpSkillInstallerCommandRunner,
|
||||
runSkillInstallAction,
|
||||
@@ -347,7 +348,7 @@ describe('skills CLI helpers', () => {
|
||||
|
||||
it('does not invoke command runner when policy disables execution', () => {
|
||||
const runner = {
|
||||
run: vi.fn((_commands: string[]) => ['should-not-run']),
|
||||
run: vi.fn((_commands: string[]) => [{ command: 'should-not-run', status: 'succeeded' as const }]),
|
||||
};
|
||||
|
||||
const executed = runInstallerCommandsWithPolicy(
|
||||
@@ -362,7 +363,7 @@ describe('skills CLI helpers', () => {
|
||||
|
||||
it('supports pluggable command runner when policy enables execution', () => {
|
||||
const runner = {
|
||||
run: vi.fn((commands: string[]) => commands),
|
||||
run: vi.fn((commands: string[]) => commands.map((command) => ({ command, status: 'succeeded' as const }))),
|
||||
};
|
||||
|
||||
const executed = runInstallerCommandsWithPolicy(
|
||||
@@ -371,10 +372,58 @@ describe('skills CLI helpers', () => {
|
||||
runner,
|
||||
);
|
||||
|
||||
expect(executed).toEqual(['brew install jq']);
|
||||
expect(executed).toEqual([{ command: 'brew install jq', status: 'succeeded' }]);
|
||||
expect(runner.run).toHaveBeenCalledWith(['brew install jq']);
|
||||
});
|
||||
|
||||
it('maps runner command results into structured per-step statuses', () => {
|
||||
const attempted = [
|
||||
{ installer_type: 'brew', command: 'brew install jq' },
|
||||
{ installer_type: 'node', command: 'pnpm add -g zx' },
|
||||
];
|
||||
|
||||
const results = mergeInstallerExecutionResults(
|
||||
attempted,
|
||||
{ confirmed: true, execution_enabled: true, reason: 'execution_disabled' },
|
||||
[
|
||||
{ command: 'brew install jq', status: 'succeeded', reason: 'ok' },
|
||||
{ command: 'pnpm add -g zx', status: 'failed', reason: 'exit_code_1' },
|
||||
],
|
||||
);
|
||||
|
||||
expect(results).toEqual([
|
||||
{
|
||||
installer_type: 'brew',
|
||||
command: 'brew install jq',
|
||||
status: 'succeeded',
|
||||
reason: 'ok',
|
||||
},
|
||||
{
|
||||
installer_type: 'node',
|
||||
command: 'pnpm add -g zx',
|
||||
status: 'failed',
|
||||
reason: 'exit_code_1',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('marks attempted steps failed when runner does not report a result', () => {
|
||||
const results = mergeInstallerExecutionResults(
|
||||
[{ installer_type: 'brew', command: 'brew install jq' }],
|
||||
{ confirmed: true, execution_enabled: true, reason: 'execution_disabled' },
|
||||
[],
|
||||
);
|
||||
|
||||
expect(results).toEqual([
|
||||
{
|
||||
installer_type: 'brew',
|
||||
command: 'brew install jq',
|
||||
status: 'failed',
|
||||
reason: 'runner_no_result',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('summarizes refresh counts across status and tiers', () => {
|
||||
const summary = summarizeSkillsRefresh([
|
||||
buildSkill({ manifest: { name: 'a', description: 'a', version: '1.0.0', tier: 'bundled' } }),
|
||||
|
||||
Reference in New Issue
Block a user