gsd-mempalace-capture

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
STOP -- DO NOT READ THIS FILE. You are already reading it. This prompt was injected into your context by the command system. Using the Read tool on this file wastes tokens. Begin executing Step 0 immediately.
停止——请勿阅读此文件。您已经在阅读它了。此提示由命令系统注入到您的上下文环境中。使用Read工具读取此文件会浪费token。请立即开始执行步骤0。

Step 0 -- Banner

步骤0 —— 横幅

Before ANY tool calls, display this banner:
GSD > MEMPALACE CAPTURE
Then proceed to Step 1.
在调用任何工具之前,显示以下横幅:
GSD > MEMPALACE CAPTURE
然后继续执行步骤1。

Step 1 -- Config Gate

步骤1 —— 配置检查

Check whether the MemPalace capability is enabled by reading
.planning/config.json
directly with the Read tool.
  1. Read
    .planning/config.json
    with the Read tool.
  2. If the file does not exist, or
    config.mempalace
    is absent, or
    config.mempalace.enabled !== true
    , or
    config.mempalace.capture_artifacts === false
    : display the disabled message and STOP.
  3. Otherwise proceed to Step 2.
Disabled message:
GSD > MEMPALACE CAPTURE

MemPalace capture is disabled (mempalace.enabled / mempalace.capture_artifacts).
Nothing was filed; the loop proceeds normally.
This step is
onError: skip
at
discuss:post
/
plan:post
/
verify:post
-- capture never fails a phase.
使用Read工具直接读取
.planning/config.json
,检查MemPalace功能是否已启用。
  1. 使用Read工具读取
    .planning/config.json
  2. 如果文件不存在,或
    config.mempalace
    字段缺失,或
    config.mempalace.enabled !== true
    ,或
    config.mempalace.capture_artifacts === false
    :显示禁用提示并停止
  3. 否则继续执行步骤2。
禁用提示信息:
GSD > MEMPALACE CAPTURE

MemPalace capture is disabled (mempalace.enabled / mempalace.capture_artifacts).
Nothing was filed; the loop proceeds normally.
此步骤在
discuss:post
/
plan:post
/
verify:post
阶段设置为
onError: skip
——捕获操作不会导致阶段失败。

Step 2 -- Resolve target

步骤2 —— 确定目标

  1. Artifact. Take the artifact from
    $ARGUMENTS
    . If absent, infer from the loop point:
    discuss:post
    CONTEXT.md
    ,
    plan:post
    PLAN.md
    ,
    verify:post
    SUMMARY.md
    .
  2. Room. Map artifact → room:
    • CONTEXT.md
      decisions
    • PLAN.md
      planning
    • SUMMARY.md
      milestones
      (Confirmed problem→fix pairs go to
      problems
      — see the
      capture-problems
      fragment used at
      execute:wave:post
      .)
  3. Wing.
    config.mempalace.wing
    if non-empty, else
    config.project_code
    , else the repo directory name.
  4. Mode / transport. Read
    config.mempalace.memory_mode
    . Prefer MCP (
    mempalace_*
    ) when your MemPalace MCP server is registered and your runtime permits those tools; otherwise use the
    mempalace
    CLI (covered by this skill's
    Bash
    allow-tool), as in
    mempalace-recall
    .
  1. 工件:从
    $ARGUMENTS
    中获取工件。如果不存在,则根据循环节点推断:
    discuss:post
    CONTEXT.md
    plan:post
    PLAN.md
    verify:post
    SUMMARY.md
  2. 空间(Room):将工件映射到对应空间:
    • CONTEXT.md
      decisions
      (决策空间)
    • PLAN.md
      planning
      (规划空间)
    • SUMMARY.md
      milestones
      (里程碑空间) (已确认的问题→修复配对将存入
      problems
      (问题空间)——详见
      execute:wave:post
      阶段使用的
      capture-problems
      片段。)
  3. 分区(Wing):若
    config.mempalace.wing
    非空则使用该值,否则使用
    config.project_code
    ,再否则使用仓库目录名称。
  4. 模式/传输方式:读取
    config.mempalace.memory_mode
    。若已注册MemPalace MCP服务器且运行时允许使用相关工具,则优先使用MCP(
    mempalace_*
    );否则使用
    mempalace
    CLI(此技能的
    Bash
    允许工具已覆盖该命令),例如
    mempalace-recall

Step 3 -- File verbatim (idempotent)

步骤3 —— 原样归档(幂等性)

On any error or timeout, stop and let the phase continue -- capture is best-effort.
  1. Dedup first. Interactive:
    mempalace_check_duplicate
    on the artifact's deterministic drawer id. Headless: rely on
    mempalace mine
    's content-hash idempotency.
  2. Add the drawer (verbatim). File the exact artifact text into
    room: <room>
    of
    wing: <wing>
    with provenance (
    source_file
    , phase id). Interactive:
    mempalace_add_drawer
    . Headless: see below.
    mempalace mine
    has no
    --room
    flag
    — only
    search
    accepts
    --room
    (CLI reference: https://mempalaceofficial.com/reference/cli.html). Room assignment is driven by
    detect_room()
    matching folder-path segments against the
    rooms:
    list in
    mempalace.yaml
    (mining guide: https://mempalaceofficial.com/guide/mining.html — "Rooms are auto-detected from your folder structure"; config reference: https://mempalaceofficial.com/guide/configuration.html). Stage the artifact under a room-named folder so
    detect_room()
    assigns it correctly:
    bash
    STAGE=".planning/.mempalace-stage"
    # One-time: declare the GSD room taxonomy so detect_room() recognizes these folders
    mkdir -p "$STAGE"
    [ -f "$STAGE/mempalace.yaml" ] || cat > "$STAGE/mempalace.yaml" <<'YAML'
    # Each entry MUST be a dict with a `name` key (the miner's detect_room()
    # indexes room["name"] — a bare-string list crashes _mine_impl with
    # TypeError: string indices must be integers, not 'str'). Optional fields:
    # `description`, `keywords` (matched against folder-path segments).
    rooms:
      - name: decisions
      - name: planning
      - name: milestones
      - name: problems
      - name: general
    YAML
    # Suppress MemPalace cache artifacts written into the scanned tree
    [ -f "$STAGE/.gitignore" ] || echo "mempalace_embedder.json" > "$STAGE/.gitignore"
    # Stage under <room>/<phase-id>/<basename> — stable path so mine's content-hash
    # idempotency (file_already_mined keys on absolute source_file + mtime) deduplicates
    # instead of creating duplicate drawers on re-runs.
    ROOM_DIR="$STAGE/<room>/<phase-id>"
    mkdir -p "$ROOM_DIR"
    cp "<artifact-path>" "$ROOM_DIR/<basename>"
    # Mine with --wing only — no --room flag; detect_room() assigns from the folder path
    mempalace mine "$STAGE" --wing <wing>
  3. Mirror KG facts unless
    config.mempalace.mirror_kg === false
    (registry default is true — an absent key means enabled): extract decision/delivery facts and
    mempalace_kg_add
    them with
    valid_from
    = the phase date (e.g.
    (<project>, decided, <decision>)
    from CONTEXT;
    (<phase>, delivered, <capability>)
    from SUMMARY). Under
    augment
    these are an additive mirror of GSD's native
    .planning/graphs/
    . Under
    kg_backend
    /
    replace
    the palace KG is the authoritative fact store — GSD still produces
    .planning/graphs/
    through its normal graphify, so an unreachable palace never loses a fact.
  4. Re-running a phase MUST NOT create duplicate drawers (deterministic ids +
    check_duplicate
    ).
若出现任何错误或超时,停止操作并让阶段继续——捕获操作仅做最大努力尝试。
  1. 先去重:交互式模式:对工件的确定性抽屉ID执行
    mempalace_check_duplicate
    。无头模式:依赖
    mempalace mine
    的内容哈希幂等性。
  2. 添加抽屉(原样):将工件的精确文本连同来源信息(
    source_file
    、阶段ID)归档至
    wing: <wing>
    下的
    room: <room>
    。交互式模式:使用
    mempalace_add_drawer
    。无头模式:详见下文。
    mempalace mine
    没有
    --room
    参数
    ——只有
    search
    命令接受
    --room
    参数(CLI参考文档:https://mempalaceofficial.com/reference/cli.html)。空间分配由
    detect_room()
    函数驱动,该函数会将文件夹路径片段与
    mempalace.yaml
    中的
    rooms:
    列表进行匹配(挖掘指南:https://mempalaceofficial.com/guide/mining.html ——“空间会从您的文件夹结构中自动检测”;配置参考文档:https://mempalaceofficial.com/guide/configuration.html)。将工件暂存到以空间命名的文件夹下,以便
    detect_room()
    正确分配空间:
    bash
    STAGE=".planning/.mempalace-stage"
    # One-time: declare the GSD room taxonomy so detect_room() recognizes these folders
    mkdir -p "$STAGE"
    [ -f "$STAGE/mempalace.yaml" ] || cat > "$STAGE/mempalace.yaml" <<'YAML'
    # Each entry MUST be a dict with a `name` key (the miner's detect_room()
    # indexes room["name"] — a bare-string list crashes _mine_impl with
    # TypeError: string indices must be integers, not 'str'). Optional fields:
    # `description`, `keywords` (matched against folder-path segments).
    rooms:
      - name: decisions
      - name: planning
      - name: milestones
      - name: problems
      - name: general
    YAML
    # Suppress MemPalace cache artifacts written into the scanned tree
    [ -f "$STAGE/.gitignore" ] || echo "mempalace_embedder.json" > "$STAGE/.gitignore"
    # Stage under <room>/<phase-id>/<basename> — stable path so mine's content-hash
    # idempotency (file_already_mined keys on absolute source_file + mtime) deduplicates
    # instead of creating duplicate drawers on re-runs.
    ROOM_DIR="$STAGE/<room>/<phase-id>"
    mkdir -p "$ROOM_DIR"
    cp "<artifact-path>" "$ROOM_DIR/<basename>"
    # Mine with --wing only — no --room flag; detect_room() assigns from the folder path
    mempalace mine "$STAGE" --wing <wing>
  3. 镜像KG事实,除非
    config.mempalace.mirror_kg === false
    (注册表默认值为true——缺失该键意味着功能启用):提取决策/交付事实,并使用
    mempalace_kg_add
    命令添加,设置
    valid_from
    为阶段日期(例如从CONTEXT中提取
    (<project>, decided, <decision>)
    ;从SUMMARY中提取
    (<phase>, delivered, <capability>)
    )。在
    augment
    模式下,这些事实是GSD原生
    .planning/graphs/
    增量式镜像。在
    kg_backend
    /
    replace
    模式下,MemPalace的KG是权威事实存储——GSD仍会通过正常的图形化流程生成
    .planning/graphs/
    ,因此即使MemPalace不可访问,也不会丢失任何事实。
  4. 重新运行阶段时不得创建重复抽屉(通过确定性ID +
    check_duplicate
    实现)。

Step 4 -- Report

步骤4 —— 报告

Print a one-line summary:
Filed <artifact> → <wing>/<room> (<n> KG facts)
or
MemPalace unavailable — capture skipped
.
打印一行摘要:
Filed <artifact> → <wing>/<room> (<n> KG facts)
(已归档<工件>至<分区>/<空间>(共<n>条KG事实))或
MemPalace unavailable — capture skipped
(MemPalace不可用——已跳过捕获操作)。

Anti-Patterns

反模式

  1. DO NOT let any MemPalace error fail the step -- capture is
    onError: skip
    .
  2. DO NOT write lossy summaries -- store the verbatim artifact text (AAAK compression is a separate, optional index).
  3. DO NOT prune or delete drawers here -- pruning (
    sync --apply
    ) is the curator agent's job at
    ship:post
    , wing-scoped only.
  4. DO NOT skip the config gate or the dedup check.
  1. 请勿让任何MemPalace错误导致步骤失败——捕获操作设置为
    onError: skip
  2. 请勿编写有损摘要——存储工件的原始文本(AAAK压缩是独立的可选索引)。
  3. 请勿在此处修剪或删除抽屉——修剪操作(
    sync --apply
    )是curator agent在
    ship:post
    阶段的工作,且仅针对指定分区。
  4. 请勿跳过配置检查或去重验证。