mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-14 02:42:04 +08:00
feat: 添加需求分析功能,支持维度拆解、覆盖度评估和歧义检测
This commit is contained in:
206
.claude/skills/skill-tuning/specs/dimension-mapping.md
Normal file
206
.claude/skills/skill-tuning/specs/dimension-mapping.md
Normal file
@@ -0,0 +1,206 @@
|
||||
# Dimension to Spec Mapping
|
||||
|
||||
维度关键词到 Spec 的映射规则,用于 action-analyze-requirements 阶段的自动匹配。
|
||||
|
||||
## When to Use
|
||||
|
||||
| Phase | Usage |
|
||||
|-------|-------|
|
||||
| action-analyze-requirements | 维度→类别→Spec 自动匹配 |
|
||||
| action-propose-fixes | 策略选择参考 |
|
||||
|
||||
---
|
||||
|
||||
## Keyword → Category Mapping
|
||||
|
||||
基于关键词将用户描述的维度映射到问题类别。
|
||||
|
||||
### 中英文关键词表
|
||||
|
||||
| Keywords (中文) | Keywords (英文) | Primary Category | Secondary |
|
||||
|----------------|-----------------|------------------|-----------|
|
||||
| token, 上下文, 爆炸, 太长, 超限, 膨胀 | token, context, explosion, overflow, bloat | context_explosion | - |
|
||||
| 遗忘, 忘记, 指令丢失, 约束消失, 目标漂移 | forget, lost, drift, constraint, goal | memory_loss | - |
|
||||
| 状态, 数据, 格式, 不一致, 丢失, 损坏 | state, data, format, inconsistent, corrupt | dataflow_break | - |
|
||||
| agent, 子任务, 失败, 嵌套, 调用, 协调 | agent, subtask, fail, nested, call, coordinate | agent_failure | - |
|
||||
| 慢, 性能, 效率, token 消耗, 延迟 | slow, performance, efficiency, latency | performance | context_explosion |
|
||||
| 提示词, prompt, 输出不稳定, 幻觉 | prompt, unstable, hallucination | prompt_quality | - |
|
||||
| 架构, 结构, 模块, 耦合, 扩展 | architecture, structure, module, coupling | architecture | - |
|
||||
| 错误, 异常, 恢复, 降级, 崩溃 | error, exception, recovery, crash | error_handling | agent_failure |
|
||||
| 输出, 质量, 格式, 验证, 不完整 | output, quality, validation, incomplete | output_quality | - |
|
||||
| 交互, 体验, 进度, 反馈, 不清晰 | interaction, ux, progress, feedback | user_experience | - |
|
||||
|
||||
### Matching Algorithm
|
||||
|
||||
```javascript
|
||||
function matchCategory(keywords) {
|
||||
const categoryScores = {};
|
||||
|
||||
for (const keyword of keywords) {
|
||||
const normalizedKeyword = keyword.toLowerCase();
|
||||
|
||||
for (const [category, categoryKeywords] of Object.entries(KEYWORD_MAP)) {
|
||||
if (categoryKeywords.some(k => normalizedKeyword.includes(k) || k.includes(normalizedKeyword))) {
|
||||
categoryScores[category] = (categoryScores[category] || 0) + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 返回得分最高的类别
|
||||
const sorted = Object.entries(categoryScores).sort((a, b) => b[1] - a[1]);
|
||||
|
||||
if (sorted.length === 0) return null;
|
||||
|
||||
// 如果前两名得分相同,返回多类别(需澄清)
|
||||
if (sorted.length > 1 && sorted[0][1] === sorted[1][1]) {
|
||||
return {
|
||||
primary: sorted[0][0],
|
||||
secondary: sorted[1][0],
|
||||
ambiguous: true
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
primary: sorted[0][0],
|
||||
secondary: sorted[1]?.[0] || null,
|
||||
ambiguous: false
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Category → Taxonomy Pattern Mapping
|
||||
|
||||
将问题类别映射到 problem-taxonomy.md 中的检测模式。
|
||||
|
||||
| Category | Pattern IDs | Detection Focus |
|
||||
|----------|-------------|-----------------|
|
||||
| context_explosion | CTX-001, CTX-002, CTX-003, CTX-004, CTX-005 | Token 累积、内容传递模式 |
|
||||
| memory_loss | MEM-001, MEM-002, MEM-003, MEM-004, MEM-005 | 约束传播、检查点机制 |
|
||||
| dataflow_break | DF-001, DF-002, DF-003, DF-004, DF-005 | 状态存储、Schema 验证 |
|
||||
| agent_failure | AGT-001, AGT-002, AGT-003, AGT-004, AGT-005, AGT-006 | 错误处理、结果验证 |
|
||||
| prompt_quality | - | (无内置检测,需 Gemini 分析) |
|
||||
| architecture | - | (无内置检测,需 Gemini 分析) |
|
||||
| performance | CTX-001, CTX-003 | (复用 context 检测) |
|
||||
| error_handling | AGT-001, AGT-002 | (复用 agent 检测) |
|
||||
| output_quality | - | (无内置检测,需 Gemini 分析) |
|
||||
| user_experience | - | (无内置检测,需 Gemini 分析) |
|
||||
|
||||
---
|
||||
|
||||
## Category → Strategy Mapping
|
||||
|
||||
将问题类别映射到 tuning-strategies.md 中的修复策略。
|
||||
|
||||
### Core Categories (有完整策略)
|
||||
|
||||
| Category | Available Strategies | Risk Level |
|
||||
|----------|---------------------|------------|
|
||||
| context_explosion | sliding_window, path_reference, context_summarization, structured_state | Low-Medium |
|
||||
| memory_loss | constraint_injection, state_constraints_field, checkpoint_restore, goal_embedding | Low-Medium |
|
||||
| dataflow_break | state_centralization, schema_enforcement, field_normalization | Low-Medium |
|
||||
| agent_failure | error_wrapping, result_validation, flatten_nesting | Low-Medium |
|
||||
|
||||
### Extended Categories (需 Gemini 生成策略)
|
||||
|
||||
| Category | Available Strategies | Risk Level |
|
||||
|----------|---------------------|------------|
|
||||
| prompt_quality | structured_prompt, output_schema, grounding_context, format_enforcement | Low |
|
||||
| architecture | phase_decomposition, interface_contracts, plugin_architecture, state_machine | Medium-High |
|
||||
| performance | token_budgeting, parallel_execution, result_caching, lazy_loading | Low-Medium |
|
||||
| error_handling | graceful_degradation, error_propagation, structured_logging, error_context | Low |
|
||||
| output_quality | quality_gates, output_validation, template_enforcement, completeness_check | Low |
|
||||
| user_experience | progress_tracking, status_communication, interactive_checkpoints, guided_workflow | Low |
|
||||
|
||||
---
|
||||
|
||||
## Coverage Rules
|
||||
|
||||
### Satisfaction Criteria
|
||||
|
||||
判断"是否满足需求"的标准:
|
||||
|
||||
```javascript
|
||||
function evaluateSatisfaction(specMatch) {
|
||||
// 核心标准:有可用的修复策略
|
||||
const hasFix = specMatch.strategy_match !== null &&
|
||||
specMatch.strategy_match.strategies.length > 0;
|
||||
|
||||
// 辅助标准:有检测手段
|
||||
const hasDetection = specMatch.taxonomy_match !== null;
|
||||
|
||||
return {
|
||||
satisfied: hasFix,
|
||||
detection_available: hasDetection,
|
||||
needs_gemini: !hasDetection // 无内置检测时需要 Gemini 分析
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### Coverage Status Thresholds
|
||||
|
||||
| Status | Condition |
|
||||
|--------|-----------|
|
||||
| satisfied | coverage_rate >= 80% |
|
||||
| partial | 50% <= coverage_rate < 80% |
|
||||
| unsatisfied | coverage_rate < 50% |
|
||||
|
||||
---
|
||||
|
||||
## Fallback Rules
|
||||
|
||||
当无法匹配到具体类别时的处理:
|
||||
|
||||
```javascript
|
||||
function handleUnmatchedDimension(dimension) {
|
||||
return {
|
||||
dimension_id: dimension.id,
|
||||
taxonomy_match: null,
|
||||
strategy_match: {
|
||||
strategies: ['custom'], // Fallback to custom strategy
|
||||
risk_levels: ['medium']
|
||||
},
|
||||
has_fix: true, // custom 策略视为"可满足"
|
||||
needs_gemini_analysis: true,
|
||||
fallback_reason: 'no_keyword_match'
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Usage Example
|
||||
|
||||
```javascript
|
||||
// 输入:用户描述 "skill 执行太慢,而且有时候会忘记最初的指令"
|
||||
|
||||
// Step 1: Gemini 拆解为维度
|
||||
const dimensions = [
|
||||
{ id: 'DIM-001', description: '执行太慢', keywords: ['慢', '执行'], confidence: 0.9 },
|
||||
{ id: 'DIM-002', description: '忘记最初指令', keywords: ['忘记', '指令'], confidence: 0.85 }
|
||||
];
|
||||
|
||||
// Step 2: 匹配类别
|
||||
// DIM-001 → performance (慢)
|
||||
// DIM-002 → memory_loss (忘记, 指令)
|
||||
|
||||
// Step 3: 匹配 Spec
|
||||
const specMatches = [
|
||||
{
|
||||
dimension_id: 'DIM-001',
|
||||
taxonomy_match: { category: 'performance', pattern_ids: ['CTX-001', 'CTX-003'], severity_hint: 'medium' },
|
||||
strategy_match: { strategies: ['token_budgeting', 'parallel_execution'], risk_levels: ['low', 'low'] },
|
||||
has_fix: true
|
||||
},
|
||||
{
|
||||
dimension_id: 'DIM-002',
|
||||
taxonomy_match: { category: 'memory_loss', pattern_ids: ['MEM-001', 'MEM-002'], severity_hint: 'high' },
|
||||
strategy_match: { strategies: ['constraint_injection', 'checkpoint_restore'], risk_levels: ['low', 'low'] },
|
||||
has_fix: true
|
||||
}
|
||||
];
|
||||
|
||||
// Step 4: 评估覆盖度
|
||||
// 2/2 = 100% → satisfied
|
||||
```
|
||||
@@ -14,6 +14,35 @@ Classification of skill execution issues with detection patterns and severity cr
|
||||
|
||||
## Problem Categories
|
||||
|
||||
### 0. Authoring Principles Violation (P0)
|
||||
|
||||
**Definition**: 违反 skill 撰写首要准则(简洁高效、去除存储、上下文流转)。
|
||||
|
||||
**Root Causes**:
|
||||
- 不必要的中间文件存储
|
||||
- State schema 过度膨胀
|
||||
- 文件中转代替上下文传递
|
||||
- 重复数据存储
|
||||
|
||||
**Detection Patterns**:
|
||||
|
||||
| Pattern ID | Regex/Check | Description |
|
||||
|------------|-------------|-------------|
|
||||
| APV-001 | `/Write\([^)]*temp-|intermediate-/` | 中间文件写入 |
|
||||
| APV-002 | `/Write\([^)]+\)[\s\S]{0,50}Read\([^)]+\)/` | 写后立即读(文件中转) |
|
||||
| APV-003 | State schema > 15 fields | State 字段过多 |
|
||||
| APV-004 | `/_history\s*[.=].*push|concat/` | 无限增长数组 |
|
||||
| APV-005 | `/debug_|_cache|_temp/` in state | 调试/缓存字段残留 |
|
||||
| APV-006 | Same data in multiple state fields | 重复存储 |
|
||||
|
||||
**Impact Levels**:
|
||||
- **Critical**: 中间文件 > 5 个,严重违反原则
|
||||
- **High**: State 字段 > 20 个,或存在文件中转
|
||||
- **Medium**: 存在调试字段或轻微冗余
|
||||
- **Low**: 轻微的命名不规范
|
||||
|
||||
---
|
||||
|
||||
### 1. Context Explosion (P2)
|
||||
|
||||
**Definition**: Excessive token accumulation causing prompt size to grow unbounded.
|
||||
@@ -181,6 +210,7 @@ function calculateIssueSeverity(issue) {
|
||||
|
||||
| Problem Type | Recommended Strategies | Priority Order |
|
||||
|--------------|----------------------|----------------|
|
||||
| **Authoring Principles Violation** | eliminate_intermediate_files, minimize_state, context_passing | 1, 2, 3 |
|
||||
| Context Explosion | sliding_window, path_reference, context_summarization | 1, 2, 3 |
|
||||
| Long-tail Forgetting | constraint_injection, state_constraints_field, checkpoint | 1, 2, 3 |
|
||||
| Data Flow Disruption | state_centralization, schema_enforcement, field_normalization | 1, 2, 3 |
|
||||
|
||||
189
.claude/skills/skill-tuning/specs/skill-authoring-principles.md
Normal file
189
.claude/skills/skill-tuning/specs/skill-authoring-principles.md
Normal file
@@ -0,0 +1,189 @@
|
||||
# Skill Authoring Principles
|
||||
|
||||
Skill 撰写首要准则。所有诊断和优化以此为纲。
|
||||
|
||||
---
|
||||
|
||||
## 核心原则
|
||||
|
||||
```
|
||||
简洁高效 → 去除无关存储 → 去除中间存储 → 上下文流转
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 1. 简洁高效
|
||||
|
||||
**原则**:最小化实现,只做必要的事
|
||||
|
||||
| DO | DON'T |
|
||||
|----|-------|
|
||||
| 单一职责阶段 | 臃肿的多功能阶段 |
|
||||
| 直接的数据路径 | 迂回的处理流程 |
|
||||
| 必要的字段 | 冗余的 schema 定义 |
|
||||
| 精准的 prompt | 过度详细的指令 |
|
||||
|
||||
**检测模式**:
|
||||
- Phase 文件 > 200 行 → 需拆分
|
||||
- State schema 字段 > 20 个 → 需精简
|
||||
- 同一数据多处定义 → 需去重
|
||||
|
||||
---
|
||||
|
||||
## 2. 去除无关存储
|
||||
|
||||
**原则**:不存储不需要的数据
|
||||
|
||||
| DO | DON'T |
|
||||
|----|-------|
|
||||
| 只存最终结果 | 存储调试信息 |
|
||||
| 存路径引用 | 存完整内容副本 |
|
||||
| 存必要索引 | 存全量历史 |
|
||||
|
||||
**检测模式**:
|
||||
```javascript
|
||||
// BAD: 存储完整内容
|
||||
state.full_analysis_result = longAnalysisOutput;
|
||||
|
||||
// GOOD: 存路径 + 摘要
|
||||
state.analysis = {
|
||||
path: `${workDir}/analysis.json`,
|
||||
summary: extractSummary(output),
|
||||
key_findings: extractFindings(output)
|
||||
};
|
||||
```
|
||||
|
||||
**反模式清单**:
|
||||
- `state.debug_*` → 删除
|
||||
- `state.*_history` (无限增长) → 限制或删除
|
||||
- `state.*_cache` (会话内) → 改用内存变量
|
||||
- 重复字段 → 合并
|
||||
|
||||
---
|
||||
|
||||
## 3. 去除中间存储
|
||||
|
||||
**原则**:避免临时文件和中间状态文件
|
||||
|
||||
| DO | DON'T |
|
||||
|----|-------|
|
||||
| 直接传递结果 | 写文件再读文件 |
|
||||
| 函数返回值 | 中间 JSON 文件 |
|
||||
| 管道处理 | 阶段性存储 |
|
||||
|
||||
**检测模式**:
|
||||
```javascript
|
||||
// BAD: 中间文件
|
||||
Write(`${workDir}/temp-step1.json`, step1Result);
|
||||
const step1 = Read(`${workDir}/temp-step1.json`);
|
||||
const step2Result = process(step1);
|
||||
Write(`${workDir}/temp-step2.json`, step2Result);
|
||||
|
||||
// GOOD: 直接流转
|
||||
const step1Result = await executeStep1();
|
||||
const step2Result = process(step1Result);
|
||||
const finalResult = finalize(step2Result);
|
||||
Write(`${workDir}/final-output.json`, finalResult); // 只存最终结果
|
||||
```
|
||||
|
||||
**允许的存储**:
|
||||
- 最终输出(用户需要的结果)
|
||||
- 检查点(长流程恢复用,可选)
|
||||
- 备份(修改前的原始文件)
|
||||
|
||||
**禁止的存储**:
|
||||
- `temp-*.json`
|
||||
- `intermediate-*.json`
|
||||
- `step[N]-output.json`
|
||||
- `*-draft.md`
|
||||
|
||||
---
|
||||
|
||||
## 4. 上下文流转
|
||||
|
||||
**原则**:通过上下文传递而非文件
|
||||
|
||||
| DO | DON'T |
|
||||
|----|-------|
|
||||
| 函数参数传递 | 全局状态读写 |
|
||||
| 返回值链式处理 | 文件中转 |
|
||||
| prompt 内嵌数据 | 指向外部文件 |
|
||||
|
||||
**模式**:
|
||||
```javascript
|
||||
// 上下文流转模式
|
||||
async function executePhase(context) {
|
||||
const { previousResult, constraints, config } = context;
|
||||
|
||||
const result = await Task({
|
||||
prompt: `
|
||||
[CONTEXT]
|
||||
Previous: ${JSON.stringify(previousResult)}
|
||||
Constraints: ${constraints.join(', ')}
|
||||
|
||||
[TASK]
|
||||
Process and return result directly.
|
||||
`
|
||||
});
|
||||
|
||||
return {
|
||||
...context,
|
||||
currentResult: result,
|
||||
completed: ['phase-name']
|
||||
};
|
||||
}
|
||||
|
||||
// 链式执行
|
||||
let ctx = initialContext;
|
||||
ctx = await executePhase1(ctx);
|
||||
ctx = await executePhase2(ctx);
|
||||
ctx = await executePhase3(ctx);
|
||||
// ctx 包含完整上下文,无中间文件
|
||||
```
|
||||
|
||||
**State 最小化**:
|
||||
```typescript
|
||||
// 只存必要状态
|
||||
interface MinimalState {
|
||||
status: 'pending' | 'running' | 'completed';
|
||||
target: { name: string; path: string };
|
||||
result_path: string; // 最终结果路径
|
||||
error?: string;
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 应用场景
|
||||
|
||||
### 诊断时检查
|
||||
|
||||
| 检查项 | 违反时标记 |
|
||||
|--------|-----------|
|
||||
| Phase 内写入 temp 文件 | `unnecessary_storage` |
|
||||
| State 包含 *_history 无限数组 | `unbounded_state` |
|
||||
| 文件写入后立即读取 | `redundant_io` |
|
||||
| 多阶段传递完整内容 | `context_bloat` |
|
||||
|
||||
### 优化策略
|
||||
|
||||
| 问题 | 策略 |
|
||||
|------|------|
|
||||
| 中间文件过多 | `eliminate_intermediate_files` |
|
||||
| State 膨胀 | `minimize_state_schema` |
|
||||
| 重复存储 | `deduplicate_storage` |
|
||||
| 文件中转 | `context_passing` |
|
||||
|
||||
---
|
||||
|
||||
## 合规检查清单
|
||||
|
||||
```
|
||||
□ 无 temp/intermediate 文件写入
|
||||
□ State schema < 15 个字段
|
||||
□ 无重复数据存储
|
||||
□ Phase 间通过上下文/返回值传递
|
||||
□ 只存最终结果文件
|
||||
□ 无无限增长的数组
|
||||
□ 无调试字段残留
|
||||
```
|
||||
@@ -12,6 +12,155 @@ Detailed fix strategies for each problem category with implementation guidance.
|
||||
|
||||
---
|
||||
|
||||
## Authoring Principles Strategies (P0 - 首要准则)
|
||||
|
||||
> **核心原则**:简洁高效 → 去除无关存储 → 去除中间存储 → 上下文流转
|
||||
|
||||
### Strategy: eliminate_intermediate_files
|
||||
|
||||
**Purpose**: 删除所有中间文件,改用上下文流转。
|
||||
|
||||
**Implementation**:
|
||||
```javascript
|
||||
// Before: 中间文件
|
||||
async function process() {
|
||||
const step1 = await analyze();
|
||||
Write(`${workDir}/step1.json`, JSON.stringify(step1));
|
||||
|
||||
const step1Data = JSON.parse(Read(`${workDir}/step1.json`));
|
||||
const step2 = await transform(step1Data);
|
||||
Write(`${workDir}/step2.json`, JSON.stringify(step2));
|
||||
|
||||
const step2Data = JSON.parse(Read(`${workDir}/step2.json`));
|
||||
return finalize(step2Data);
|
||||
}
|
||||
|
||||
// After: 上下文流转
|
||||
async function process() {
|
||||
const step1 = await analyze();
|
||||
const step2 = await transform(step1); // 直接传递
|
||||
return finalize(step2); // 只返回最终结果
|
||||
}
|
||||
```
|
||||
|
||||
**Risk**: Low
|
||||
**Verification**: `ls ${workDir}` 无 temp/intermediate 文件
|
||||
|
||||
---
|
||||
|
||||
### Strategy: minimize_state
|
||||
|
||||
**Purpose**: 精简 State schema 至必要字段。
|
||||
|
||||
**Implementation**:
|
||||
```typescript
|
||||
// Before: 膨胀的 State
|
||||
interface State {
|
||||
status: string;
|
||||
target: TargetInfo;
|
||||
user_input: string;
|
||||
parsed_input: ParsedInput; // 删除 - 只在处理时用
|
||||
intermediate_result: any; // 删除 - 中间结果
|
||||
debug_info: DebugInfo; // 删除 - 调试信息
|
||||
analysis_cache: any; // 删除 - 缓存
|
||||
full_history: HistoryEntry[]; // 删除 - 无限增长
|
||||
step1_output: any; // 删除 - 中间输出
|
||||
step2_output: any; // 删除 - 中间输出
|
||||
final_result: FinalResult;
|
||||
}
|
||||
|
||||
// After: 精简的 State
|
||||
interface State {
|
||||
status: 'pending' | 'running' | 'completed' | 'failed';
|
||||
target: { name: string; path: string };
|
||||
result_path: string; // 最终结果路径
|
||||
error?: string; // 仅失败时有
|
||||
}
|
||||
```
|
||||
|
||||
**Rules**:
|
||||
- State 字段 ≤ 15 个
|
||||
- 删除所有 `debug_*`, `*_cache`, `*_temp` 字段
|
||||
- `*_history` 数组设置上限或改用滚动窗口
|
||||
|
||||
**Risk**: Medium (需确保不丢失必要数据)
|
||||
**Verification**: Count state fields ≤ 15
|
||||
|
||||
---
|
||||
|
||||
### Strategy: context_passing
|
||||
|
||||
**Purpose**: 用函数参数/返回值代替文件中转。
|
||||
|
||||
**Implementation**:
|
||||
```javascript
|
||||
// 上下文流转模式
|
||||
async function executeWorkflow(initialContext) {
|
||||
let ctx = initialContext;
|
||||
|
||||
// Phase 1: 直接传递上下文
|
||||
ctx = await executePhase1(ctx);
|
||||
|
||||
// Phase 2: 继续传递
|
||||
ctx = await executePhase2(ctx);
|
||||
|
||||
// Phase 3: 最终处理
|
||||
const result = await executePhase3(ctx);
|
||||
|
||||
// 只存最终结果
|
||||
Write(`${ctx.workDir}/result.json`, JSON.stringify(result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Phase 函数模板
|
||||
async function executePhaseN(ctx) {
|
||||
const { previousResult, constraints } = ctx;
|
||||
|
||||
const result = await Task({
|
||||
prompt: `
|
||||
[CONTEXT]
|
||||
${JSON.stringify(previousResult)}
|
||||
|
||||
[TASK]
|
||||
Process and return result.
|
||||
`
|
||||
});
|
||||
|
||||
// 返回更新后的上下文,不写文件
|
||||
return {
|
||||
...ctx,
|
||||
previousResult: result,
|
||||
completed: [...ctx.completed, 'phase-n']
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
**Risk**: Low
|
||||
**Verification**: 无 Write→Read 紧邻模式
|
||||
|
||||
---
|
||||
|
||||
### Strategy: deduplicate_storage
|
||||
|
||||
**Purpose**: 消除重复数据存储。
|
||||
|
||||
**Implementation**:
|
||||
```javascript
|
||||
// Before: 重复存储
|
||||
state.user_request = userInput;
|
||||
state.original_request = userInput;
|
||||
state.input_text = userInput;
|
||||
|
||||
// After: 单一来源
|
||||
state.input = userInput; // 唯一存储点
|
||||
```
|
||||
|
||||
**Risk**: Low
|
||||
**Verification**: 无相同数据多字段存储
|
||||
|
||||
---
|
||||
|
||||
## Context Explosion Strategies
|
||||
|
||||
### Strategy: sliding_window
|
||||
|
||||
Reference in New Issue
Block a user