Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,25 +131,30 @@ public String getContent() {
}

/**
* 获取有效内容:优先使用 content,如果为空则从 artifact.code 自动生成
* 获取有效内容:合并 contentartifact.code,两者均有值时拼接返回
* <p>
* 这样可以避免 CODE 经验中 contentartifact.code 的冗余配置
* 先拼接 content(如有),再拼接从 artifact.code 生成的内容(如有)
*/
public String getEffectiveContent() {
// 1. 如果 content 有值,直接返回
StringBuilder result = new StringBuilder();

// 1. 追加 content
if (content != null && !content.isBlank()) {
return content;
result.append(content);
}

// 2. 如果 artifact.code 存在,自动生成 content
// 2. 追加 artifact.code 生成的内容
if (artifact != null && artifact.getCode() != null) {
ExperienceArtifact.CodeArtifact codeArtifact = artifact.getCode();
if (codeArtifact.getCode() != null && !codeArtifact.getCode().isBlank()) {
return buildContentFromCodeArtifact(codeArtifact);
if (!result.isEmpty()) {
result.append("\n\n");
}
result.append(buildContentFromCodeArtifact(codeArtifact));
Comment on lines 149 to +153
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getEffectiveContent() currently concatenates content and the generated artifact.code block whenever both are present. If existing data already stores the generated block in content (or overlaps heavily), this will duplicate the same guidance and contradict the PR description (“less redundant output”). Consider normalizing and de-duplicating before appending (e.g., compare trimmed/normalized strings, or skip appending when content already contains the generated block). Also consider trimming trailing newlines from content so the \n\n separator doesn’t accidentally introduce multiple blank lines.

Copilot uses AI. Check for mistakes.
}
}

return content;
return result.isEmpty() ? content : result.toString();
}

/**
Expand Down