/spark-to-paper:ts-idea2storyfrom spark-to-paper
Turns a raw research idea into an 8-field structured story proposal with knowledge graph recall, literature search, and critique-refine loop. For when you have an idea and want a paper-ready story.
Ships in spark-to-paper. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Distilled from the product's idea→story link. The idea is the PROTAGONIST; a recalled/searched
pattern is the TOOL it wields. Claude is the packager, the recaller, the searcher, the storyteller,
and the critic — all in one context (so coherence and anti-stacking come for free). Two scripts are
irreducible: kg_recall.py (vector/graph retrieval) and story_lint.py (the gate); embeddings
(optional) reuse ../ts-kg-build/scripts/embed.py's TS_EMBED_* config.
In: a raw idea (text); optional kg/ dir (from ts-kg-build, or the bundled kg_ts); optional
TS_EMBED_* endpoint; a retrieval_focus dial in {trust_kg, balanced, go_search_web}.
Out (in the workdir):
story.json — the 8 fields: title, abstract, problem_framing, gap_pattern, solution, method_skeleton, innovation_claims[], experiments_plan.story_proposal.md — the Markdown projection of the 8 fields (this is what ts-paper-plan reads —
a story IS a structured proposal; story2paper == proposal2paper).retrieved_papers.json — the real papers found, the citation seed for ts-paper-cite (§ Reuse).logs/*.io.md, optional novelty_report.json.Write idea_brief.json: motivation, problem, assumptions_explicit[], assumptions_inferred[], constraints, retrieval_query. Faithfulness guard: keep assumptions you inferred separate from
what the user stated — never fabricate user intent. The retrieval_query is an English,
search-friendly reformulation. Never raise on a thin idea; normalize and proceed.
If a kg/ exists: python3 scripts/kg_recall.py --idea "<retrieval_query>" --kg <kg_dir> --out recall.json --topk 8.
It returns Top-K candidate patterns (semantic+graph if embeddings configured, else lexical-only,
labeled — treat lexical hits as weaker). Then YOU reason over them comparatively in one pass,
scoring each on three independent axes (no per-pattern round-trips needed):
Plan intent-tagged query packs (with forced minimums) and run them via native search:
core_method, task_setting, contrast (what you depart from — don't skip this), evaluation
(datasets/metrics/baselines). Force-keep the literal user idea as one query. For each kept paper,
read the abstract and extract a story-first pattern (as in ts-kg-build). Record every real paper
into retrieved_papers.json (schema in § Reuse) — this is the citation seed. Never fabricate a
paper or an abstract.
Pick the pattern that best fits the idea as a stable skeleton (prefer a near-domain, coherent KG pattern for the first draft); hold novelty/far-domain patterns in reserve for the refine loop.
Idea = protagonist, pattern = tool. Produce the 8 fields. The non-negotiable craft:
gap_pattern/solution must say "reframe X from Y to Z" —
recast the problem, don't staple two methods together. Banned verbs: combine, integrate, merge,
stack, plug in. Required verbs: reframe, recast, transform, unify, exploit. Include a one-line
rationale why_not_straightforward_combination inside solution.solution is the narrative (what changes and why it works);
method_skeleton is the concrete step list (≥ a few real steps). Keep them distinct.experiments_plan and innovation_claims are forward-looking ("we evaluate… we
expect…") — no fabricated numbers / "beats SOTA by X%".When TS_EMBED_* is configured, run python3 scripts/novelty_check.py <workdir>: it embeds the story
text (reusing the embed_one() pattern), cosine-compares it against an available reference set (the
retrieved_papers.json abstracts embedded on the fly, else the pattern index kg/pattern_emb.npy),
and writes novelty_report.json {max_similarity, risk_level, threshold_high, threshold_medium, top_similar, verdict, basis}. Act on the bands: ≥0.88 high → pivot to a more differentiating
reserved pattern and re-tell; ≥0.82 medium → warn; cap pivots at 2.
Graceful degrade: with no embedding endpoint the script exits 0 with a "lexical/judgement only —
not a semantic guarantee" note; in that case do the lexical/judgement check against the recalled
exemplars + retrieved_papers.json yourself. Either way novelty_report.json must exist (top similar
works + verdict + basis) so the check is never silently skipped.
Write story.json, render story_proposal.md (the 8 fields as a proposal: Problem / Gap / Proposed
method / Evaluation plan / Contributions), and finalize retrieved_papers.json. Then:
python3 scripts/story_lint.py <workdir> — must be ok:true (8 fields non-empty, no schema-echo
noise, method_skeleton concrete, no fabricated numbers). Soft requirement: confirm
novelty_report.json exists (from step 7, semantic or degraded) so the novelty check was not silently
skipped. Hand story_proposal.md to ts-paper-plan.
retrieved_papers.json (cuts the cite stage's search)Write the real papers found in steps 2–3 here; ts-paper-cite ingests it as a verified seed.
{"source":"ts-idea2story", "papers":[
{"paper_id":"openalex:W..","title":"..","authors":[".."],"year":2024,"venue":"..",
"volume":"","issue":"","pages":"","doi":"10..","url":"https://..","abstract":"(real)",
"abstract_source":"openalex|arxiv|openreview|missing",
"relevance":"core|context|baseline|dataset_metric|contrast",
"supports_claim":"the exact story claim this paper backs"}]}
Rules: dedup by paper_id / normalized title; on merge keep the longest non-empty abstract/title;
never fabricate an abstract (abstract_source:"missing"); pool = the exemplar/agentic papers the
story was derived from + the novelty candidates. The cite stage still verifies each via doi2bib,
places it by abstract, gap-fills missing angles, and enforces its coverage floor — the seed just
removes the cold-start sweep.
This is a proposal — no real results anywhere. Keep explicit-vs-inferred assumptions honest. Write
logs/idea2story.io.md — INPUT (idea, retrieval_focus, kg on/off, embeddings on/off), DECISIONS
(packaged brief, recalled patterns + 3-axis scores, search packs + kept/rejected, seed pattern, each
critique round: weakest axis → pattern pulled → fuse result, novelty verdict), OUTPUT (story.json
summary, story_lint result, retrieved_papers count).
What SKILL.md sets; muted values are Claude Code's defaults
Generated from the plugin's indexed repository (spark-to-paper-skills/spark-to-paper-skills) — no native marketplace selected
npx claudepluginhub p/spark-to-paper-skills-spark-to-paper14 skills in this plugin
/ts-figure-optimizeThe suite's SOLE figure vectorizer: turn ONE raster scientific figure (a PNG/JPG, e.g. a gpt-image-2 schematic) into an editable, publication-ready figure via DrawAI's **key-free HYBRID** — local perception (SAM3 region detection + PaddleOCR + Box-IR layout, no account) then a deterministic hybrid build that keeps the approved render **pixel-exact** (a whole-canvas raster) and lays an **editable <text> overlay** on top (~0.91 SSIM), exported as a self-contained SVG + vector PDF + an editable PPTX. The render's full richness is preserved EXACTLY (it IS the approved image) while every label becomes editable. The original raster is always kept. Hybrid is the ONLY mode used: there is no Codex full-vector redraw (legacy/off — it needs an account, and a redraw of a dense figure loses fidelity) and no Claude-redraw fallback. If this runtime cannot be provisioned, the caller keeps the approved PNG as-is — never a lossy redraw. Independent of the paper pipeline — give it any figure image.
/ts-figure-svgPaperBanana+ — turn a paper's figure brief into a native, editable, publication-grade SVG. Stage 1 runs the OFFICIAL PaperBanana (dwzhu-pku/PaperBanana, pulled by `setup_paperbanana.py`, its own Retriever→Planner→Stylist→Visualizer→Critic pipeline) to produce candidate PNGs. Stage 2 is the "+": Claude LOOKS at the chosen PNG, extracts its DESIGN LANGUAGE (palette, type scale, spacing, idiom) into a style sheet, then redraws the figure FROM THE PAPER'S FACTS as real <rect>/<path>/<text> objects — never tracing pixels, never embedding the PNG. Stage 3 is a measured repair loop: `audit_svg.py` (stdlib, no renderer needed) catches overflow, text-on-text, icons cutting labels, stroke-scaled and canvas-clipped arrowheads, dangling connectors, sub-legible type, font-fallback glyphs, CSS-cascade colour traps and traced path-soup; ≥4 rounds, no upper bound while defects remain. Ends on a vector PDF verified on the real compiled page. Use when a figure must be editable and correct, not merely pretty.
/ts-kg-buildBuild a reusable research-PATTERN knowledge graph from a paper corpus, so ts-idea2story can recall prior problem→solution→story patterns. Claude does the reasoning (story-first pattern extraction, cluster naming + summaries); small scripts do the irreducible math (embeddings via a USER-SUPPLIED endpoint, clustering, graph assembly). Best-effort and honestly optional — without an embedding endpoint it degrades to a flat in-context "pattern shelf". Use to (re)build the KG for a domain, or skip it and let ts-idea2story rely on web search alone.
/ts-paperGenerate a complete, publication-format journal/conference paper (LaTeX → compiled PDF) from whatever the user drops — a one-line idea, a proposal, or a proposal WITH real results. It ROUTES the input (idea→idea2story; proposal→proposal mode; results-present→data-aware mode), then runs plan→cite→write→refine→review→figure→latex using Claude's native abilities (reasoning, WebSearch, vision, file I/O, running Python) instead of a heavyweight per-call pipeline. Template-agnostic (ts_iieta + neurips bundled). Use for "write the paper", "proposal to paper", "turn this idea/report into a paper". Integrity is absolute: in proposal mode never fabricate numbers; in data-aware mode every number must trace to the user's real data.
/ts-paper-citeStage 2 of the ts-paper suite. Build a complete, REAL refs.bib for a Traitement du Signal paper — using the user's provided references first and Claude's native WebSearch/WebFetch only for genuine gaps. Every entry must have full metadata (authors, year, venue, vol(issue):pages, DOI); never a title-only stub; reference count is driven by real evidence, not a quota. Use when assembling or fixing the bibliography of a TS paper, or whenever citations must be real and complete.
/ts-paper-dataDATA-AWARE mode for the ts-paper suite. Activated by the orchestrator's router ONLY when the input ships REAL measured results (results_mode == "data_aware"); the proposal/no-numbers path is unchanged. Claude reads the user's data in ANY form (CSV / JSON / a pasted table / numbers in prose), judges it directly — there is NO fixed results schema — fills the result tables itself with real numbers in past tense, and writes the per-section text from the evidence. Two thin code backstops keep it honest: a schema-agnostic number-audit (draft_lint) and matplotlib results figures (plot_results.py). Use when a proposal/report comes with real experimental data.
Other plugins' skills for the same job