dsh-molbio-tools 0.22.2 → 0.24.1
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/CHANGELOG.md +221 -0
- package/README.md +51 -19
- package/batch.mjs +5 -1
- package/benchmark/README.md +7 -7
- package/benchmark/changed.mjs +4 -3
- package/benchmark/fixtures.mjs +32 -4
- package/benchmark/profile.mjs +1 -1
- package/benchmark/run.mjs +1 -0
- package/benchmark/sequences.mjs +1 -0
- package/benchmark/tasks/02-primers.json +3 -3
- package/benchmark/tasks/06-analysis.json +111 -1
- package/benchmark/tasks/09-formats.json +44 -1
- package/benchmark/verifications.mjs +13 -0
- package/build/client-bundle.mjs +1 -1
- package/build/client-entry.mjs +80 -1
- package/build/panel-core.mjs +85 -0
- package/build/preset-patch.mjs +1 -1
- package/build/release-preflight.mjs +1 -1
- package/charts.mjs +35 -16
- package/contamination.mjs +229 -0
- package/cordis.patch.yml +10 -6
- package/design.mjs +111 -78
- package/docs/capability-gap-survey.md +5 -0
- package/docs/client-panel.md +10 -8
- package/docs/history.md +86 -0
- package/docs/maintainer.md +8 -5
- package/docs/roadmap.md +37 -15
- package/docs/rules.md +5 -2
- package/docs/store-evidence.md +30 -23
- package/docs/store-preset-exemption-issue.md +1 -1
- package/docs/store-preset-exemption.md +1 -1
- package/docs/v24-plan.md +178 -0
- package/docs/workflow.md +11 -10
- package/dotplot.mjs +257 -0
- package/fastq-qc.mjs +31 -16
- package/fastq-trim.mjs +238 -0
- package/host.mjs +2 -2
- package/index.mjs +521 -34
- package/lib/client.js +376 -109
- package/package.json +8 -3
- package/papers.mjs +10 -0
- package/plot.mjs +24 -8
- package/preset/install.mjs +8 -0
- package/preset/molbio-lab/agent.cordis.yml +19 -13
- package/preset/molbio-lab/preset.yml +1 -1
- package/protein-charge.mjs +158 -0
- package/protein-structure.mjs +10 -2
- package/protein.mjs +36 -14
- package/records.mjs +17 -2
- package/seqio.mjs +49 -14
- package/test/charts.mjs +11 -0
- package/test/client.mjs +12 -5
- package/test/contract.mjs +44 -12
- package/test/drift-probe.mjs +15 -1
- package/test/map-card.mjs +139 -1
- package/test/preset-health.mjs +39 -0
- package/test/smoke.mjs +378 -11
package/test/client.mjs
CHANGED
|
@@ -144,6 +144,8 @@ assert.deepEqual(effects, [
|
|
|
144
144
|
'molbio panel: papers tab title',
|
|
145
145
|
'molbio panel: molbio_plasmid_map card',
|
|
146
146
|
'molbio panel: molbio_plasmid_map_file card',
|
|
147
|
+
'molbio panel: molbio_sequence_logo card',
|
|
148
|
+
'molbio panel: molbio_grna_design card',
|
|
147
149
|
'molbio panel: NCBI key section gate',
|
|
148
150
|
'molbio panel: NCBI key section',
|
|
149
151
|
]);
|
|
@@ -186,9 +188,9 @@ assert.deepEqual(
|
|
|
186
188
|
assert.equal(slots.registrations.length, 4, 'both tab bodies and titles land as soon as their seat exists');
|
|
187
189
|
slots.declare('tool.call.toolview');
|
|
188
190
|
|
|
189
|
-
// Body + title register in the keyed seats under each type's id
|
|
190
|
-
//
|
|
191
|
-
// back to the generic tool row, so claiming ours is additive).
|
|
191
|
+
// Body + title register in the keyed seats under each type's id; two map tools
|
|
192
|
+
// and two figure tools claim their own `tool.call.toolview` keys (an unclaimed
|
|
193
|
+
// key falls back to the generic tool row, so claiming ours is additive).
|
|
192
194
|
assert.deepEqual(
|
|
193
195
|
slots.registrations.map((entry) => [entry.registration.name, entry.registration.key]),
|
|
194
196
|
[
|
|
@@ -198,6 +200,8 @@ assert.deepEqual(
|
|
|
198
200
|
['sidebar.right.pane.tab.title', 'dsh-molbio-tools/papers'],
|
|
199
201
|
['tool.call.toolview', 'molbio_plasmid_map'],
|
|
200
202
|
['tool.call.toolview', 'molbio_plasmid_map_file'],
|
|
203
|
+
['tool.call.toolview', 'molbio_sequence_logo'],
|
|
204
|
+
['tool.call.toolview', 'molbio_grna_design'],
|
|
201
205
|
],
|
|
202
206
|
);
|
|
203
207
|
const claim = (name, key) => slots.registrations.find(
|
|
@@ -206,6 +210,9 @@ const claim = (name, key) => slots.registrations.find(
|
|
|
206
210
|
assert.equal(typeof claim('sidebar.right.pane.tab', 'dsh-molbio-tools').component, 'function', 'the plasmid body is a component');
|
|
207
211
|
assert.equal(typeof claim('sidebar.right.pane.tab', 'dsh-molbio-tools/papers').component, 'function', 'the papers body is a component');
|
|
208
212
|
assert.equal(typeof claim('tool.call.toolview', 'molbio_plasmid_map').component, 'function', 'the map card is a component');
|
|
213
|
+
assert.equal(typeof claim('tool.call.toolview', 'molbio_sequence_logo').component, 'function', 'the logo card is a component');
|
|
214
|
+
assert.equal(claim('tool.call.toolview', 'molbio_sequence_logo').component, claim('tool.call.toolview', 'molbio_grna_design').component, 'the two figure tools share one card component');
|
|
215
|
+
assert.equal(claim('tool.call.toolview', 'molbio_grna_design').registration.inject, undefined, 'the figure card declares no injection');
|
|
209
216
|
for (const key of ['dsh-molbio-tools', 'dsh-molbio-tools/papers']) {
|
|
210
217
|
const face = claim('sidebar.right.pane.tab', key).registration.inject('session-1', {});
|
|
211
218
|
assert.equal(typeof face.remote.workspaceFiles.list, 'function', 'the inject factory hands the body the workspace Remote');
|
|
@@ -220,13 +227,13 @@ assert.equal(claim('tool.call.toolview', 'molbio_plasmid_map').registration.inje
|
|
|
220
227
|
// A re-declaration of the seat (the shell's declaration-epoch rule) re-runs the
|
|
221
228
|
// wait: the previous entries are disposed first, so claims never accumulate.
|
|
222
229
|
slots.declare('tool.call.toolview');
|
|
223
|
-
assert.equal(slots.registrations.length,
|
|
230
|
+
assert.equal(slots.registrations.length, 8, 're-declaring the seat re-installs all four cards instead of duplicating them');
|
|
224
231
|
|
|
225
232
|
// The Plugins page's detail seat belongs to the plugin manager. The section
|
|
226
233
|
// lands when that seat is declared, and the component itself decides whether
|
|
227
234
|
// the open subject is this package.
|
|
228
235
|
slots.declare('plugins.detail.section');
|
|
229
|
-
assert.equal(slots.registrations.length,
|
|
236
|
+
assert.equal(slots.registrations.length, 9, 'the key section lands when the plugin manager declares its seat');
|
|
230
237
|
const keyClaim = slots.registrations.find((entry) => entry.registration.name === 'plugins.detail.section');
|
|
231
238
|
assert.ok(keyClaim, 'the key section is claimed in plugins.detail.section');
|
|
232
239
|
assert.equal(keyClaim.registration.id, 'molbio-ncbi-key', 'the list seat is addressed by an id of our own');
|
package/test/contract.mjs
CHANGED
|
@@ -228,7 +228,14 @@ check('the shell derives hook props as use<Capitalised(Source)>', () => {
|
|
|
228
228
|
check('a session-scope tab body receives sessionId + useSessions (official precedent)', () => {
|
|
229
229
|
const files = clientBundle('@deepseek-ai/dsh-client-ui-sidebar-files');
|
|
230
230
|
assert.ok(files !== undefined, 'ui-sidebar-files is installed');
|
|
231
|
-
|
|
231
|
+
// 0.2.2-rc.1 renamed the tab body (`FilesBody` -> `FileNavigator`) without
|
|
232
|
+
// changing what the runtime injects into it. The CONTRACT is the props, not
|
|
233
|
+
// the function's name, so match the destructuring rather than one identifier.
|
|
234
|
+
assert.match(
|
|
235
|
+
files.text,
|
|
236
|
+
/function [A-Za-z_$][\w$]*\(\{(?=[^}]*\buseTabInfo\b)(?=[^}]*\bsessionId\b)(?=[^}]*\buseSessions\b)/,
|
|
237
|
+
'the official tab body receives useTabInfo + sessionId + useSessions from its props',
|
|
238
|
+
);
|
|
232
239
|
assert.ok(files.text.includes('useSessions((sessions) => sessions.byId[sessionId]?.cwd)'), 'and reads the workspace root exactly as the panel does');
|
|
233
240
|
assert.ok(files.text.includes('"slots"') && files.text.includes('"sidebarRightTabs"'), 'and injects the same registries');
|
|
234
241
|
});
|
|
@@ -432,7 +439,7 @@ check('the published tarball carries the client half and exactly one plugin mani
|
|
|
432
439
|
// SUBMISSION_PACKAGE_AMBIGUOUS, plus a duplicate 427 KB client bundle in every
|
|
433
440
|
// download. The panel does not disappear for npm users: the root package's own
|
|
434
441
|
// `lib/client.js` already carries it (the panel-only package exists for people
|
|
435
|
-
// who want the tab without the
|
|
442
|
+
// who want the tab without the 64 tools).
|
|
436
443
|
assert.ok(
|
|
437
444
|
!files.includes('packages'),
|
|
438
445
|
'the root tarball must not embed packages/molbio-panel: a second `dsh` manifest inside one package is an ambiguous submission, and the panel is published separately',
|
|
@@ -468,8 +475,16 @@ check('the toolview card contract still holds (meta path + keyed seat)', () => {
|
|
|
468
475
|
// path that still carries the value — consulted, snapshotted, attached as
|
|
469
476
|
// `meta` — rather than a literal upstream is free to drop (the panel does not
|
|
470
477
|
// depend on nested calls being excluded, only on the root call carrying it).
|
|
471
|
-
|
|
472
|
-
|
|
478
|
+
// The projection lives in the assembly pipeline. 0.2.2-rc.1 moved that code
|
|
479
|
+
// out of `lib/index.js` into `lib/pipeline.js` (same call, same snapshot, same
|
|
480
|
+
// attachment), so read whichever files the installed package ships instead of
|
|
481
|
+
// pinning the one upstream happened to use before.
|
|
482
|
+
const toolsDir = packageDir('@deepseek-ai/dsh-tools');
|
|
483
|
+
const toolsFiles = ['lib/index.js', 'lib/pipeline.js']
|
|
484
|
+
.map((rel) => join(toolsDir, rel))
|
|
485
|
+
.filter((path) => existsSync(path));
|
|
486
|
+
assert.ok(toolsFiles.length > 0, 'dsh-tools is installed');
|
|
487
|
+
const tools = { text: toolsFiles.map((path) => readFileSync(path, 'utf8')).join('\n') };
|
|
473
488
|
assert.ok(/output\.presentationMeta\s*!==\s*void 0/.test(tools.text), 'the tool layer still consults output.presentationMeta');
|
|
474
489
|
assert.ok(tools.text.includes('snapshotProjection(tool.name, "presentationMeta"'), 'and records the projection on the result');
|
|
475
490
|
assert.ok(
|
|
@@ -493,16 +508,25 @@ check('the toolview card contract still holds (meta path + keyed seat)', () => {
|
|
|
493
508
|
// key whose tool forgot `presentationMeta`.
|
|
494
509
|
const source = readFileSync(join(packageRoot, 'index.mjs'), 'utf8');
|
|
495
510
|
const bundle = readFileSync(join(packageRoot, 'lib', 'client.js'), 'utf8');
|
|
496
|
-
const
|
|
497
|
-
|
|
498
|
-
|
|
511
|
+
const keyList = (name) => {
|
|
512
|
+
const match = new RegExp('const ' + name + ' = \\[([^\\]]*)\\]').exec(bundle);
|
|
513
|
+
assert.ok(match !== null, 'the bundle declares ' + name + ', the tool keys whose cards it draws');
|
|
514
|
+
return match[1].split(',').map((entry) => entry.trim().replace(/^['"]|['"]$/g, '')).filter((entry) => entry !== '');
|
|
515
|
+
};
|
|
516
|
+
// Two card shapes share the seat: the plasmid-map card (MAP_TOOL_KEYS) and the
|
|
517
|
+
// figure card (FIGURE_TOOL_KEYS). Both lists are read from the bundle, so a
|
|
518
|
+
// third key whose tool forgets its projection fails here either way.
|
|
519
|
+
const claimed = [...keyList('MAP_TOOL_KEYS'), ...keyList('FIGURE_TOOL_KEYS')];
|
|
499
520
|
assert.ok(claimed.length > 0, 'the bundle claims at least one card key');
|
|
500
521
|
assert.equal(
|
|
501
|
-
|
|
522
|
+
// Anchored: the file-header comment also mentions the signature, and a
|
|
523
|
+
// substring count would treat that prose as a fourth implementation.
|
|
524
|
+
(source.match(/^ presentationMeta\((?:args|_args), value\)/gm) ?? []).length,
|
|
502
525
|
claimed.length,
|
|
503
526
|
'every claimed card key belongs to a tool that declares the projection',
|
|
504
527
|
);
|
|
505
|
-
assert.ok(source.includes('mapCardMeta'), 'and build it through the shared projection');
|
|
528
|
+
assert.ok(source.includes('mapCardMeta'), 'and build it through the shared map projection');
|
|
529
|
+
assert.ok(source.includes('figureCardMeta'), 'and the shared figure projection');
|
|
506
530
|
for (const key of claimed) {
|
|
507
531
|
// The host half registers a tool under that exact name.
|
|
508
532
|
assert.ok(source.includes(`name: '${key}'`), `the host registers the tool ${key} whose card the bundle claims`);
|
|
@@ -710,8 +734,8 @@ check('a tool may show the model a picture the way read_image does', () => {
|
|
|
710
734
|
// The count is deliberate: it is what catches a NEW picture tool that forgets
|
|
711
735
|
// the hand-off (or a report tool that quietly grows it).
|
|
712
736
|
const index = readFileSync(join(packageRoot, 'index.mjs'), 'utf8');
|
|
713
|
-
assert.equal((index.match(/image: ATTACHED_IMAGE_SCHEMA/g) ?? []).length,
|
|
714
|
-
assert.equal((index.match(/\.\.\.ATTACH_IMAGE_PARAM/g) ?? []).length,
|
|
737
|
+
assert.equal((index.match(/image: ATTACHED_IMAGE_SCHEMA/g) ?? []).length, 17, 'all 17 picture tools declare the image output field');
|
|
738
|
+
assert.equal((index.match(/\.\.\.ATTACH_IMAGE_PARAM/g) ?? []).length, 17, 'and offer the opt-in attach_image parameter');
|
|
715
739
|
assert.ok(/output\.render/.test(index) || index.includes('imageBlockFor(value)'), 'the block builder is wired into define()');
|
|
716
740
|
});
|
|
717
741
|
|
|
@@ -724,7 +748,15 @@ check('the workspace still cannot hold a binary file (the reason the picture rid
|
|
|
724
748
|
// the local backend (the base is consulted last, only as a presence fallback).
|
|
725
749
|
const fsTypes = declarationEvidence('@deepseek-ai/dsh-fs', ['lib/types/types.d.ts', '../dsh-fs-local/lib/index.js', 'lib/index.js']).text;
|
|
726
750
|
const fsReadme = readFileSync(join(packageDir('@deepseek-ai/dsh-fs'), 'README.md'), 'utf8');
|
|
727
|
-
|
|
751
|
+
// 0.2.2-rc.1 reworded this: the old "binary-safe mutations remain deferred"
|
|
752
|
+
// note became the precise rule under "Known Limitations and Deferred Work"
|
|
753
|
+
// ("Literal edits, patches, and moves require UTF-8 text"). Accept either
|
|
754
|
+
// spelling of the SAME policy — the seam assertions below are the real gate.
|
|
755
|
+
assert.match(
|
|
756
|
+
fsReadme,
|
|
757
|
+
/binary-safe mutations remain deferred|Literal edits, patches, and moves require UTF-8 text/i,
|
|
758
|
+
'and still documents the text-only mutation rule the picture hand-off depends on',
|
|
759
|
+
);
|
|
728
760
|
const fsIndex = readFileSync(join(packageDir('@deepseek-ai/dsh-fs'), 'lib', 'index.js'), 'utf8');
|
|
729
761
|
assertFsSeamDeclared(fsTypes, fsIndex);
|
|
730
762
|
});
|
package/test/drift-probe.mjs
CHANGED
|
@@ -29,7 +29,7 @@ import { existsSync } from 'node:fs';
|
|
|
29
29
|
import { dirname, join, resolve } from 'node:path';
|
|
30
30
|
import { fileURLToPath } from 'node:url';
|
|
31
31
|
|
|
32
|
-
import { compositionDrift, toolCountDrift, presetPlugins, asPresetPatch, relativeSpecifiers, presetOrderDeclared, orderCollisions } from './preset-health.mjs';
|
|
32
|
+
import { compositionDrift, toolCountDrift, presetPlugins, asPresetPatch, relativeSpecifiers, presetOrderDeclared, orderCollisions, specifierProblem } from './preset-health.mjs';
|
|
33
33
|
// The three helpers this probe used to carry its own copies of. Duplicating
|
|
34
34
|
// `findHarnessRoot` was the worst of them: the probe could resolve a DIFFERENT
|
|
35
35
|
// harness than `preset-health` validated against, so a mutation experiment could
|
|
@@ -215,6 +215,20 @@ check('the specifier guard is quiet on a package name and catches a relative pat
|
|
|
215
215
|
);
|
|
216
216
|
});
|
|
217
217
|
|
|
218
|
+
check('a row naming a removed package subpath is caught (the 0.2.2-rc.1 list-agents trap)', () => {
|
|
219
|
+
// 0.2.2-rc.1 folded `list_agents` into `@deepseek-ai/dsh-tool-subagent-control`
|
|
220
|
+
// and dropped its `./list-agents` export. `packageInstalled` still finds the
|
|
221
|
+
// package ROOT, so only a real specifier resolution notices — and this probe
|
|
222
|
+
// must not depend on one version's removals to prove the guard works. A
|
|
223
|
+
// subpath no release can export is the version-independent mutation.
|
|
224
|
+
const base = '@deepseek-ai/dsh-tool-subagent-control';
|
|
225
|
+
assert.equal(specifierProblem(base, harnessRoot), undefined, 'the package root resolves');
|
|
226
|
+
assert.equal(specifierProblem(`${base}/package.json`, harnessRoot), undefined, 'an exported subpath resolves');
|
|
227
|
+
const problem = specifierProblem(`${base}/no-such-subpath`, harnessRoot);
|
|
228
|
+
assert.ok(problem !== undefined, 'an unexported subpath is rejected');
|
|
229
|
+
assert.match(problem, /does not resolve/, problem);
|
|
230
|
+
});
|
|
231
|
+
|
|
218
232
|
check('the order guard reads the order under config, not the declaration row id', () => {
|
|
219
233
|
const layer = [
|
|
220
234
|
' - id: preset-mine',
|
package/test/map-card.mjs
CHANGED
|
@@ -344,6 +344,144 @@ assert.ok(unparseableText.includes('could not be parsed as SVG'), 'unparseable m
|
|
|
344
344
|
assert.ok(unparseableText.includes('pCARD · 206 bp'), 'and the header is still there, above the explanation');
|
|
345
345
|
unparseable.unmount();
|
|
346
346
|
|
|
347
|
+
// ── figure cards: sequence logo and gRNA design ─────────────────────────────
|
|
348
|
+
|
|
349
|
+
/** Deterministic pseudo-random DNA for the gRNA fixture. */
|
|
350
|
+
function dnaFixture(n, seed) {
|
|
351
|
+
let s = seed;
|
|
352
|
+
const bases = 'ACGT';
|
|
353
|
+
let out = '';
|
|
354
|
+
for (let i = 0; i < n; i++) {
|
|
355
|
+
s = (s * 1103515245 + 12345) % 2147483648;
|
|
356
|
+
out += bases[(s >> 16) % 4];
|
|
357
|
+
}
|
|
358
|
+
return out;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const logoTool = registered.find((entry) => entry.name === 'molbio_sequence_logo');
|
|
362
|
+
const grnaTool = registered.find((entry) => entry.name === 'molbio_grna_design');
|
|
363
|
+
assert.ok(logoTool !== undefined && grnaTool !== undefined, 'both figure tools register');
|
|
364
|
+
|
|
365
|
+
const logoArgs = { sequences: ['ACGTACGTACGTACGT', 'ACGTACGTACGTACGA', 'ACGTACGTTCGTACGT'] };
|
|
366
|
+
const logoValue = await logoTool.execute(logoArgs, exec);
|
|
367
|
+
const logoMeta = logoTool.output.presentationMeta(logoArgs, logoValue);
|
|
368
|
+
assert.equal(logoMeta.kind, 'molbio-figure');
|
|
369
|
+
assert.equal(logoMeta.figure, 'logo');
|
|
370
|
+
assert.equal(logoMeta.svg_path, logoValue.svg_path);
|
|
371
|
+
assert.ok(typeof logoMeta.svg === 'string' && logoMeta.svg.startsWith('<svg'), 'the logo card meta carries the markup');
|
|
372
|
+
assert.equal(logoMeta.svg_bytes, logoMeta.svg.length);
|
|
373
|
+
assert.match(logoMeta.summary, /3 sequences × 16 columns/, 'the summary states the alignment size');
|
|
374
|
+
|
|
375
|
+
const logoView = panelCore.figureCardView(logoMeta);
|
|
376
|
+
assert.equal(logoView.kind, 'figure', 'the card resolves the logo projection');
|
|
377
|
+
assert.equal(logoView.svg, logoMeta.svg);
|
|
378
|
+
assert.equal(logoView.svgPath, logoValue.svg_path);
|
|
379
|
+
assert.equal(panelCore.figureCardSummary(logoView), logoMeta.summary);
|
|
380
|
+
|
|
381
|
+
const grnaArgs = {
|
|
382
|
+
sequence: dnaFixture(320, 7),
|
|
383
|
+
map_path: at('grna-map.svg'),
|
|
384
|
+
save_path: at('grna-order.csv'),
|
|
385
|
+
max_guides: 5,
|
|
386
|
+
};
|
|
387
|
+
const grnaValue = await grnaTool.execute(grnaArgs, exec);
|
|
388
|
+
assert.ok(grnaValue.guides.length > 0, 'the gRNA fixture yields at least one guide');
|
|
389
|
+
const grnaMeta = grnaTool.output.presentationMeta(grnaArgs, grnaValue);
|
|
390
|
+
assert.equal(grnaMeta.kind, 'molbio-figure');
|
|
391
|
+
assert.equal(grnaMeta.figure, 'grna');
|
|
392
|
+
assert.equal(grnaMeta.svg_path, grnaValue.map_path);
|
|
393
|
+
assert.ok(typeof grnaMeta.svg === 'string' && grnaMeta.svg.startsWith('<svg'), 'the gRNA card carries the map markup');
|
|
394
|
+
assert.ok(grnaMeta.guides.length >= 1 && grnaMeta.guides.length <= 5, 'the card carries at most five guide rows');
|
|
395
|
+
assert.equal(grnaMeta.guides[0].sequence, grnaValue.guides[0].sequence);
|
|
396
|
+
assert.equal(grnaMeta.csv_path, grnaValue.saved_to);
|
|
397
|
+
assert.match(grnaMeta.summary, /SpCas9/, 'the summary names the Cas family');
|
|
398
|
+
|
|
399
|
+
const grnaView = panelCore.figureCardView(grnaMeta);
|
|
400
|
+
assert.equal(grnaView.kind, 'figure');
|
|
401
|
+
assert.equal(grnaView.guides.length, grnaMeta.guides.length);
|
|
402
|
+
assert.equal(grnaView.guides[0].offTargets, grnaValue.guides[0].off_target_count ?? 0);
|
|
403
|
+
|
|
404
|
+
// A gRNA call WITHOUT a map still gets the ranked-guide table, with an
|
|
405
|
+
// explanation for the absent picture rather than a blank card.
|
|
406
|
+
const plainGrnaValue = await grnaTool.execute({ sequence: dnaFixture(320, 7), max_guides: 5 }, exec);
|
|
407
|
+
const plainMeta = grnaTool.output.presentationMeta({ sequence: dnaFixture(320, 7) }, plainGrnaValue);
|
|
408
|
+
assert.equal(plainMeta.svg_missing, true);
|
|
409
|
+
const plainView = panelCore.figureCardView(plainMeta);
|
|
410
|
+
assert.equal(plainView.kind, 'notice');
|
|
411
|
+
assert.match(plainView.message, /No picture was requested/i);
|
|
412
|
+
assert.ok(plainView.guides.length > 0, 'the table survives the missing picture');
|
|
413
|
+
|
|
414
|
+
// ── figure-card fallbacks: never throw inside a transcript ──────────────────
|
|
415
|
+
|
|
416
|
+
assert.equal(panelCore.figureCardView({ kind: 'molbio-map' }).kind, 'notice', 'a map meta is not a figure');
|
|
417
|
+
assert.equal(panelCore.figureCardView(undefined).kind, 'notice');
|
|
418
|
+
assert.equal(panelCore.figureCardView(null).kind, 'notice');
|
|
419
|
+
assert.equal(panelCore.figureCardView('nonsense').kind, 'notice');
|
|
420
|
+
assert.equal(panelCore.figureCardView([]).kind, 'notice');
|
|
421
|
+
assert.equal(panelCore.figureCardView({ kind: 'molbio-figure', figure: 'unknown' }).kind, 'notice');
|
|
422
|
+
const oversizedFigure = panelCore.figureCardView({
|
|
423
|
+
kind: 'molbio-figure',
|
|
424
|
+
figure: 'logo',
|
|
425
|
+
summary: 'Sequence logo',
|
|
426
|
+
svg_omitted: true,
|
|
427
|
+
svg_bytes: 900_000,
|
|
428
|
+
svg_path: at('big-logo.svg'),
|
|
429
|
+
});
|
|
430
|
+
assert.equal(oversizedFigure.kind, 'notice');
|
|
431
|
+
assert.match(oversizedFigure.message, /too large/i);
|
|
432
|
+
assert.equal(oversizedFigure.svgPath, at('big-logo.svg'));
|
|
433
|
+
assert.equal(panelCore.figureCardView({ kind: 'molbio-figure', figure: 'logo', svg: '<div>hi</div>' }).kind, 'notice');
|
|
434
|
+
const sanitized = panelCore.figureCardView({
|
|
435
|
+
kind: 'molbio-figure',
|
|
436
|
+
figure: 'grna',
|
|
437
|
+
summary: 's',
|
|
438
|
+
svg_missing: true,
|
|
439
|
+
guides: [null, 7, { sequence: 42 }, { sequence: 'ACGT', rank: 'x', start: 1.5 }, { sequence: 'ACGT', rank: 1 }, { sequence: 'ACGT', rank: 2 }, { sequence: 'ACGT', rank: 3 }, { sequence: 'ACGT', rank: 4 }],
|
|
440
|
+
});
|
|
441
|
+
assert.equal(sanitized.guides.length, 5, 'malformed rows are dropped and the list is capped at five');
|
|
442
|
+
assert.equal(sanitized.guides[0].rank, 0, 'a non-integer rank degrades to 0 rather than being trusted');
|
|
443
|
+
|
|
444
|
+
// ── the figure component: logo and gRNA render through the same card ────────
|
|
445
|
+
|
|
446
|
+
const FigureCard = slots.registrations.find(
|
|
447
|
+
(entry) => entry.registration.name === 'tool.call.toolview' && entry.registration.key === 'molbio_sequence_logo',
|
|
448
|
+
).component;
|
|
449
|
+
assert.equal(typeof FigureCard, 'function', 'the figure card is registered for molbio_sequence_logo');
|
|
450
|
+
|
|
451
|
+
globalThis.__molbioTestHooks = mount(FigureCard);
|
|
452
|
+
const logoCard = globalThis.__molbioTestHooks;
|
|
453
|
+
logoCard.setProps({ block: { kind: 'tool-result', callId: 'l1', isError: false, meta: logoMeta, content: [{ type: 'text', text: 'logo saved' }] }, inspect: undefined });
|
|
454
|
+
await logoCard.render();
|
|
455
|
+
const logoText = texts(logoCard.tree).join('\n');
|
|
456
|
+
assert.ok(logoText.includes('Sequence logo · 3 sequences × 16 columns'), 'the logo card header summarises the alignment');
|
|
457
|
+
assert.ok(logoText.includes(logoValue.svg_path), 'the logo card names the written file');
|
|
458
|
+
const logoHosts = (function find(node, out = []) {
|
|
459
|
+
if (Array.isArray(node)) {
|
|
460
|
+
for (const child of node) find(child, out);
|
|
461
|
+
return out;
|
|
462
|
+
}
|
|
463
|
+
if (node !== null && typeof node === 'object' && node.props !== undefined) {
|
|
464
|
+
if (node.props.ref !== undefined && node.props.ref !== null) out.push(node);
|
|
465
|
+
find(node.props.children, out);
|
|
466
|
+
}
|
|
467
|
+
return out;
|
|
468
|
+
})(logoCard.tree);
|
|
469
|
+
assert.equal(logoHosts.length, 1, 'the logo card mounts one SVG host');
|
|
470
|
+
assert.equal(logoHosts[0].props.ref.current.children.length, 1, 'and appended the parsed logo into it');
|
|
471
|
+
logoCard.unmount();
|
|
472
|
+
|
|
473
|
+
globalThis.__molbioTestHooks = mount(FigureCard);
|
|
474
|
+
const grnaCard = globalThis.__molbioTestHooks;
|
|
475
|
+
grnaCard.setProps({ block: { kind: 'tool-result', callId: 'g1', isError: false, meta: grnaMeta, content: [{ type: 'text', text: 'guides designed' }] }, inspect: undefined });
|
|
476
|
+
await grnaCard.render();
|
|
477
|
+
const grnaText = texts(grnaCard.tree).join('\n');
|
|
478
|
+
assert.ok(grnaText.includes('SpCas9'), 'the gRNA card header names the family');
|
|
479
|
+
assert.ok(grnaText.includes(grnaValue.guides[0].sequence), 'the gRNA card lists the top guide');
|
|
480
|
+
assert.ok(grnaText.includes('Off-targets'), 'the gRNA card shows the guide table header');
|
|
481
|
+
assert.ok(grnaText.includes(grnaValue.map_path), 'and the written map path');
|
|
482
|
+
assert.ok(grnaText.includes(grnaValue.saved_to), 'and the ordering CSV path');
|
|
483
|
+
grnaCard.unmount();
|
|
484
|
+
|
|
347
485
|
await rm(shimPath, { force: true });
|
|
348
486
|
await rm(entryPath, { force: true });
|
|
349
|
-
console.log('
|
|
487
|
+
console.log('tool card checks passed (map + logo/gRNA: host projection -> card view -> rendered SVG)');
|
package/test/preset-health.mjs
CHANGED
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
*/
|
|
37
37
|
import { readFile, readdir } from 'node:fs/promises';
|
|
38
38
|
import { existsSync } from 'node:fs';
|
|
39
|
+
import { createRequire } from 'node:module';
|
|
39
40
|
import { dirname, join, resolve } from 'node:path';
|
|
40
41
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
41
42
|
// Re-exported for test/drift-probe.mjs, which drives the same reader against
|
|
@@ -101,6 +102,34 @@ function flattenRows(rows, at = '') {
|
|
|
101
102
|
return found;
|
|
102
103
|
}
|
|
103
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Resolve a row's specifier the way the Loader does, or say why it cannot.
|
|
107
|
+
*
|
|
108
|
+
* The Loader imports a package row BY SPECIFIER (`import.meta.resolve` anchored
|
|
109
|
+
* in the config project's scope, see `cordis-plugin-loader`), and Node enforces
|
|
110
|
+
* the target package's `exports` map on that specifier. `packageInstalled` only
|
|
111
|
+
* proves that a directory exists, so a row naming a SUBPATH the harness dropped
|
|
112
|
+
* used to pass this suite and then fail at preset mount — that is exactly how
|
|
113
|
+
* `@deepseek-ai/dsh-tool-subagent-control/list-agents` (removed in 0.2.2-rc.1,
|
|
114
|
+
* where `list_agents` moved into the control plugin itself) survived until a
|
|
115
|
+
* manual run against the new harness.
|
|
116
|
+
*
|
|
117
|
+
* Exported so `test/drift-probe.mjs` can drive it against a mutated specifier:
|
|
118
|
+
* a guard nobody has seen fail is not a guard (rules.md rule 9).
|
|
119
|
+
*
|
|
120
|
+
* @param {string} name the row's `name`.
|
|
121
|
+
* @param {string} harnessRoot the installed harness.
|
|
122
|
+
* @returns {string|undefined} a diagnostic, or undefined when it resolves.
|
|
123
|
+
*/
|
|
124
|
+
export function specifierProblem(name, harnessRoot) {
|
|
125
|
+
try {
|
|
126
|
+
createRequire(join(harnessRoot, 'package.json')).resolve(name);
|
|
127
|
+
return undefined;
|
|
128
|
+
} catch (error) {
|
|
129
|
+
return `specifier does not resolve: ${error?.code ?? error?.message ?? error}`;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
104
133
|
/** Validate one row against its package's own `Config` schema. */
|
|
105
134
|
async function checkRow(row, packages, harnessRoot, presetBase) {
|
|
106
135
|
const id = typeof row.id === 'string' ? row.id : row.name;
|
|
@@ -118,6 +147,16 @@ async function checkRow(row, packages, harnessRoot, presetBase) {
|
|
|
118
147
|
: { ...result, status: 'unresolvable', detail: `preset-relative module not found: ${target}` };
|
|
119
148
|
}
|
|
120
149
|
|
|
150
|
+
// A bare package row is imported by SPECIFIER, so its `exports` map decides
|
|
151
|
+
// whether it mounts. Check that before looking for the package directory:
|
|
152
|
+
// `packageInstalled` walks up from the harness root and would happily report a
|
|
153
|
+
// package whose named subpath no longer exists. `cordis:*` rows name Loader
|
|
154
|
+
// builtins, not modules, so they are skipped here too.
|
|
155
|
+
if (!row.name.includes(':') && row.name !== selfName) {
|
|
156
|
+
const problem = specifierProblem(row.name, harnessRoot);
|
|
157
|
+
if (problem !== undefined) return { ...result, status: 'unresolvable', detail: problem };
|
|
158
|
+
}
|
|
159
|
+
|
|
121
160
|
const pkgDir = row.name === selfName
|
|
122
161
|
// The row names THIS package. `packageInstalled` walks up from the harness
|
|
123
162
|
// root, where this package is not installed — but in the preset it is
|