spec-context

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Spec 上下文定位(FEATURE_DIR)

Spec Context Localization (FEATURE_DIR)

概览

Overview

在任何 Spec 命令/技能里,只要会读写
requirements/*.md
,就必须先确定
{FEATURE_DIR}
。本仓库以 当前 Git 分支名作为 spec pack 的定位锚点,禁止猜路径。
In any Spec command/skill, whenever you need to read or write
requirements/*.md
, you must first determine
{FEATURE_DIR}
. This repository uses the current Git branch name as the anchor for locating the spec pack; path guessing is strictly prohibited.

何时使用

When to Use

  • 你将要读/写:
    {FEATURE_DIR}/requirements/raw.md | clarify.md | competitors.md | solutions.md | prd.md
  • 你不确定当前处于哪个 spec pack(担心读写错目录)
  • 你看到“分支名不规范 / 目录结构不完整 / 缺 .aisdlc”之类上下文错误
  • You are about to read/write:
    {FEATURE_DIR}/requirements/raw.md | clarify.md | competitors.md | solutions.md | prd.md
  • You are unsure which spec pack you are currently in (worried about reading/writing to the wrong directory)
  • You encounter context errors such as "non-compliant branch name/incomplete directory structure/missing .aisdlc"

唯一做法(PowerShell)

The Only Correct Approach (PowerShell)

powershell
. ".\spec-common.ps1"
$context = Get-SpecContext
$FEATURE_DIR = $context.FEATURE_DIR
Write-Host "FEATURE_DIR=$FEATURE_DIR"
powershell
. ".\spec-common.ps1"
$context = Get-SpecContext
$FEATURE_DIR = $context.FEATURE_DIR
Write-Host "FEATURE_DIR=$FEATURE_DIR"

硬规则(必须遵守)

Hard Rules (Must Follow)

  • 先定位再读写:任何读/写
    requirements/*.md
    之前,必须先运行上面的脚本并回显
    FEATURE_DIR=...
  • 失败就停止
    Get-SpecContext
    报错时,必须立刻停止,不得继续生成/写文件内容(否则几乎必然跑偏上下文)。
  • 只用 FEATURE_DIR 拼路径:后续所有路径都必须以
    $FEATURE_DIR
    为前缀(禁止用当前工作目录做相对路径猜测)。
  • Locate first, then read/write: Before any read/write operation on
    requirements/*.md
    , you must run the above script and echo
    FEATURE_DIR=...
    .
  • Stop on failure: When
    Get-SpecContext
    reports an error, you must stop immediately and must not continue generating/writing file content (otherwise, you will almost certainly deviate from the correct context).
  • Only use FEATURE_DIR to construct paths: All subsequent paths must use
    $FEATURE_DIR
    as the prefix (guessing relative paths using the current working directory is prohibited).

常见错误

Common Mistakes

  • 在非 spec 分支上执行:分支名不符合
    {num}-{short-name}
    ,会导致无法定位 spec pack。
  • 手写
    .aisdlc/specs/...
    路径
    :人会写错,AI 更容易写错;必须以脚本输出为准。
  • 继续执行“生成文档”:只要上下文失败,就停止并先修复分支/目录结构。
  • Executing on a non-spec branch: If the branch name does not conform to the
    {num}-{short-name}
    format, the spec pack cannot be located.
  • Manually writing paths like
    .aisdlc/specs/...
    : Humans make mistakes, and AI is even more prone to errors; you must rely on the script's output.
  • Continuing to "generate documents": As long as the context validation fails, stop and first fix the branch/directory structure.