Add the forge subsystem's extension API section, README and cookbook coverage, the generated Cordis, config, slot, and event catalogs, and a recorded forge-panel e2e case that loads a fixture plugin registering a lens, annotations, and every new slot.
28 lines
981 B
JavaScript
28 lines
981 B
JavaScript
/** Host half of the forge extension fixture: a filter lens that keeps the files whose new side has `export` lines, about those lines. */
|
|
export const name = '@fixture/forge-extension'
|
|
export const inject = ['forgePanel']
|
|
|
|
/** @param {import('@deepseek-ai/cordis').Context} ctx */
|
|
export function apply(ctx) {
|
|
ctx.forgePanel.registerLens({
|
|
id: 'fixture/exports',
|
|
version: '1',
|
|
async classify(input, signal) {
|
|
const files = {}
|
|
let done = 0
|
|
for (const file of input.files) {
|
|
const text = await input.text('new', file.path, signal)
|
|
done += 1
|
|
input.progress(done, input.files.length)
|
|
if (text === null) continue
|
|
const ranges = []
|
|
text.split('\n').forEach((line, index) => {
|
|
if (/^export\b/.test(line)) ranges.push({ start: index + 1, end: index + 1 })
|
|
})
|
|
if (ranges.length > 0) files[file.path] = { ranges: { old: [], new: ranges } }
|
|
}
|
|
return { files }
|
|
},
|
|
})
|
|
}
|