fix(coding-agent): unify source provenance, closes #1734
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user