PixInsight MCP——自主深空天文摄影处理
一个自主的深空天文摄影处理管道,使用Claude(通过Claude Code/Max订阅)通过基于文件的IPC驱动PixInsight。LLM扮演着处理主管的角色,在拉伸、细节增强、色彩饱和度和星形管理方面做出创造性的决定,而代码强制的质量门可以防止常见的处理故障,如振铃伪影、核心燃烧和星形破坏。
状态:工作正在进行中。积极开发并用于生产加工。
注意scripts/run-pipeline.mjs:中的原始完全脚本化管道scripts/run-pipeline.mjs这是第一种方法——一种不涉及LLM的确定性、配置驱动的处理链。现在是 被GIGA代理管道取代 (agents/llm/giga-run.mjs)该公司聘请克劳德担任创意处理总监。脚本化管道仍保留在仓库中以供参考,但不再进行主动维护。所有新的开发都以代理架构为目标。
______________________________________________________________________
它的作用
您提供校准的堆叠主帧(WBPP后)和最小的JSON配置。该管道对目标进行分类,从之前的运行中调用处理知识,执行确定性线性准备,然后将控制权交给Claude代理,该代理在四个创意分支中生成括号内的候选集,进行自我批评,并组成最终图像——同时代码强制的质量门可以防止代理产生振铃伪影、烧坏核心或破坏恒星。
You: config.json with M81 HaLRGB file paths + "push IFN hard, vivid galaxy colors"
Pipeline:
1. Classifies M81 as galaxy_spiral (core_arms_ifn, broadband, high dynamic range)
2. Recalls memory: "Seti target 0.12 for L, HDRMT inverted 6L/1i, Ha strength 0.25"
3. Deterministic prep: align, combine, GC, BXT, SPCC, NXT, SXT, stretch (~12 min, cached)
4. Creative agent generates 16 candidates across 4 branches:
- Luminance detail: LHE + HDRMT from weak to overdone
- IFN/faint structure: shadow-lifting curves from subtle to aggressive
- Color: saturation curves + Ha injection from restrained to overdone
- Stars: stretch + color saturation from bright to over-reduced
5. Critic pass selects branch winners, identifies overdone boundaries
6. Composes 4 final candidates (balanced, bold-IFN, bold-color, edge)
7. Art director picks near-edge-but-credible winner
8. Quality gates pass -> saves final XISF + JPG -> saves memory for next target______________________________________________________________________
架构概述
+---------------------+
| Config JSON |
| (target, channels, |
| aesthetic prefs) |
+---------+-----------+
|
+---------v-----------+
| Classifier |
| agents/classifier |
| target-taxonomy.json|
+---------+-----------+
|
+------------------+------------------+
| |
+----------v-----------+ +-------------v-----------+
| Phase 1: Deterministic| | Phase 2+: Creative Agent |
| Prep (no LLM) | | (Claude Max subprocess) |
| deterministic-prep.mjs| | giga-run.mjs |
| | | |
| open, align, combine, | | 53 MCP tools |
| GC, BN, BXT, SPCC, | | bracket-then-critic |
| NXT, SXT, stretch | | 4 branches x 4 candidates|
+-----------+-----------+ | quality gates |
| +-------------+-------------+
| |
+----> PixInsight (PJSR) 0.25会破坏细节”)
1. **特质** --按性状名称键控(例如,“core_halo”目标需要HDRMT maskClipLow>=0.35)
1. **类型** --按分类键控(例如,galaxy_spiral Seti拉伸目标=0.12)
1. **数据类** --按工作流程+主题量表(例如,HaLRGB_large)排序
1. **目标** --按目标名称键入(例如M81特定Ha注射强度)
这 `recallForBrief()` 该函数从所有级别收集所有相关条目,进行分类匹配,所有特征键(结构区域、信号类型、颜色分区等)、数据类指纹和目标名称。代理在每次运行开始时都会收到一个格式化的摘要。
内存优化器(`optimizeMemory()`)在每个处理会话后运行,并自动向上提升层次结构中的条目:
- 相同的参数+值在3+个相同类型的目标中获胜-->提升到类型级别
- 在共享特征的2+种类型中确认了相同的参数+值-->提升到特征级别
- 在所有数据类中确认类型级别条目-->推广到通用
这意味着处理M81(具有core_arms_ifn和高动态范围的galaxy_spiral)的知识可以为面纱星云(超新星遗迹)的处理提供信息,因为它们具有明亮的核心和类似的HDRMT掩蔽要求等处理特征。
### 支架然后批评工作流程
创意代理遵循中定义的结构化7阶段工作流程 `agents/llm/prompts/giga-orchestrator.mjs`对于四个分支中的每一个,代理必须以递增的强度生成四个候选:
- **软弱/克制** --显然过于保守
- **目标/粗体** --预期的最佳点
- **边缘** --突破极限,可能会显示第一个伪影
- **过度的** --故意太强,标志着拒绝的界限
如果代理无法生成过度的候选对象,则表示它没有搜索到足够的参数空间。这是在提示中强制执行的一项硬性要求:“在只产生一个可接受的结果后,永远不要调用finish。”
这四个分支解决了无法同时优化的冲突目标:
- **分支A——亮度细节**:LHE多尺度+HDRMT反转(当L通道存在时)
- **B分支——微弱结构/IFN**:通过反转亮度蒙版的阴影提升曲线
- **分支C——颜色丰富性**:两级饱和度曲线+色调选择性增强+Ha注入
- **D分部--星级政策**:对提取的星形层进行拉伸、颜色饱和度和缩减决策
生成后,评论家通过评估每个分支的候选人,确定过度的边界,选择获胜者,并可能触发一轮狭义的细化。构图候选人(平衡、大胆的IFN、大胆的颜色、边缘)结合了分支获奖者,然后是构图评论家和艺术总监,以“接近边缘但可信”为目标
### 准备缓存
确定性准备根据准备脚本内容的SHA-256哈希加上每个输入主文件的指纹(文件大小+mtime+前/后64KB内容哈希)计算缓存密钥。缓存命中将预先计算的XISF文件直接加载到PixInsight中,跳过10-15分钟的线性处理。缓存存储在 `~/.pixinsight-mcp/prep-cache/`.
### 评分模型
8维评分模型(`agents/scoring.mjs`)具有目标类型比重曲线:
- 细节_可信度,背景_质量,颜色_自然性,明星_完整性
- 音调平衡、主体分离、艺术性、审美连贯性
每个维度得分为0-100。权重分布因目标类型而异(galaxy_spiral权重detail_credibility最高;star_cluster_open权重star_integrity最高)。
______________________________________________________________________
## 处理流程
DETERMINISTIC PREP (Phase 1, ~10-15 min first run, cached thereafter): disk space check (>= 20 GB required) --> cache key computation (script hash + input fingerprints) --> [cache hit: load XISF files, skip to Phase 2] --> close all open images --> open masters (with channel swap if configured) --> check dimensions, align to R reference via StarAlignment --> combine RGB channels --> gradient correction (GC or ABE, auto-selected) --> BXT correct_only (deconvolution) --> copy astrometric solution back (BXT strips WCS) --> SPCC color calibration --> background neutralization --> NXT linear denoise (0.20) --> BXT sharpen --> SXT star extraction (linear mode, stars=true only) --> Seti statistical stretch (target=0.12, headroom=0.05) --> NXT post-stretch denoise (0.25) --> [repeat GC, BXT, NXT, SXT, stretch for L and Ha if present] --> save to cache
CREATIVE AGENT (Phase 2+, ~30-60 min via Claude Max): Phase 0: recall_memory, inspect prep diagnostics Phase 2: Branch generation (4 branches x 4 candidates = 16 candidates) Branch A -- Luminance detail (LHE, HDRMT, masks) Branch B -- Faint structure / IFN (shadow-lifting curves, inverted masks) Branch C -- Color / Ha injection (saturation curves, narrowband blending) Branch D -- Stars (stretch, color saturation, screen blend params) Phase 3: Branch critic pass (score, compare, select winners) Phase 4: Optional narrow refinement (1 round max) Phase 5: Composition candidates (balanced, bold-IFN, bold-color, edge) Phase 6: Composition critic pass Phase 7: Art director decision (near-edge but credible) Phase 7.5: Final gradient correction Phase 8: Quality gates (star quality, ringing, core burning) Phase 9: Final polish + save_memory --> save final XISF + JPG --> run memory optimizer (auto-promote patterns)
______________________________________________________________________
## 结果
在运行之间成功处理了零特定于目标的代码更改:
- **M81/M82** (博德星系+雪茄星系)——螺旋星系,HaLRGB,5个通道。IFN在银河卷云中可见,Ha发射突出了螺旋臂中的HII区域,尘埃带用HDRMT倒置解析,核心结构保留了净空延伸。
- **M97猫头鹰星云** --行星状星云,LRGB。内壳结构通过精细尺度LHE解析,微弱的外晕通过阴影提升显现出来,OIII/Ha分区颜色得以保留。第一次尝试的结果被描述为零目标调谐的“惊人”。
- **Abell 2151大力士星团** --星系团,LRGB。数十个微小而多样的星系被保守的SXT重叠锐化,恒星颜色多样性得以保留,各种星系形态和颜色可见。
______________________________________________________________________
## 需求
- **PixInsight** (用1.8.9+测试),安装了以下第三方模块:
- BlurXTerminator(BXT)
- 噪音终结者(NXT)
- StarX终端(SXT)
- **Node.js** v22+(用v22.13.1测试)
- **克劳德代码** 带着一个 **最大订阅数** (创意代理通过 `claude -p` 子流程—不需要API密钥)
- **校准的主框架** --WBPP堆叠、去层XISF文件(R、G、B,可选L和Ha)
- **macOS** (在Darwin/arm64上测试;Linux可能工作,但未经测试)
- 至少20 GB的可用磁盘空间(在启动时检查)
______________________________________________________________________
## 快速开始
1. Build the MCP server
export PATH="/Users/aescaffre/.local/node-v22.13.1-darwin-arm64/bin:$PATH" cd /Users/aescaffre/pixinsight-mcp && npm run build
2. Start PixInsight and load the watcher script:
Script > Run Script... > pjsr/pixinsight-mcp-watcher.js
3. Verify bridge connectivity
node scripts/ping-watcher.mjs
4. Create a config JSON (see Config Format below) and run the GIGA pipeline
node agents/llm/giga-run.mjs --config /path/to/config.json
5. Optional: add a processing intent to guide aesthetic decisions
node agents/llm/giga-run.mjs --config /path/to/config.json --intent "push IFN hard, vivid galaxy colors"
6. Dry run (classification + brief only, no processing)
node agents/llm/giga-run.mjs --config /path/to/config.json --dry-run
传统的确定性管道(无LLM)仍然可用:
node scripts/run-pipeline.mjs --config /path/to/config.json node scripts/run-pipeline.mjs --config /path/to/config.json --restart-from stretch
______________________________________________________________________
## 配置格式
{ "files": { "targetName": "M81", "R": "/absolute/path/to/masterLight_R.xisf", "G": "/absolute/path/to/masterLight_G.xisf", "B": "/absolute/path/to/masterLight_B.xisf", "L": "/absolute/path/to/masterLight_L.xisf", "Ha": "/absolute/path/to/masterLight_Ha.xisf", "outputDir": "/absolute/path/to/output/", "channelSwap": "" }, "aestheticPreferences": { "noiseLevel": "very_clean", "glow": "moderate", "starPresence": "prominent" } }
**重要说明**:
- 所有文件路径 **必须是绝对的**。管道不会解析相对路径或在任何基目录前添加任何内容。
- 如果该筛选器不可用,请将频道键保留为空字符串(不省略)。
- 使用 `channelSwap` (例如。, `"RB,GB"` 如果您的过滤器标签不正确,请进行BRV过滤器轮校正。
- 工作流(LRGB、HaLRGB、HaRGB、RGB)会自动检测哪些通道具有文件路径。
______________________________________________________________________
## 项目结构
agents/ llm/ giga-run.mjs -- Main entry point (GIGA pipeline runner) deterministic-prep.mjs -- Phase 1: scripted linear processing with caching engine-max.mjs -- Claude Max subprocess engine (claude -p) tools.mjs -- 53 MCP tool definitions and handlers vision.mjs -- Diagnostic view generation and image messaging mcp-agent-tools.mjs -- MCP server for agent tool access prompts/ giga-orchestrator.mjs -- System prompt builder (generic, trait-driven) ops/ bridge.mjs -- File-based IPC with PixInsight quality-gates.mjs -- Star quality, ringing, core burning checks (PJSR) stats.mjs -- Image statistics and uniformity measurement stretch.mjs -- Seti statistical stretch (ported from PixInsight) gradient.mjs -- Gradient correction (ABE, GC, per-channel) masks.mjs -- Luminance mask creation and management preview.mjs -- JPEG preview export image-mgmt.mjs -- Clone, close, purge operations checkpoint.mjs -- Checkpoint save/restore index.mjs -- Ops module aggregator memory/ hierarchical-memory.mjs -- 5-level memory store with auto-promotion optimizer classifier.mjs -- Target classification and processing brief generation target-taxonomy.json -- 12 categories with 7 trait dimensions each scoring.mjs -- 8-dimension scoring model with per-type weight profiles artifact-store.mjs -- Per-run artifact management processing-profiles.json -- Default processing parameters per target type scripts/ run-pipeline.mjs -- Legacy deterministic pipeline (~2000 lines) ping-watcher.mjs -- Bridge connectivity test pjsr/ pixinsight-mcp-watcher.js -- PixInsight-side watcher (ECMAScript 5) src/ -- MCP server TypeScript source (for IDE/tool integration) editor/ server.mjs -- Web UI backend for config editing index.html -- Web UI frontend default-config.json -- Default pipeline configuration .claude/skills/ pixinsight-pipeline/ -- Processing knowledge base for Claude Code sessions SKILL.md -- Pipeline overview and parameter tuning guide reference/ -- PJSR processes, gotchas, tools, stretch formulas
______________________________________________________________________
## 处理技术
|技术|起源|实施|
|-----------|--------|----------------|
|Seti统计拉伸| [塞蒂·阿斯特罗](https://www.setiastro.com) v2.3(Franklin Marek)|移植到Node.js:黑点重新缩放、MTF、归一化、Hermite HDR压缩|
|GHS拉伸| [全球统一制度](https://ghsastro.co.uk) (克兰菲尔德和雪莱)|PixelMath分段回退(无.dylib)|
|屏幕混合星星|标准技术| `~(~$T * ~(strength * stars))` --无卤复合|
|Ha注入|社区技术|R通道注入+亮度限制的亮度提升|
|倒置HDRMT | PixInsight社区|增强局部细节而不是压缩亮度|
|智能梯度去除|原始|通过角均匀性度量对ABE与GC进行比较,每通道模式|
|分层记忆|原创| 5级知识库,可跨目标自动推广|
|支架然后评论家|改编自摄影支架|每个创意分支有4名候选人(弱/目标/边缘/过度)|
______________________________________________________________________
## Astro ARO——远程天文台
该项目由以下成员开发 [**阿斯特罗 ARO**](https://astrolentejo.fr),位于 **阿连特茹黑暗天空保护区** (葡萄牙)-欧洲最黑暗的地点之一 **博尔特尔2-3**.
座位经常可供远程观察。访问 [团队部分](https://astrolentejo.fr/teams) 来自天文台的图像。
______________________________________________________________________
## 许可证
麻省理工学院