fix(coding-agent): unify source provenance, closes #1734

This commit is contained in:
Mario Zechner
2026-03-23 02:02:42 +01:00
parent 883862a354
commit 4e5af01d73
26 changed files with 340 additions and 157 deletions
+27 -4
View File
@@ -5,7 +5,7 @@ import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "pat
import { CONFIG_DIR_NAME, getAgentDir } from "../config.js";
import { parseFrontmatter } from "../utils/frontmatter.js";
import type { ResourceDiagnostic } from "./diagnostics.js";
import type { SourceInfo } from "./source-info.js";
import { createSyntheticSourceInfo, type SourceInfo } from "./source-info.js";
/** Max name length per spec */
const MAX_NAME_LENGTH = 64;
@@ -76,8 +76,7 @@ export interface Skill {
description: string;
filePath: string;
baseDir: string;
source: string;
sourceInfo?: SourceInfo;
sourceInfo: SourceInfo;
disableModelInvocation: boolean;
}
@@ -138,6 +137,30 @@ export interface LoadSkillsFromDirOptions {
source: string;
}
function createSkillSourceInfo(filePath: string, baseDir: string, source: string): SourceInfo {
switch (source) {
case "user":
return createSyntheticSourceInfo(filePath, {
source: "local",
scope: "user",
baseDir,
});
case "project":
return createSyntheticSourceInfo(filePath, {
source: "local",
scope: "project",
baseDir,
});
case "path":
return createSyntheticSourceInfo(filePath, {
source: "local",
baseDir,
});
default:
return createSyntheticSourceInfo(filePath, { source, baseDir });
}
}
/**
* Load skills from a directory.
*
@@ -293,7 +316,7 @@ function loadSkillFromFile(
description: frontmatter.description,
filePath,
baseDir: skillDir,
source,
sourceInfo: createSkillSourceInfo(filePath, skillDir, source),
disableModelInvocation: frontmatter["disable-model-invocation"] === true,
},
diagnostics,