@sentry/warden 0.22.0 → 0.24.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/.oxlintrc.json +169 -0
- package/CHANGELOG.md +427 -0
- package/README.md +4 -1
- package/dist/cli/args.d.ts +6 -2
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +175 -207
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/commands/add.d.ts.map +1 -1
- package/dist/cli/commands/add.js +16 -5
- package/dist/cli/commands/add.js.map +1 -1
- package/dist/cli/commands/build.d.ts +13 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/build.js +384 -0
- package/dist/cli/commands/build.js.map +1 -0
- package/dist/cli/commands/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +13 -5
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/runs.d.ts.map +1 -1
- package/dist/cli/commands/runs.js +12 -6
- package/dist/cli/commands/runs.js.map +1 -1
- package/dist/cli/commands/sync.d.ts.map +1 -1
- package/dist/cli/commands/sync.js +4 -1
- package/dist/cli/commands/sync.js.map +1 -1
- package/dist/cli/context.d.ts.map +1 -1
- package/dist/cli/context.js +8 -1
- package/dist/cli/context.js.map +1 -1
- package/dist/cli/files.d.ts.map +1 -1
- package/dist/cli/files.js +27 -9
- package/dist/cli/files.js.map +1 -1
- package/dist/cli/help.d.ts +4 -0
- package/dist/cli/help.d.ts.map +1 -0
- package/dist/cli/help.js +448 -0
- package/dist/cli/help.js.map +1 -0
- package/dist/cli/index.js +2 -13
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/input.d.ts +12 -0
- package/dist/cli/input.d.ts.map +1 -1
- package/dist/cli/input.js +60 -0
- package/dist/cli/input.js.map +1 -1
- package/dist/cli/main.d.ts +41 -2
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +294 -75
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/output/box.js +1 -1
- package/dist/cli/output/formatters.d.ts +10 -2
- package/dist/cli/output/formatters.d.ts.map +1 -1
- package/dist/cli/output/formatters.js +32 -9
- package/dist/cli/output/formatters.js.map +1 -1
- package/dist/cli/output/index.d.ts +1 -1
- package/dist/cli/output/index.d.ts.map +1 -1
- package/dist/cli/output/index.js +1 -1
- package/dist/cli/output/index.js.map +1 -1
- package/dist/cli/output/ink-runner.d.ts +3 -1
- package/dist/cli/output/ink-runner.d.ts.map +1 -1
- package/dist/cli/output/ink-runner.js +64 -28
- package/dist/cli/output/ink-runner.js.map +1 -1
- package/dist/cli/output/jsonl.d.ts +37 -0
- package/dist/cli/output/jsonl.d.ts.map +1 -1
- package/dist/cli/output/jsonl.js +6 -0
- package/dist/cli/output/jsonl.js.map +1 -1
- package/dist/cli/output/live-status.d.ts +48 -0
- package/dist/cli/output/live-status.d.ts.map +1 -0
- package/dist/cli/output/live-status.js +173 -0
- package/dist/cli/output/live-status.js.map +1 -0
- package/dist/cli/output/reporter.d.ts +4 -0
- package/dist/cli/output/reporter.d.ts.map +1 -1
- package/dist/cli/output/reporter.js +20 -3
- package/dist/cli/output/reporter.js.map +1 -1
- package/dist/cli/output/tasks.d.ts +8 -5
- package/dist/cli/output/tasks.d.ts.map +1 -1
- package/dist/cli/output/tasks.js +113 -71
- package/dist/cli/output/tasks.js.map +1 -1
- package/dist/cli/signals.d.ts +15 -0
- package/dist/cli/signals.d.ts.map +1 -0
- package/dist/cli/signals.js +26 -0
- package/dist/cli/signals.js.map +1 -0
- package/dist/config/loader.d.ts +48 -7
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/config/loader.js +228 -32
- package/dist/config/loader.js.map +1 -1
- package/dist/config/schema.d.ts +55 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +34 -2
- package/dist/config/schema.js.map +1 -1
- package/dist/diff/context.d.ts +9 -2
- package/dist/diff/context.d.ts.map +1 -1
- package/dist/diff/context.js +65 -17
- package/dist/diff/context.js.map +1 -1
- package/dist/evals/runner.d.ts.map +1 -1
- package/dist/evals/runner.js +16 -0
- package/dist/evals/runner.js.map +1 -1
- package/dist/event/context.d.ts.map +1 -1
- package/dist/event/context.js +1 -0
- package/dist/event/context.js.map +1 -1
- package/dist/event/schedule-context.d.ts.map +1 -1
- package/dist/event/schedule-context.js +1 -0
- package/dist/event/schedule-context.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/output/dedup.d.ts +8 -11
- package/dist/output/dedup.d.ts.map +1 -1
- package/dist/output/dedup.js +39 -37
- package/dist/output/dedup.js.map +1 -1
- package/dist/output/github-checks.d.ts +1 -0
- package/dist/output/github-checks.d.ts.map +1 -1
- package/dist/output/github-checks.js +9 -7
- package/dist/output/github-checks.js.map +1 -1
- package/dist/sdk/analyze.d.ts.map +1 -1
- package/dist/sdk/analyze.js +147 -277
- package/dist/sdk/analyze.js.map +1 -1
- package/dist/sdk/circuit-breaker.d.ts +26 -0
- package/dist/sdk/circuit-breaker.d.ts.map +1 -0
- package/dist/sdk/circuit-breaker.js +53 -0
- package/dist/sdk/circuit-breaker.js.map +1 -0
- package/dist/sdk/errors.d.ts +5 -0
- package/dist/sdk/errors.d.ts.map +1 -1
- package/dist/sdk/errors.js +27 -0
- package/dist/sdk/errors.js.map +1 -1
- package/dist/sdk/extract.d.ts +18 -9
- package/dist/sdk/extract.d.ts.map +1 -1
- package/dist/sdk/extract.js +95 -87
- package/dist/sdk/extract.js.map +1 -1
- package/dist/sdk/fix-quality.d.ts +5 -0
- package/dist/sdk/fix-quality.d.ts.map +1 -1
- package/dist/sdk/fix-quality.js +42 -23
- package/dist/sdk/fix-quality.js.map +1 -1
- package/dist/sdk/haiku.d.ts +6 -0
- package/dist/sdk/haiku.d.ts.map +1 -1
- package/dist/sdk/haiku.js +75 -49
- package/dist/sdk/haiku.js.map +1 -1
- package/dist/sdk/json-output.d.ts +31 -0
- package/dist/sdk/json-output.d.ts.map +1 -0
- package/dist/sdk/json-output.js +98 -0
- package/dist/sdk/json-output.js.map +1 -0
- package/dist/sdk/model-pricing.json +56 -16
- package/dist/sdk/post-process.d.ts +29 -0
- package/dist/sdk/post-process.d.ts.map +1 -0
- package/dist/sdk/post-process.js +65 -0
- package/dist/sdk/post-process.js.map +1 -0
- package/dist/sdk/prepare.d.ts.map +1 -1
- package/dist/sdk/prepare.js +4 -1
- package/dist/sdk/prepare.js.map +1 -1
- package/dist/sdk/pricing.d.ts +18 -0
- package/dist/sdk/pricing.d.ts.map +1 -1
- package/dist/sdk/pricing.js +108 -3
- package/dist/sdk/pricing.js.map +1 -1
- package/dist/sdk/prompt-sections.d.ts +56 -0
- package/dist/sdk/prompt-sections.d.ts.map +1 -0
- package/dist/sdk/prompt-sections.js +118 -0
- package/dist/sdk/prompt-sections.js.map +1 -0
- package/dist/sdk/prompt.d.ts +2 -17
- package/dist/sdk/prompt.d.ts.map +1 -1
- package/dist/sdk/prompt.js +15 -37
- package/dist/sdk/prompt.js.map +1 -1
- package/dist/sdk/report-files.d.ts +15 -0
- package/dist/sdk/report-files.d.ts.map +1 -0
- package/dist/sdk/report-files.js +20 -0
- package/dist/sdk/report-files.js.map +1 -0
- package/dist/sdk/runner.d.ts +9 -1
- package/dist/sdk/runner.d.ts.map +1 -1
- package/dist/sdk/runner.js +6 -0
- package/dist/sdk/runner.js.map +1 -1
- package/dist/sdk/runtimes/claude.d.ts +3 -0
- package/dist/sdk/runtimes/claude.d.ts.map +1 -0
- package/dist/sdk/runtimes/claude.js +376 -0
- package/dist/sdk/runtimes/claude.js.map +1 -0
- package/dist/sdk/runtimes/index.d.ts +12 -0
- package/dist/sdk/runtimes/index.d.ts.map +1 -0
- package/dist/sdk/runtimes/index.js +22 -0
- package/dist/sdk/runtimes/index.js.map +1 -0
- package/dist/sdk/runtimes/types.d.ts +116 -0
- package/dist/sdk/runtimes/types.d.ts.map +1 -0
- package/dist/sdk/runtimes/types.js +17 -0
- package/dist/sdk/runtimes/types.js.map +1 -0
- package/dist/sdk/types.d.ts +23 -2
- package/dist/sdk/types.d.ts.map +1 -1
- package/dist/sdk/types.js.map +1 -1
- package/dist/sdk/usage.d.ts +21 -6
- package/dist/sdk/usage.d.ts.map +1 -1
- package/dist/sdk/usage.js +36 -23
- package/dist/sdk/usage.js.map +1 -1
- package/dist/sdk/verify.d.ts +25 -0
- package/dist/sdk/verify.d.ts.map +1 -0
- package/dist/sdk/verify.js +226 -0
- package/dist/sdk/verify.js.map +1 -0
- package/dist/skill-builder/agentic.d.ts +33 -0
- package/dist/skill-builder/agentic.d.ts.map +1 -0
- package/dist/skill-builder/agentic.js +240 -0
- package/dist/skill-builder/agentic.js.map +1 -0
- package/dist/skill-builder/authoring-provider.d.ts +5 -0
- package/dist/skill-builder/authoring-provider.d.ts.map +1 -0
- package/dist/skill-builder/authoring-provider.js +70 -0
- package/dist/skill-builder/authoring-provider.js.map +1 -0
- package/dist/skill-builder/definition.d.ts +46 -0
- package/dist/skill-builder/definition.d.ts.map +1 -0
- package/dist/skill-builder/definition.js +171 -0
- package/dist/skill-builder/definition.js.map +1 -0
- package/dist/skill-builder/outline-contract.d.ts +113 -0
- package/dist/skill-builder/outline-contract.d.ts.map +1 -0
- package/dist/skill-builder/outline-contract.js +73 -0
- package/dist/skill-builder/outline-contract.js.map +1 -0
- package/dist/skill-builder/outline-state.d.ts +158 -0
- package/dist/skill-builder/outline-state.d.ts.map +1 -0
- package/dist/skill-builder/outline-state.js +87 -0
- package/dist/skill-builder/outline-state.js.map +1 -0
- package/dist/skill-builder/outline.d.ts +36 -0
- package/dist/skill-builder/outline.d.ts.map +1 -0
- package/dist/skill-builder/outline.js +345 -0
- package/dist/skill-builder/outline.js.map +1 -0
- package/dist/skill-builder/skill-contract.d.ts +97 -0
- package/dist/skill-builder/skill-contract.d.ts.map +1 -0
- package/dist/skill-builder/skill-contract.js +58 -0
- package/dist/skill-builder/skill-contract.js.map +1 -0
- package/dist/skill-builder/skill-prompts.d.ts +61 -0
- package/dist/skill-builder/skill-prompts.d.ts.map +1 -0
- package/dist/skill-builder/skill-prompts.js +285 -0
- package/dist/skill-builder/skill-prompts.js.map +1 -0
- package/dist/skill-builder/skill.d.ts +23 -0
- package/dist/skill-builder/skill.d.ts.map +1 -0
- package/dist/skill-builder/skill.js +563 -0
- package/dist/skill-builder/skill.js.map +1 -0
- package/dist/skills/index.d.ts +2 -2
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +1 -1
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/loader.d.ts +20 -6
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +88 -141
- package/dist/skills/loader.js.map +1 -1
- package/dist/skills/remote.d.ts +11 -7
- package/dist/skills/remote.d.ts.map +1 -1
- package/dist/skills/remote.js +62 -162
- package/dist/skills/remote.js.map +1 -1
- package/dist/triggers/matcher.d.ts.map +1 -1
- package/dist/triggers/matcher.js +28 -15
- package/dist/triggers/matcher.js.map +1 -1
- package/dist/types/index.d.ts +40 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +11 -0
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/path.d.ts +17 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/path.js +36 -0
- package/dist/utils/path.js.map +1 -0
- package/package.json +8 -8
- package/policies/README.md +22 -0
- package/policies/code-comments.md +20 -0
- package/policies/policy-template.md +14 -0
- package/skills/warden/SPEC.md +112 -0
- package/skills/warden/references/cli-reference.md +2 -2
- package/skills/warden/references/config-schema.md +29 -13
- package/skills/warden/references/configuration.md +20 -8
- package/skills/warden/references/creating-skills.md +3 -0
- package/skills/warden-sweep/SPEC.md +126 -0
- package/src/builtin-skills/security-review/SKILL.md +81 -0
- package/src/builtin-skills/security-review/SPEC.md +77 -0
- package/src/builtin-skills/security-review/references/github-workflows.md +186 -0
- package/src/builtin-skills/security-review/references/javascript-typescript.md +69 -0
- package/src/builtin-skills/security-review/references/python.md +70 -0
- package/src/internal-skills/skill-writer/EVAL.md +124 -0
- package/src/internal-skills/skill-writer/SKILL.md +159 -0
- package/src/internal-skills/skill-writer/SOURCES.md +94 -0
- package/src/internal-skills/skill-writer/SPEC.md +153 -0
- package/src/internal-skills/skill-writer/references/artifact-layouts/argument-driven-skill-layout.md +32 -0
- package/src/internal-skills/skill-writer/references/artifact-layouts/asset-template-skill-layout.md +30 -0
- package/src/internal-skills/skill-writer/references/artifact-layouts/inline-skill-layout.md +28 -0
- package/src/internal-skills/skill-writer/references/artifact-layouts/reference-backed-skill-layout.md +35 -0
- package/src/internal-skills/skill-writer/references/artifact-layouts/script-backed-skill-layout.md +31 -0
- package/src/internal-skills/skill-writer/references/authoring-path.md +91 -0
- package/src/internal-skills/skill-writer/references/claude-code/argument-substitutions.md +20 -0
- package/src/internal-skills/skill-writer/references/claude-code/dynamic-context.md +16 -0
- package/src/internal-skills/skill-writer/references/claude-code/frontmatter-and-invocation.md +33 -0
- package/src/internal-skills/skill-writer/references/claude-code/hook-backed-skills.md +28 -0
- package/src/internal-skills/skill-writer/references/claude-code/subagent-fork-skills.md +22 -0
- package/src/internal-skills/skill-writer/references/description-optimization.md +28 -0
- package/src/internal-skills/skill-writer/references/design-principles.md +74 -0
- package/src/internal-skills/skill-writer/references/evaluation-path.md +73 -0
- package/src/internal-skills/skill-writer/references/examples/documentation-skill.md +70 -0
- package/src/internal-skills/skill-writer/references/examples/evaluator-loop-skill.md +38 -0
- package/src/internal-skills/skill-writer/references/examples/hook-backed-skill.md +39 -0
- package/src/internal-skills/skill-writer/references/examples/router-skill.md +41 -0
- package/src/internal-skills/skill-writer/references/examples/security-review-skill.md +69 -0
- package/src/internal-skills/skill-writer/references/examples/subagent-fork-skill.md +39 -0
- package/src/internal-skills/skill-writer/references/examples/workflow-process-skill.md +65 -0
- package/src/internal-skills/skill-writer/references/execution-shapes.md +68 -0
- package/src/internal-skills/skill-writer/references/iteration-evidence.md +82 -0
- package/src/internal-skills/skill-writer/references/iteration-path.md +40 -0
- package/src/internal-skills/skill-writer/references/mode-selection.md +67 -0
- package/src/internal-skills/skill-writer/references/output-contracts.md +68 -0
- package/src/internal-skills/skill-writer/references/reference-architecture.md +71 -0
- package/src/internal-skills/skill-writer/references/registration-validation.md +67 -0
- package/src/internal-skills/skill-writer/references/source-discovery.md +60 -0
- package/src/internal-skills/skill-writer/references/spec-template.md +118 -0
- package/src/internal-skills/skill-writer/references/structure-troubleshooting.md +111 -0
- package/src/internal-skills/skill-writer/references/synthesis-path.md +119 -0
- package/src/internal-skills/skill-writer/references/workflow-mechanics/evaluator-loops.md +25 -0
- package/src/internal-skills/skill-writer/references/workflow-mechanics/orchestrator-workers.md +25 -0
- package/src/internal-skills/skill-writer/references/workflow-mechanics/parallel-workflows.md +21 -0
- package/src/internal-skills/skill-writer/references/workflow-mechanics/plan-validate-execute.md +26 -0
- package/src/internal-skills/skill-writer/references/workflow-mechanics/prompt-chaining.md +24 -0
- package/src/internal-skills/skill-writer/references/workflow-mechanics/routing-workflows.md +28 -0
- package/src/internal-skills/skill-writer/references/workflow-mechanics/validation-loops.md +26 -0
- package/src/internal-skills/skill-writer/scripts/quick_validate.py +158 -0
- package/src/internal-skills/skill-writer/scripts/quick_validate_test.py +79 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../src/sdk/prepare.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAML,KAAK,eAAe,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAExF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,YAAY,EAAE,CAazE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,YAAY,EACrB,OAAO,GAAE,mBAAwB,GAChC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../src/sdk/prepare.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAML,KAAK,eAAe,EACrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAExF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,YAAY,EAAE,CAazE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,YAAY,EACrB,OAAO,GAAE,mBAAwB,GAChC,kBAAkB,CAoEpB"}
|
package/dist/sdk/prepare.js
CHANGED
|
@@ -67,7 +67,10 @@ export function prepareFiles(context, options = {}) {
|
|
|
67
67
|
maxChunkSize: chunking?.coalesce?.maxChunkSize,
|
|
68
68
|
})
|
|
69
69
|
: splitHunks;
|
|
70
|
-
const hunksWithContext = expandDiffContext(context.repoPath, { ...diff, hunks },
|
|
70
|
+
const hunksWithContext = expandDiffContext(context.repoPath, { ...diff, hunks }, {
|
|
71
|
+
contextLines,
|
|
72
|
+
contentSource: context.diffContextSource,
|
|
73
|
+
});
|
|
71
74
|
allHunks.push(...hunksWithContext);
|
|
72
75
|
}
|
|
73
76
|
return {
|
package/dist/sdk/prepare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../../src/sdk/prepare.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,eAAe,GAEhB,MAAM,kBAAkB,CAAC;AA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,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,EAAE,CAAC;YAC7F,YAAY,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;YAClE,SAAS;QACX,CAAC;QAED,sEAAsE;QACtE,MAAM,UAAU,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,EAAE;YAC7C,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY;SAC/C,CAAC,CAAC;QAEH,gEAAgE;QAChE,MAAM,eAAe,GAAG,QAAQ,EAAE,QAAQ,EAAE,OAAO,KAAK,KAAK,CAAC;QAC9D,MAAM,KAAK,GAAG,eAAe;YAC3B,CAAC,CAAC,aAAa,CAAC,UAAU,EAAE;gBACxB,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW;gBAC5C,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY;aAC/C,CAAC;YACJ,CAAC,CAAC,UAAU,CAAC;QAEf,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,EAAE;YAC/E,YAAY;YACZ,aAAa,EAAE,OAAO,CAAC,iBAAiB;SACzC,CAAC,CAAC;QACH,QAAQ,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,CAAC;IACrC,CAAC;IAED,OAAO;QACL,KAAK,EAAE,gBAAgB,CAAC,QAAQ,CAAC;QACjC,YAAY;KACb,CAAC;AACJ,CAAC"}
|
package/dist/sdk/pricing.d.ts
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import type { UsageStats } from '../types/index.js';
|
|
2
|
+
export interface UsageCostBreakdown {
|
|
3
|
+
freshInputUSD: number;
|
|
4
|
+
outputUSD: number;
|
|
5
|
+
cacheReadUSD: number;
|
|
6
|
+
cacheCreationUSD: number;
|
|
7
|
+
cacheCreation5mUSD: number;
|
|
8
|
+
cacheCreation1hUSD: number;
|
|
9
|
+
webSearchUSD: number;
|
|
10
|
+
totalUSD: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function estimateUsageCostBreakdown(model: string | undefined, usage: UsageStats): UsageCostBreakdown | undefined;
|
|
2
13
|
/**
|
|
3
14
|
* Usage shape returned by the Anthropic Messages API.
|
|
4
15
|
*/
|
|
@@ -7,6 +18,13 @@ interface ApiUsage {
|
|
|
7
18
|
output_tokens: number;
|
|
8
19
|
cache_read_input_tokens?: number | null;
|
|
9
20
|
cache_creation_input_tokens?: number | null;
|
|
21
|
+
cache_creation?: {
|
|
22
|
+
ephemeral_1h_input_tokens?: number | null;
|
|
23
|
+
ephemeral_5m_input_tokens?: number | null;
|
|
24
|
+
} | null;
|
|
25
|
+
server_tool_use?: {
|
|
26
|
+
web_search_requests?: number | null;
|
|
27
|
+
} | null;
|
|
10
28
|
}
|
|
11
29
|
/**
|
|
12
30
|
* Convert Anthropic API usage to our UsageStats format.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../../src/sdk/pricing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AA+
|
|
1
|
+
{"version":3,"file":"pricing.d.ts","sourceRoot":"","sources":["../../src/sdk/pricing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAiBpD,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB;AA+ED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,KAAK,EAAE,UAAU,GAChB,kBAAkB,GAAG,SAAS,CA+ChC;AAED;;GAEG;AACH,UAAU,QAAQ;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,2BAA2B,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,cAAc,CAAC,EAAE;QACf,yBAAyB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1C,yBAAyB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC3C,GAAG,IAAI,CAAC;IACT,eAAe,CAAC,EAAE;QAChB,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KACrC,GAAG,IAAI,CAAC;CACV;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,UAAU,CA8C1E"}
|
package/dist/sdk/pricing.js
CHANGED
|
@@ -10,8 +10,98 @@ const MODEL_PRICING = Object.fromEntries(Object.entries(rawPricing).map(([id, p]
|
|
|
10
10
|
outputPerToken: p.outputPerMTok / 1_000_000,
|
|
11
11
|
cacheReadPerToken: p.cacheReadPerMTok / 1_000_000,
|
|
12
12
|
cacheCreationPerToken: p.cacheWritePerMTok / 1_000_000,
|
|
13
|
+
cacheCreation1hPerToken: p.cacheWrite1hPerMTok / 1_000_000,
|
|
14
|
+
webSearchPerRequest: p.webSearchPer1K / 1_000,
|
|
13
15
|
},
|
|
14
16
|
]));
|
|
17
|
+
const MODEL_ALIASES = {
|
|
18
|
+
'claude-sonnet-4': 'claude-sonnet-4-0',
|
|
19
|
+
'claude-4-sonnet': 'claude-sonnet-4-0',
|
|
20
|
+
'claude-sonnet-4-6': 'claude-sonnet-4-5',
|
|
21
|
+
'claude-opus-4': 'claude-opus-4-0',
|
|
22
|
+
'claude-4-opus': 'claude-opus-4-0',
|
|
23
|
+
'claude-opus-4-6': 'claude-opus-4-5',
|
|
24
|
+
};
|
|
25
|
+
function hasModelPricing(pricing) {
|
|
26
|
+
return pricing !== undefined && (pricing.inputPerToken > 0 ||
|
|
27
|
+
pricing.outputPerToken > 0 ||
|
|
28
|
+
pricing.cacheReadPerToken > 0 ||
|
|
29
|
+
pricing.cacheCreationPerToken > 0 ||
|
|
30
|
+
pricing.cacheCreation1hPerToken > 0);
|
|
31
|
+
}
|
|
32
|
+
function lookupModelPricing(model) {
|
|
33
|
+
const pricing = MODEL_PRICING[model];
|
|
34
|
+
return hasModelPricing(pricing) ? pricing : undefined;
|
|
35
|
+
}
|
|
36
|
+
function normalizeModelId(model) {
|
|
37
|
+
const undated = model.replace(/-\d{8}$/, '');
|
|
38
|
+
if (lookupModelPricing(undated))
|
|
39
|
+
return undated;
|
|
40
|
+
return MODEL_ALIASES[undated] ?? undated;
|
|
41
|
+
}
|
|
42
|
+
function applyLongContextPricing(model, pricing, inputTokens) {
|
|
43
|
+
const canonical = normalizeModelId(model);
|
|
44
|
+
const sonnetLongContext = inputTokens > 200_000 &&
|
|
45
|
+
(canonical === 'claude-sonnet-4-0' || canonical === 'claude-sonnet-4-5');
|
|
46
|
+
if (!sonnetLongContext) {
|
|
47
|
+
return pricing;
|
|
48
|
+
}
|
|
49
|
+
const inputPerToken = pricing.inputPerToken * 2;
|
|
50
|
+
return {
|
|
51
|
+
...pricing,
|
|
52
|
+
inputPerToken,
|
|
53
|
+
outputPerToken: pricing.outputPerToken * 1.5,
|
|
54
|
+
cacheReadPerToken: inputPerToken * 0.1,
|
|
55
|
+
cacheCreationPerToken: inputPerToken * 1.25,
|
|
56
|
+
cacheCreation1hPerToken: inputPerToken * 2,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function getModelPricing(model, inputTokens = 0) {
|
|
60
|
+
const exact = lookupModelPricing(model);
|
|
61
|
+
if (exact)
|
|
62
|
+
return applyLongContextPricing(model, exact, inputTokens);
|
|
63
|
+
const canonical = normalizeModelId(model);
|
|
64
|
+
const pricing = lookupModelPricing(canonical) ?? lookupModelPricing(`${canonical}-latest`);
|
|
65
|
+
return pricing ? applyLongContextPricing(model, pricing, inputTokens) : undefined;
|
|
66
|
+
}
|
|
67
|
+
export function estimateUsageCostBreakdown(model, usage) {
|
|
68
|
+
if (!model)
|
|
69
|
+
return undefined;
|
|
70
|
+
const cacheReadInputTokens = usage.cacheReadInputTokens ?? 0;
|
|
71
|
+
const cacheCreation5mInputTokens = usage.cacheCreation5mInputTokens ?? 0;
|
|
72
|
+
const cacheCreation1hInputTokens = usage.cacheCreation1hInputTokens ?? 0;
|
|
73
|
+
const cacheCreationInputTokens = Math.max(usage.cacheCreationInputTokens ?? 0, cacheCreation5mInputTokens + cacheCreation1hInputTokens);
|
|
74
|
+
const cacheCreationInputTokensByTier = cacheCreation5mInputTokens + cacheCreation1hInputTokens;
|
|
75
|
+
const uncategorizedCacheCreationInputTokens = Math.max(0, cacheCreationInputTokens - cacheCreationInputTokensByTier);
|
|
76
|
+
const freshInputTokens = Math.max(0, usage.inputTokens - cacheReadInputTokens - cacheCreationInputTokens);
|
|
77
|
+
const webSearchRequests = usage.webSearchRequests ?? 0;
|
|
78
|
+
const pricing = getModelPricing(model, usage.inputTokens);
|
|
79
|
+
if (!pricing)
|
|
80
|
+
return undefined;
|
|
81
|
+
const freshInputUSD = freshInputTokens * pricing.inputPerToken;
|
|
82
|
+
const outputUSD = usage.outputTokens * pricing.outputPerToken;
|
|
83
|
+
const cacheReadUSD = cacheReadInputTokens * pricing.cacheReadPerToken;
|
|
84
|
+
const cacheCreationUSD = uncategorizedCacheCreationInputTokens * pricing.cacheCreationPerToken;
|
|
85
|
+
const cacheCreation5mUSD = cacheCreation5mInputTokens * pricing.cacheCreationPerToken;
|
|
86
|
+
const cacheCreation1hUSD = cacheCreation1hInputTokens * pricing.cacheCreation1hPerToken;
|
|
87
|
+
const webSearchUSD = webSearchRequests * pricing.webSearchPerRequest;
|
|
88
|
+
return {
|
|
89
|
+
freshInputUSD,
|
|
90
|
+
outputUSD,
|
|
91
|
+
cacheReadUSD,
|
|
92
|
+
cacheCreationUSD,
|
|
93
|
+
cacheCreation5mUSD,
|
|
94
|
+
cacheCreation1hUSD,
|
|
95
|
+
webSearchUSD,
|
|
96
|
+
totalUSD: freshInputUSD +
|
|
97
|
+
outputUSD +
|
|
98
|
+
cacheReadUSD +
|
|
99
|
+
cacheCreationUSD +
|
|
100
|
+
cacheCreation5mUSD +
|
|
101
|
+
cacheCreation1hUSD +
|
|
102
|
+
webSearchUSD,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
15
105
|
/**
|
|
16
106
|
* Convert Anthropic API usage to our UsageStats format.
|
|
17
107
|
* Calculates cost from token counts using model pricing.
|
|
@@ -22,12 +112,22 @@ const MODEL_PRICING = Object.fromEntries(Object.entries(rawPricing).map(([id, p]
|
|
|
22
112
|
* being subsets of that total.
|
|
23
113
|
*/
|
|
24
114
|
export function apiUsageToStats(model, usage) {
|
|
25
|
-
const pricing = MODEL_PRICING[model];
|
|
26
115
|
const outputTokens = usage.output_tokens;
|
|
27
116
|
const cacheReadInputTokens = usage.cache_read_input_tokens ?? 0;
|
|
28
|
-
const
|
|
117
|
+
const rawCacheCreationInputTokens = usage.cache_creation_input_tokens ?? 0;
|
|
118
|
+
const tieredCacheCreation5mInputTokens = usage.cache_creation?.ephemeral_5m_input_tokens ?? 0;
|
|
119
|
+
const cacheCreation1hInputTokens = usage.cache_creation?.ephemeral_1h_input_tokens ?? 0;
|
|
120
|
+
const hasTieredCacheCreation = usage.cache_creation !== undefined && usage.cache_creation !== null;
|
|
121
|
+
const tieredCacheCreationInputTokens = tieredCacheCreation5mInputTokens + cacheCreation1hInputTokens;
|
|
122
|
+
const cacheCreationInputTokens = Math.max(rawCacheCreationInputTokens, tieredCacheCreationInputTokens);
|
|
123
|
+
const cacheCreation5mInputTokens = hasTieredCacheCreation
|
|
124
|
+
? tieredCacheCreation5mInputTokens
|
|
125
|
+
: rawCacheCreationInputTokens;
|
|
126
|
+
const uncategorizedCacheCreationInputTokens = Math.max(0, cacheCreationInputTokens - cacheCreation5mInputTokens - cacheCreation1hInputTokens);
|
|
127
|
+
const webSearchRequests = usage.server_tool_use?.web_search_requests ?? 0;
|
|
29
128
|
// inputTokens is the total: raw API input_tokens + cache subsets.
|
|
30
129
|
const inputTokens = usage.input_tokens + cacheReadInputTokens + cacheCreationInputTokens;
|
|
130
|
+
const pricing = getModelPricing(model, inputTokens);
|
|
31
131
|
// Cost: deduct cache subsets from total to get the non-cached portion,
|
|
32
132
|
// then charge each category at its respective rate.
|
|
33
133
|
let costUSD = 0;
|
|
@@ -37,13 +137,18 @@ export function apiUsageToStats(model, usage) {
|
|
|
37
137
|
freshInputTokens * pricing.inputPerToken +
|
|
38
138
|
outputTokens * pricing.outputPerToken +
|
|
39
139
|
cacheReadInputTokens * pricing.cacheReadPerToken +
|
|
40
|
-
|
|
140
|
+
(cacheCreation5mInputTokens + uncategorizedCacheCreationInputTokens) * pricing.cacheCreationPerToken +
|
|
141
|
+
cacheCreation1hInputTokens * pricing.cacheCreation1hPerToken +
|
|
142
|
+
webSearchRequests * pricing.webSearchPerRequest;
|
|
41
143
|
}
|
|
42
144
|
return {
|
|
43
145
|
inputTokens,
|
|
44
146
|
outputTokens,
|
|
45
147
|
cacheReadInputTokens,
|
|
46
148
|
cacheCreationInputTokens,
|
|
149
|
+
cacheCreation5mInputTokens: cacheCreation5mInputTokens + uncategorizedCacheCreationInputTokens,
|
|
150
|
+
cacheCreation1hInputTokens,
|
|
151
|
+
webSearchRequests,
|
|
47
152
|
costUSD,
|
|
48
153
|
};
|
|
49
154
|
}
|
package/dist/sdk/pricing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../../src/sdk/pricing.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,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BAA2B,EAAE,8BAA8B,CAAC,CAAC;IACvG,MAAM,0BAA0B,GAAG,sBAAsB;QACvD,CAAC,CAAC,gCAAgC;QAClC,CAAC,CAAC,2BAA2B,CAAC;IAChC,MAAM,qCAAqC,GAAG,IAAI,CAAC,GAAG,CACpD,CAAC,EACD,wBAAwB,GAAG,0BAA0B,GAAG,0BAA0B,CACnF,CAAC;IACF,MAAM,iBAAiB,GAAG,KAAK,CAAC,eAAe,EAAE,mBAAmB,IAAI,CAAC,CAAC;IAE1E,kEAAkE;IAClE,MAAM,WAAW,GAAG,KAAK,CAAC,YAAY,GAAG,oBAAoB,GAAG,wBAAwB,CAAC;IACzF,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IAEpD,uEAAuE;IACvE,oDAAoD;IACpD,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,gBAAgB,GAAG,WAAW,GAAG,oBAAoB,GAAG,wBAAwB,CAAC;QACvF,OAAO;YACL,gBAAgB,GAAG,OAAO,CAAC,aAAa;gBACxC,YAAY,GAAG,OAAO,CAAC,cAAc;gBACrC,oBAAoB,GAAG,OAAO,CAAC,iBAAiB;gBAChD,CAAC,0BAA0B,GAAG,qCAAqC,CAAC,GAAG,OAAO,CAAC,qBAAqB;gBACpG,0BAA0B,GAAG,OAAO,CAAC,uBAAuB;gBAC5D,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IACpD,CAAC;IAED,OAAO;QACL,WAAW;QACX,YAAY;QACZ,oBAAoB;QACpB,wBAAwB;QACxB,0BAA0B,EAAE,0BAA0B,GAAG,qCAAqC;QAC9F,0BAA0B;QAC1B,iBAAiB;QACjB,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type Finding } from '../types/index.js';
|
|
2
|
+
export interface PromptPRContext {
|
|
3
|
+
/** All files being changed in the PR */
|
|
4
|
+
changedFiles: string[];
|
|
5
|
+
/** PR title - explains what the change does */
|
|
6
|
+
title?: string;
|
|
7
|
+
/** PR description/body - explains why and provides additional context */
|
|
8
|
+
body?: string | null;
|
|
9
|
+
/** Max number of changed files to list. 0 disables the section. Default: 50. */
|
|
10
|
+
maxContextFiles?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Build a tagged prompt section, omitting empty content.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildTaggedSection(tag: string, content: string | string[]): string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Join prompt sections with consistent spacing, skipping omitted sections.
|
|
18
|
+
*/
|
|
19
|
+
export declare function joinPromptSections(sections: (string | undefined)[]): string;
|
|
20
|
+
/**
|
|
21
|
+
* Build a tagged JSON-only output contract.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildJsonOutputSection(instructions: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Build tagged pull request context shared by Warden agents.
|
|
26
|
+
*/
|
|
27
|
+
export declare function buildPullRequestContextSection(prContext?: PromptPRContext): string | undefined;
|
|
28
|
+
export interface FileListSectionOptions {
|
|
29
|
+
currentFile?: string;
|
|
30
|
+
maxFiles?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Build a tagged file list section with optional current-file exclusion.
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildFileListSection(tag: string, files: string[], options?: FileListSectionOptions): string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Build tagged changed-file context shared by Warden agents.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildChangedFilesSection(prContext: PromptPRContext | undefined, currentFile?: string): string | undefined;
|
|
40
|
+
interface PromptFindingFormatOptions {
|
|
41
|
+
includeSeverity?: boolean;
|
|
42
|
+
includeConfidence?: boolean;
|
|
43
|
+
includeVerification?: boolean;
|
|
44
|
+
locationStyle?: 'line' | 'range';
|
|
45
|
+
snippet?: (finding: Finding) => string | undefined;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Format one finding for prompt lists shared by auxiliary agents.
|
|
49
|
+
*/
|
|
50
|
+
export declare function formatFindingForPrompt(finding: Finding, options?: PromptFindingFormatOptions): string;
|
|
51
|
+
/**
|
|
52
|
+
* Format findings as a stable 1-based prompt list.
|
|
53
|
+
*/
|
|
54
|
+
export declare function formatIndexedFindingsForPrompt(findings: Finding[], options?: PromptFindingFormatOptions): string;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=prompt-sections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-sections.d.ts","sourceRoot":"","sources":["../../src/sdk/prompt-sections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE9D,MAAM,WAAW,eAAe;IAC9B,wCAAwC;IACxC,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAID;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAO9F;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAE3E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAWnE;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,CAAC,EAAE,eAAe,GAAG,MAAM,GAAG,SAAS,CAa9F;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,GAAE,sBAA2B,GACnC,MAAM,GAAG,SAAS,CAepB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,eAAe,GAAG,SAAS,EACtC,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAMpB;AAED,UAAU,0BAA0B;IAClC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACjC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAC;CACpD;AAaD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,0BAA+B,GACvC,MAAM,CAqBR;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,GAAE,0BAA+B,GACvC,MAAM,CAIR"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { findingLine } from '../types/index.js';
|
|
2
|
+
const MAX_BODY_LENGTH = 1000;
|
|
3
|
+
/**
|
|
4
|
+
* Build a tagged prompt section, omitting empty content.
|
|
5
|
+
*/
|
|
6
|
+
export function buildTaggedSection(tag, content) {
|
|
7
|
+
const body = Array.isArray(content) ? content.join('\n') : content;
|
|
8
|
+
if (body.trim().length === 0)
|
|
9
|
+
return undefined;
|
|
10
|
+
return `<${tag}>
|
|
11
|
+
${body}
|
|
12
|
+
</${tag}>`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Join prompt sections with consistent spacing, skipping omitted sections.
|
|
16
|
+
*/
|
|
17
|
+
export function joinPromptSections(sections) {
|
|
18
|
+
return sections.filter((section) => Boolean(section)).join('\n\n');
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Build a tagged JSON-only output contract.
|
|
22
|
+
*/
|
|
23
|
+
export function buildJsonOutputSection(instructions) {
|
|
24
|
+
const lines = [
|
|
25
|
+
'Return only valid JSON. Do not include markdown, prose, code fences, or explanations.',
|
|
26
|
+
];
|
|
27
|
+
const trimmedInstructions = instructions.trim();
|
|
28
|
+
if (trimmedInstructions.length > 0) {
|
|
29
|
+
lines.push('', trimmedInstructions);
|
|
30
|
+
}
|
|
31
|
+
return `<output_format>
|
|
32
|
+
${lines.join('\n')}
|
|
33
|
+
</output_format>`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build tagged pull request context shared by Warden agents.
|
|
37
|
+
*/
|
|
38
|
+
export function buildPullRequestContextSection(prContext) {
|
|
39
|
+
if (!prContext?.title)
|
|
40
|
+
return undefined;
|
|
41
|
+
const lines = [`<title>${prContext.title}</title>`];
|
|
42
|
+
if (prContext.body) {
|
|
43
|
+
const body = prContext.body.length > MAX_BODY_LENGTH
|
|
44
|
+
? `${prContext.body.slice(0, MAX_BODY_LENGTH)}...`
|
|
45
|
+
: prContext.body;
|
|
46
|
+
lines.push('<body>', body, '</body>');
|
|
47
|
+
}
|
|
48
|
+
return buildTaggedSection('pull_request_context', lines);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Build a tagged file list section with optional current-file exclusion.
|
|
52
|
+
*/
|
|
53
|
+
export function buildFileListSection(tag, files, options = {}) {
|
|
54
|
+
const maxFiles = options.maxFiles ?? 50;
|
|
55
|
+
const visibleFiles = options.currentFile
|
|
56
|
+
? files.filter((f) => f !== options.currentFile)
|
|
57
|
+
: files;
|
|
58
|
+
if (visibleFiles.length === 0 || maxFiles === 0)
|
|
59
|
+
return undefined;
|
|
60
|
+
const displayFiles = visibleFiles.slice(0, maxFiles);
|
|
61
|
+
const remaining = visibleFiles.length - displayFiles.length;
|
|
62
|
+
const lines = displayFiles.map((f) => `- ${f}`);
|
|
63
|
+
if (remaining > 0) {
|
|
64
|
+
lines.push(`- ... and ${remaining} more`);
|
|
65
|
+
}
|
|
66
|
+
return buildTaggedSection(tag, lines);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Build tagged changed-file context shared by Warden agents.
|
|
70
|
+
*/
|
|
71
|
+
export function buildChangedFilesSection(prContext, currentFile) {
|
|
72
|
+
if (!prContext)
|
|
73
|
+
return undefined;
|
|
74
|
+
return buildFileListSection('changed_files', prContext.changedFiles, {
|
|
75
|
+
currentFile,
|
|
76
|
+
maxFiles: prContext.maxContextFiles ?? 50,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function formatFindingLocation(finding, style) {
|
|
80
|
+
const loc = finding.location;
|
|
81
|
+
if (!loc)
|
|
82
|
+
return 'general';
|
|
83
|
+
if (style === 'range' && loc.endLine) {
|
|
84
|
+
return `${loc.path}:${loc.startLine}-${loc.endLine}`;
|
|
85
|
+
}
|
|
86
|
+
return `${loc.path}:${findingLine(finding)}`;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Format one finding for prompt lists shared by auxiliary agents.
|
|
90
|
+
*/
|
|
91
|
+
export function formatFindingForPrompt(finding, options = {}) {
|
|
92
|
+
const details = [];
|
|
93
|
+
if (options.includeSeverity)
|
|
94
|
+
details.push(`(${finding.severity})`);
|
|
95
|
+
if (options.includeConfidence && finding.confidence) {
|
|
96
|
+
details.push(`[confidence: ${finding.confidence}]`);
|
|
97
|
+
}
|
|
98
|
+
const prefix = details.length > 0 ? `${details.join(' ')} ` : '';
|
|
99
|
+
const location = formatFindingLocation(finding, options.locationStyle ?? 'line');
|
|
100
|
+
let text = `[${location}] ${prefix}"${finding.title}" - ${finding.description}`;
|
|
101
|
+
if (options.includeVerification && finding.verification) {
|
|
102
|
+
text += ` Verification: ${finding.verification}`;
|
|
103
|
+
}
|
|
104
|
+
const snippet = options.snippet?.(finding);
|
|
105
|
+
if (snippet) {
|
|
106
|
+
text += `\n Code: ${snippet.split('\n').join('\n ')}`;
|
|
107
|
+
}
|
|
108
|
+
return text;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Format findings as a stable 1-based prompt list.
|
|
112
|
+
*/
|
|
113
|
+
export function formatIndexedFindingsForPrompt(findings, options = {}) {
|
|
114
|
+
return findings.map((finding, index) => {
|
|
115
|
+
return `${index + 1}. ${formatFindingForPrompt(finding, options)}`;
|
|
116
|
+
}).join('\n');
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=prompt-sections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-sections.js","sourceRoot":"","sources":["../../src/sdk/prompt-sections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAgB,MAAM,mBAAmB,CAAC;AAa9D,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW,EAAE,OAA0B;IACxE,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACnE,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAE/C,OAAO,IAAI,GAAG;EACd,IAAI;IACF,GAAG,GAAG,CAAC;AACX,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgC;IACjE,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAqB,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACxF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,YAAoB;IACzD,MAAM,KAAK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AAC,KAAK,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;IACrE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
|
package/dist/sdk/prompt.d.ts
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
1
|
import type { SkillDefinition } from '../config/schema.js';
|
|
2
2
|
import { type HunkWithContext } from '../diff/index.js';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
*
|
|
6
|
-
* The title and body (like a commit message) help explain the _intent_ of the
|
|
7
|
-
* changes to the agent, enabling it to better understand what the author was
|
|
8
|
-
* trying to accomplish and identify issues that conflict with that intent.
|
|
9
|
-
*/
|
|
10
|
-
export interface PRPromptContext {
|
|
11
|
-
/** All files being changed in the PR */
|
|
12
|
-
changedFiles: string[];
|
|
13
|
-
/** PR title - explains what the change does */
|
|
14
|
-
title?: string;
|
|
15
|
-
/** PR description/body - explains why and provides additional context */
|
|
16
|
-
body?: string | null;
|
|
17
|
-
/** Max number of "other files" to list in the prompt. 0 disables the section. Default: 50. */
|
|
18
|
-
maxContextFiles?: number;
|
|
19
|
-
}
|
|
3
|
+
import { type PromptPRContext } from './prompt-sections.js';
|
|
4
|
+
export type PRPromptContext = PromptPRContext;
|
|
20
5
|
/**
|
|
21
6
|
* Builds the system prompt for hunk-based analysis.
|
|
22
7
|
*
|
package/dist/sdk/prompt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/sdk/prompt.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/sdk/prompt.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAyB,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAE9B,MAAM,MAAM,eAAe,GAAG,eAAe,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CA6EpE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,eAAe,EACxB,SAAS,CAAC,EAAE,eAAe,GAC1B,MAAM,CAYR"}
|
package/dist/sdk/prompt.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { formatHunkForAnalysis } from '../diff/index.js';
|
|
4
|
+
import { buildChangedFilesSection, buildJsonOutputSection, buildPullRequestContextSection, joinPromptSections, } from './prompt-sections.js';
|
|
4
5
|
/**
|
|
5
6
|
* Builds the system prompt for hunk-based analysis.
|
|
6
7
|
*
|
|
@@ -26,9 +27,7 @@ The following defines the ONLY criteria you should evaluate. Do not report findi
|
|
|
26
27
|
|
|
27
28
|
${skill.prompt}
|
|
28
29
|
</skill_instructions>`,
|
|
29
|
-
|
|
30
|
-
IMPORTANT: Your response must be ONLY a valid JSON object. No markdown, no explanation, no code fences.
|
|
31
|
-
|
|
30
|
+
buildJsonOutputSection(`
|
|
32
31
|
Example response format:
|
|
33
32
|
{"findings": [{"id": "example-1", "severity": "medium", "confidence": "high", "title": "Issue title", "description": "Description", "location": {"path": "file.ts", "startLine": 10}}]}
|
|
34
33
|
|
|
@@ -56,7 +55,7 @@ Full schema:
|
|
|
56
55
|
}
|
|
57
56
|
|
|
58
57
|
Requirements:
|
|
59
|
-
- Return
|
|
58
|
+
- Return valid JSON starting with {"findings":
|
|
60
59
|
- "findings" array can be empty if no issues found
|
|
61
60
|
- "location.path" is auto-filled from context - just provide startLine (and optionally endLine). Omit location entirely for general findings not about a specific line.
|
|
62
61
|
- "location.startLine" MUST be within the hunk line range (shown in the "## Hunk" header). If the issue originates in surrounding code, anchor to the nearest changed line in the hunk and note the actual location in the description.
|
|
@@ -66,7 +65,7 @@ Requirements:
|
|
|
66
65
|
- The fix requires changes to a different file or a new file (describe the fix in the description field instead)
|
|
67
66
|
- Keep descriptions concise (2-4 sentences). Start with the root cause, end with the user-visible consequence.
|
|
68
67
|
- Focus your analysis on the code changes in the hunk. Surrounding context and tool results are for understanding only -- all findings must reference lines within the hunk range.
|
|
69
|
-
|
|
68
|
+
`),
|
|
70
69
|
];
|
|
71
70
|
const { rootDir } = skill;
|
|
72
71
|
if (rootDir) {
|
|
@@ -85,37 +84,16 @@ You can read files from ${dirList} subdirectories using the Read tool with the f
|
|
|
85
84
|
* Builds the user prompt for a single hunk.
|
|
86
85
|
*/
|
|
87
86
|
export function buildHunkUserPrompt(skill, hunkCtx, prContext) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
prSection += `\n\n**Description:**\n${body}`;
|
|
100
|
-
}
|
|
101
|
-
sections.push(prSection);
|
|
102
|
-
}
|
|
103
|
-
// Include list of other files being changed in the PR for context
|
|
104
|
-
const maxContextFiles = prContext?.maxContextFiles ?? 50;
|
|
105
|
-
const otherFiles = prContext?.changedFiles.filter((f) => f !== hunkCtx.filename) ?? [];
|
|
106
|
-
if (otherFiles.length > 0 && maxContextFiles > 0) {
|
|
107
|
-
const displayFiles = otherFiles.slice(0, maxContextFiles);
|
|
108
|
-
const remaining = otherFiles.length - displayFiles.length;
|
|
109
|
-
let fileList = displayFiles.map((f) => `- ${f}`).join('\n');
|
|
110
|
-
if (remaining > 0) {
|
|
111
|
-
fileList += `\n- ... and ${remaining} more`;
|
|
112
|
-
}
|
|
113
|
-
sections.push(`## Other Files in This PR
|
|
114
|
-
The following files are also being changed in this PR (may provide useful context):
|
|
115
|
-
${fileList}`);
|
|
116
|
-
}
|
|
117
|
-
sections.push(formatHunkForAnalysis(hunkCtx));
|
|
118
|
-
sections.push(`IMPORTANT: Only report findings that are explicitly covered by the skill instructions. Do not report general code quality issues, bugs, or improvements unless the skill specifically asks for them. Return an empty findings array if no issues match the skill's criteria.`);
|
|
119
|
-
return sections.join('\n\n');
|
|
87
|
+
return joinPromptSections([
|
|
88
|
+
`<task>
|
|
89
|
+
Analyze this code change according to the "${skill.name}" skill criteria.
|
|
90
|
+
</task>`,
|
|
91
|
+
buildPullRequestContextSection(prContext),
|
|
92
|
+
buildChangedFilesSection(prContext, hunkCtx.filename),
|
|
93
|
+
formatHunkForAnalysis(hunkCtx),
|
|
94
|
+
`<scope_reminder>
|
|
95
|
+
Only report findings that are explicitly covered by the skill instructions. Do not report general code quality issues, bugs, or improvements unless the skill specifically asks for them. Return an empty findings array if no issues match the skill's criteria.
|
|
96
|
+
</scope_reminder>`,
|
|
97
|
+
]);
|
|
120
98
|
}
|
|
121
99
|
//# sourceMappingURL=prompt.js.map
|
package/dist/sdk/prompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/sdk/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,qBAAqB,EAAwB,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/sdk/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,qBAAqB,EAAwB,MAAM,kBAAkB,C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,CAAC;QAC9B;;kBAEc;KACf,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FileReport, Finding, UsageStats } from '../types/index.js';
|
|
2
|
+
export interface FileReportInput {
|
|
3
|
+
filename: string;
|
|
4
|
+
durationMs?: number;
|
|
5
|
+
usage?: UsageStats;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Return whether a final finding should be counted against a file.
|
|
9
|
+
*/
|
|
10
|
+
export declare function findingAppliesToFile(finding: Finding, filename: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Count final findings per file while preserving timing and usage metadata.
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildFileReports(files: FileReportInput[], findings: Finding[]): FileReport[];
|
|
15
|
+
//# sourceMappingURL=report-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-files.d.ts","sourceRoot":"","sources":["../../src/sdk/report-files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEzE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGhF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,UAAU,EAAE,CAO5F"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return whether a final finding should be counted against a file.
|
|
3
|
+
*/
|
|
4
|
+
export function findingAppliesToFile(finding, filename) {
|
|
5
|
+
if (finding.location?.path === filename)
|
|
6
|
+
return true;
|
|
7
|
+
return finding.additionalLocations?.some((location) => location.path === filename) ?? false;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Count final findings per file while preserving timing and usage metadata.
|
|
11
|
+
*/
|
|
12
|
+
export function buildFileReports(files, findings) {
|
|
13
|
+
return files.map((file) => ({
|
|
14
|
+
filename: file.filename,
|
|
15
|
+
findings: findings.filter((finding) => findingAppliesToFile(finding, file.filename)).length,
|
|
16
|
+
durationMs: file.durationMs,
|
|
17
|
+
usage: file.usage,
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=report-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report-files.js","sourceRoot":"","sources":["../../src/sdk/report-files.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAgB,EAAE,QAAgB;IACrE,IAAI,OAAO,CAAC,QAAQ,EAAE,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IACrD,OAAO,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,KAAK,CAAC;AAC9F,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAwB,EAAE,QAAmB;IAC5E,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC1B,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,oBAAoB,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM;QAC3F,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;KAClB,CAAC,CAAC,CAAC;AACN,CAAC"}
|
package/dist/sdk/runner.d.ts
CHANGED
|
@@ -21,7 +21,15 @@ export type { PRPromptContext } from './prompt.js';
|
|
|
21
21
|
export { buildHunkSystemPrompt as buildSystemPrompt } from './prompt.js';
|
|
22
22
|
export { extractFindingsJson, extractBalancedJson, extractFindingsWithLLM, truncateForLLMFallback, deduplicateFindings, mergeGroupLocations, applyMergeGroups, mergeCrossLocationFindings, validateFindings, generateShortId, } from './extract.js';
|
|
23
23
|
export type { ExtractFindingsResult, MergeResult } from './extract.js';
|
|
24
|
+
export { parseJsonFromOutput } from './json-output.js';
|
|
25
|
+
export type { JsonOutputRepairOptions, ParseJsonFromOutputOptions, ParseJsonFromOutputResult, } from './json-output.js';
|
|
24
26
|
export { prepareFiles } from './prepare.js';
|
|
27
|
+
export { verifyFindings } from './verify.js';
|
|
28
|
+
export { postProcessFindings } from './post-process.js';
|
|
29
|
+
export type { PostProcessFindingsOptions, PostProcessFindingsResult, } from './post-process.js';
|
|
25
30
|
export { analyzeFile, runSkill, generateSummary } from './analyze.js';
|
|
26
|
-
export
|
|
31
|
+
export { claudeRuntime, getRuntimeProviderOptions, getRuntime, } from './runtimes/index.js';
|
|
32
|
+
export type { Runtime, RuntimeName } from './runtimes/index.js';
|
|
33
|
+
export type { AuxiliaryRunRequest, AuxiliaryRunResult, AuxiliaryTask, AuxiliaryTool, SynthesisRunRequest, SynthesisTask, SkillRunOptions, SkillRunRequest, SkillRunResponse, SkillRunResult, SkillRunStatus, } from './runtimes/index.js';
|
|
34
|
+
export type { AuxiliaryUsageEntry, FindingProcessingEvent, SkillRunnerCallbacks, SkillRunnerOptions, PreparedFile, PrepareFilesOptions, PrepareFilesResult, FileAnalysisCallbacks, FileAnalysisResult, ChunkAnalysisResult, } from './types.js';
|
|
27
35
|
//# sourceMappingURL=runner.d.ts.map
|
package/dist/sdk/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/sdk/runner.ts"],"names":[],"mappings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