fix(coding-agent): unify source provenance, closes #1734
This commit is contained in:
@@ -26,6 +26,7 @@ import * as _bundledPiCodingAgent from "../../index.js";
|
||||
import { createEventBus, type EventBus } from "../event-bus.js";
|
||||
import type { ExecOptions } from "../exec.js";
|
||||
import { execCommand } from "../exec.js";
|
||||
import { createSyntheticSourceInfo } from "../source-info.js";
|
||||
import type {
|
||||
Extension,
|
||||
ExtensionAPI,
|
||||
@@ -174,15 +175,14 @@ function createExtensionAPI(
|
||||
registerTool(tool: ToolDefinition): void {
|
||||
extension.tools.set(tool.name, {
|
||||
definition: tool,
|
||||
extensionPath: extension.path,
|
||||
sourceInfo: extension.sourceInfo,
|
||||
});
|
||||
runtime.refreshTools();
|
||||
},
|
||||
|
||||
registerCommand(name: string, options: Omit<RegisteredCommand, "name" | "extensionPath">): void {
|
||||
registerCommand(name: string, options: Omit<RegisteredCommand, "name" | "sourceInfo">): void {
|
||||
extension.commands.set(name, {
|
||||
name,
|
||||
extensionPath: extension.path,
|
||||
sourceInfo: extension.sourceInfo,
|
||||
...options,
|
||||
});
|
||||
@@ -307,9 +307,16 @@ async function loadExtensionModule(extensionPath: string) {
|
||||
* Create an Extension object with empty collections.
|
||||
*/
|
||||
function createExtension(extensionPath: string, resolvedPath: string): Extension {
|
||||
const source =
|
||||
extensionPath.startsWith("<") && extensionPath.endsWith(">")
|
||||
? extensionPath.slice(1, -1).split(":")[0] || "temporary"
|
||||
: "local";
|
||||
const baseDir = extensionPath.startsWith("<") ? undefined : path.dirname(resolvedPath);
|
||||
|
||||
return {
|
||||
path: extensionPath,
|
||||
resolvedPath,
|
||||
sourceInfo: createSyntheticSourceInfo(extensionPath, { source, baseDir }),
|
||||
handlers: new Map(),
|
||||
tools: new Map(),
|
||||
messageRenderers: new Map(),
|
||||
|
||||
Reference in New Issue
Block a user