@agntn/harnesses 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -13
- package/dist/_chunks/agents.mjs +2 -30
- package/dist/_chunks/agents.mjs.map +1 -1
- package/dist/_chunks/libs/typebox.mjs +11 -8
- package/dist/_chunks/libs/typebox.mjs.map +1 -1
- package/dist/_chunks/mcp-servers.mjs +5 -34
- package/dist/_chunks/mcp-servers.mjs.map +1 -1
- package/dist/_chunks/mcp.mjs +13 -163
- package/dist/_chunks/mcp.mjs.map +1 -1
- package/dist/_chunks/output.mjs +28 -0
- package/dist/_chunks/output.mjs.map +1 -0
- package/dist/_chunks/{agents-sync.d.mts → prompt-sync.d.mts} +51 -3
- package/dist/_chunks/prompt-sync.d.mts.map +1 -0
- package/dist/_chunks/{agents-sync.mjs → prompt-sync.mjs} +517 -21
- package/dist/_chunks/prompt-sync.mjs.map +1 -0
- package/dist/_chunks/prompts.mjs +28 -0
- package/dist/_chunks/prompts.mjs.map +1 -0
- package/dist/_chunks/tool-operations.mjs +43 -10
- package/dist/_chunks/tool-operations.mjs.map +1 -1
- package/dist/_chunks/tool-schemas.d.mts +5 -0
- package/dist/_chunks/tool-schemas.d.mts.map +1 -1
- package/dist/_chunks/tool-schemas.mjs +4 -0
- package/dist/_chunks/tool-schemas.mjs.map +1 -1
- package/dist/_chunks/types.mjs +1 -1
- package/dist/_chunks/types.mjs.map +1 -1
- package/dist/cli.mjs +6 -2
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +16 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/mcp.d.mts.map +1 -1
- package/dist/mcp.mjs +176 -1
- package/dist/mcp.mjs.map +1 -0
- package/dist/tool-operations.d.mts +12 -2
- package/dist/tool-operations.d.mts.map +1 -1
- package/dist/tool-operations.mjs +2 -2
- package/dist/tool-schemas.d.mts +2 -2
- package/package.json +16 -14
- package/packages/omp/extensions/harnesses.ts +19 -1
- package/packages/pi/extensions/harnesses.ts +23 -1
- package/packages/shared/tui.ts +22 -1
- package/dist/_chunks/agents-sync.d.mts.map +0 -1
- package/dist/_chunks/agents-sync.mjs.map +0 -1
- package/dist/_chunks/mcp2.mjs +0 -17
- package/dist/_chunks/mcp2.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { version } from "./_chunks/types.mjs";
|
|
2
|
-
import { Harness, McpEnvError, addMcpServer, detectHarness, detectHarnessFromEnv, detectProjectHarnesses, getAllHarnesses, getHarness, isHarnessId, listHarnesses, listMcpServers, masterMcpPath, parseJsonc, readAgentsConfig, readMasterMcpServers, registerHarness, removeMcpServer, resolvePathTemplate, syncAgentsFiles, syncMcpServers } from "./_chunks/
|
|
2
|
+
import { Harness, McpEnvError, addMcpServer, agntnConfigDir, agntnDataDir, detectHarness, detectHarnessFromEnv, detectProjectHarnesses, getAllHarnesses, getHarness, isHarnessId, listHarnesses, listMcpServers, masterMcpPath, parseJsonc, readAgentsConfig, readMasterMcpServers, registerHarness, removeMcpServer, resolvePathTemplate, syncAgentsFiles, syncMcpServers, syncPromptTemplates } from "./_chunks/prompt-sync.mjs";
|
|
3
3
|
const harnessIds = Object.freeze(listHarnesses());
|
|
4
|
-
export { Harness, McpEnvError, addMcpServer, detectHarness, detectHarnessFromEnv, detectProjectHarnesses, getAllHarnesses, getHarness, harnessIds, isHarnessId, listHarnesses, listMcpServers, masterMcpPath, parseJsonc, readAgentsConfig, readMasterMcpServers, registerHarness, removeMcpServer, resolvePathTemplate, syncAgentsFiles, syncMcpServers, version };
|
|
4
|
+
export { Harness, McpEnvError, addMcpServer, agntnConfigDir, agntnDataDir, detectHarness, detectHarnessFromEnv, detectProjectHarnesses, getAllHarnesses, getHarness, harnessIds, isHarnessId, listHarnesses, listMcpServers, masterMcpPath, parseJsonc, readAgentsConfig, readMasterMcpServers, registerHarness, removeMcpServer, resolvePathTemplate, syncAgentsFiles, syncMcpServers, syncPromptTemplates, version };
|
|
5
5
|
|
|
6
6
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { version } from \"./types.ts\";\nexport type {\n HarnessId,\n EvidenceLevel,\n Platform,\n PathCandidate,\n StorageDescriptor,\n HarnessCapabilities,\n HarnessDetection,\n HarnessInvocation,\n HarnessInvocationModes,\n HarnessModelListing,\n AvailableModel,\n ListModelsOptions,\n ListModelsResult,\n InvokeOptions,\n InvokeResult,\n McpServerConfig,\n McpConfigFile,\n ResolveOptions,\n ResolvedPaths,\n} from \"./types.ts\";\n\nexport { Harness } from \"./harness.ts\";\nexport type { HarnessConstructor } from \"./harness.ts\";\nexport {\n registerHarness,\n getHarness,\n isHarnessId,\n listHarnesses,\n getAllHarnesses,\n detectHarness,\n detectHarnessFromEnv,\n detectProjectHarnesses,\n} from \"./registry.ts\";\nexport { resolvePathTemplate } from \"./resolve.ts\";\nexport {\n listMcpServers,\n addMcpServer,\n removeMcpServer,\n syncMcpServers,\n readMasterMcpServers,\n masterMcpPath,\n parseJsonc,\n McpEnvError,\n} from \"./mcp-servers.ts\";\nexport type { McpConfigListing, SyncReport, SyncTargetResult } from \"./mcp-servers.ts\";\nexport { syncAgentsFiles, readAgentsConfig } from \"./agents-sync.ts\";\nexport type {\n AgentsConfig,\n AgentsSyncAction,\n AgentsCompanionTargetResult,\n AgentsSyncReport,\n AgentsTargetResult,\n} from \"./agents-sync.ts\";\n\nexport type {\n ClaudeContentBlock,\n ClaudeTextBlock,\n ClaudeThinkingBlock,\n ClaudeToolUseBlock,\n ClaudeToolResultBlock,\n ClaudeUsage,\n ClaudeBaseEntry,\n ClaudeUserEntry,\n ClaudeAssistantEntry,\n ClaudeSummaryEntry,\n ClaudeSessionEntry,\n ClaudeHistoryEntry,\n GeminiTokensSummary,\n GeminiToolCallRecord,\n GeminiThought,\n GeminiMessageRecord,\n GeminiConversationRecord,\n CodexHistoryEntry,\n CodexThread,\n CodexLogEntry,\n OpenCodeSession,\n OpenCodeMessage,\n OpenCodeTextPart,\n OpenCodeReasoningPart,\n OpenCodeToolPart,\n OpenCodeFilePart,\n OpenCodeSubtaskPart,\n OpenCodeStepStartPart,\n OpenCodeStepFinishPart,\n OpenCodeSnapshotPart,\n OpenCodePatchPart,\n OpenCodeAgentPart,\n OpenCodeRetryPart,\n OpenCodeCompactionPart,\n OpenCodePart,\n OpenCodeTodo,\n OpenCodeProject,\n} from \"./schemas/index.ts\";\n\nimport type { HarnessId } from \"./types.ts\";\nimport { listHarnesses } from \"./registry.ts\";\n\nexport const harnessIds: readonly HarnessId[] = Object.freeze(listHarnesses());\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["export { version } from \"./types.ts\";\nexport type {\n HarnessId,\n EvidenceLevel,\n Platform,\n PathCandidate,\n PromptTemplateSyncTarget,\n StorageDescriptor,\n HarnessCapabilities,\n HarnessDetection,\n HarnessInvocation,\n HarnessInvocationModes,\n HarnessModelListing,\n AvailableModel,\n ListModelsOptions,\n ListModelsResult,\n InvokeOptions,\n InvokeResult,\n McpServerConfig,\n McpConfigFile,\n ResolveOptions,\n ResolvedPaths,\n} from \"./types.ts\";\n\nexport { Harness } from \"./harness.ts\";\nexport type { HarnessConstructor } from \"./harness.ts\";\nexport {\n registerHarness,\n getHarness,\n isHarnessId,\n listHarnesses,\n getAllHarnesses,\n detectHarness,\n detectHarnessFromEnv,\n detectProjectHarnesses,\n} from \"./registry.ts\";\nexport { agntnDataDir, agntnConfigDir, resolvePathTemplate } from \"./resolve.ts\";\nexport {\n listMcpServers,\n addMcpServer,\n removeMcpServer,\n syncMcpServers,\n readMasterMcpServers,\n masterMcpPath,\n parseJsonc,\n McpEnvError,\n} from \"./mcp-servers.ts\";\nexport type { McpConfigListing, SyncReport, SyncTargetResult } from \"./mcp-servers.ts\";\nexport { syncAgentsFiles, readAgentsConfig } from \"./agents-sync.ts\";\nexport type {\n AgentsConfig,\n AgentsSyncAction,\n AgentsCompanionTargetResult,\n AgentsSyncReport,\n AgentsTargetResult,\n} from \"./agents-sync.ts\";\nexport { syncPromptTemplates } from \"./prompt-sync.ts\";\nexport type {\n PromptSyncAction,\n PromptSyncReport,\n PromptSyncTargetResult,\n PromptTemplateTargetResult,\n} from \"./prompt-sync.ts\";\n\nexport type {\n ClaudeContentBlock,\n ClaudeTextBlock,\n ClaudeThinkingBlock,\n ClaudeToolUseBlock,\n ClaudeToolResultBlock,\n ClaudeUsage,\n ClaudeBaseEntry,\n ClaudeUserEntry,\n ClaudeAssistantEntry,\n ClaudeSummaryEntry,\n ClaudeSessionEntry,\n ClaudeHistoryEntry,\n GeminiTokensSummary,\n GeminiToolCallRecord,\n GeminiThought,\n GeminiMessageRecord,\n GeminiConversationRecord,\n CodexHistoryEntry,\n CodexThread,\n CodexLogEntry,\n OpenCodeSession,\n OpenCodeMessage,\n OpenCodeTextPart,\n OpenCodeReasoningPart,\n OpenCodeToolPart,\n OpenCodeFilePart,\n OpenCodeSubtaskPart,\n OpenCodeStepStartPart,\n OpenCodeStepFinishPart,\n OpenCodeSnapshotPart,\n OpenCodePatchPart,\n OpenCodeAgentPart,\n OpenCodeRetryPart,\n OpenCodeCompactionPart,\n OpenCodePart,\n OpenCodeTodo,\n OpenCodeProject,\n} from \"./schemas/index.ts\";\n\nimport type { HarnessId } from \"./types.ts\";\nimport { listHarnesses } from \"./registry.ts\";\n\nexport const harnessIds: readonly HarnessId[] = Object.freeze(listHarnesses());\n"],"mappings":";;AA2GA,MAAa,aAAmC,OAAO,OAAO,cAAc,CAAC"}
|
package/dist/mcp.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.mts","names":[],"sources":["../src/mcp.ts"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"mcp.d.mts","names":[],"sources":["../src/mcp.ts"],"mappings":";;;;;;;;;;;;wBAwOgB,mBAAmB"}
|
package/dist/mcp.mjs
CHANGED
|
@@ -1,2 +1,177 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Check, Errors, typebox_exports } from "./_chunks/libs/typebox.mjs";
|
|
2
|
+
import { version } from "./_chunks/types.mjs";
|
|
3
|
+
import { harnessToolSchemas } from "./_chunks/tool-schemas.mjs";
|
|
4
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
6
|
+
const READ_ONLY = {
|
|
7
|
+
readOnlyHint: true,
|
|
8
|
+
destructiveHint: false,
|
|
9
|
+
idempotentHint: true,
|
|
10
|
+
openWorldHint: false
|
|
11
|
+
};
|
|
12
|
+
const EXEC_READ = {
|
|
13
|
+
readOnlyHint: false,
|
|
14
|
+
destructiveHint: false,
|
|
15
|
+
idempotentHint: false,
|
|
16
|
+
openWorldHint: true
|
|
17
|
+
};
|
|
18
|
+
const CONFIG_WRITE = {
|
|
19
|
+
readOnlyHint: false,
|
|
20
|
+
destructiveHint: true,
|
|
21
|
+
idempotentHint: true,
|
|
22
|
+
openWorldHint: false
|
|
23
|
+
};
|
|
24
|
+
const schemas = harnessToolSchemas(typebox_exports);
|
|
25
|
+
let operationsPromise;
|
|
26
|
+
const tools = [
|
|
27
|
+
{
|
|
28
|
+
name: "harnesses_detect",
|
|
29
|
+
title: "Harnesses Detect",
|
|
30
|
+
description: "List every known AI coding harness with its install state and version.",
|
|
31
|
+
inputSchema: schemas.detect,
|
|
32
|
+
annotations: READ_ONLY,
|
|
33
|
+
execute: ({ detectHarnesses }) => detectHarnesses()
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: "harnesses_info",
|
|
37
|
+
title: "Harnesses Info",
|
|
38
|
+
description: "Full metadata for one or more AI coding harnesses, including supported invocation and model operations, configuration, sessions, instructions, skills, commands, prompt templates, hooks, and resolved paths.",
|
|
39
|
+
inputSchema: schemas.info,
|
|
40
|
+
annotations: READ_ONLY,
|
|
41
|
+
execute: ({ harnessInfo }, args) => harnessInfo(args.id)
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "harnesses_models",
|
|
45
|
+
title: "Harnesses Models",
|
|
46
|
+
description: "List the models currently available to one AI coding harness through its native CLI, normalized across providers. An optional search filter is passed to harnesses that support it. The command may load project configuration and extensions.",
|
|
47
|
+
inputSchema: schemas.models,
|
|
48
|
+
annotations: EXEC_READ,
|
|
49
|
+
execute: ({ listHarnessModels }, args, signal) => listHarnessModels(args.id, {
|
|
50
|
+
search: args.search,
|
|
51
|
+
cwd: args.cwd,
|
|
52
|
+
timeoutSeconds: args.timeoutSeconds,
|
|
53
|
+
signal
|
|
54
|
+
})
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "harnesses_run",
|
|
58
|
+
title: "Harnesses Run",
|
|
59
|
+
description: "Run one prompt through an AI coding harness's normalized non-interactive invocation and return its output. Pass tools=true whenever the task needs harness tools, including Grok native X search. Add readOnly=true to require native read-only tool enforcement. Pass tools=false only for an advisor without tools. Unsupported modes never widen access.",
|
|
60
|
+
inputSchema: schemas.run,
|
|
61
|
+
annotations: {
|
|
62
|
+
readOnlyHint: false,
|
|
63
|
+
destructiveHint: true,
|
|
64
|
+
idempotentHint: false,
|
|
65
|
+
openWorldHint: true
|
|
66
|
+
},
|
|
67
|
+
execute: ({ runHarness }, args, signal) => runHarness(args.id, args.prompt, {
|
|
68
|
+
cwd: args.cwd,
|
|
69
|
+
model: args.model,
|
|
70
|
+
timeoutSeconds: args.timeoutSeconds,
|
|
71
|
+
signal,
|
|
72
|
+
structured: args.structured,
|
|
73
|
+
tools: args.tools,
|
|
74
|
+
readOnly: args.readOnly
|
|
75
|
+
})
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "harnesses_mcp_list",
|
|
79
|
+
title: "Harnesses MCP List",
|
|
80
|
+
description: "List the MCP servers configured in each harness's config files, normalized across dialects. Omit id to scan every harness.",
|
|
81
|
+
inputSchema: schemas.mcpList,
|
|
82
|
+
annotations: READ_ONLY,
|
|
83
|
+
execute: ({ mcpList }, args) => mcpList(args.id)
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "harnesses_mcp_add",
|
|
87
|
+
title: "Harnesses MCP Add",
|
|
88
|
+
description: "Add or replace one MCP server in a harness config. JSON configs are rewritten; TOML configs get a surgical, comment-preserving edit.",
|
|
89
|
+
inputSchema: schemas.mcpAdd,
|
|
90
|
+
annotations: CONFIG_WRITE,
|
|
91
|
+
execute: ({ mcpAdd }, args) => mcpAdd(args.id, args, args.scope ?? "user")
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "harnesses_mcp_sync",
|
|
95
|
+
title: "Harnesses MCP Sync",
|
|
96
|
+
description: "Reset every harness's user-scope MCP config to exactly the master list from ~/.config/agntn/mcp.jsonc: servers are added, replaced, and extras removed. Excluded harnesses keep their own servers, but master-listed names are withdrawn from them.",
|
|
97
|
+
inputSchema: schemas.mcpSync,
|
|
98
|
+
annotations: CONFIG_WRITE,
|
|
99
|
+
execute: ({ mcpSync }, args) => mcpSync(args.id)
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "harnesses_agents_sync",
|
|
103
|
+
title: "Harnesses Agents Sync",
|
|
104
|
+
description: "Link every harness's global instructions file and declared companions to the master bundle, so edits made through any harness land in one place. Diverged copies are backed up and relinked. Pass check to only report.",
|
|
105
|
+
inputSchema: schemas.agentsSync,
|
|
106
|
+
annotations: CONFIG_WRITE,
|
|
107
|
+
execute: ({ agentsSync }, args) => agentsSync(args.id, args.check === true)
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
name: "harnesses_prompts_sync",
|
|
111
|
+
title: "Harnesses Prompts Sync",
|
|
112
|
+
description: "Sync canonical Markdown prompt templates from the agntn XDG data directory into every supported harness. Markdown targets use links; Gemini receives generated TOML. Diverged files are backed up. Pass check to only report.",
|
|
113
|
+
inputSchema: schemas.promptsSync,
|
|
114
|
+
annotations: CONFIG_WRITE,
|
|
115
|
+
execute: ({ promptsSync }, args) => promptsSync(args.id, args.check === true)
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: "harnesses_mcp_remove",
|
|
119
|
+
title: "Harnesses MCP Remove",
|
|
120
|
+
description: "Remove one MCP server from a harness config. JSON configs are rewritten; TOML configs get a surgical, comment-preserving edit.",
|
|
121
|
+
inputSchema: schemas.mcpRemove,
|
|
122
|
+
annotations: CONFIG_WRITE,
|
|
123
|
+
execute: ({ mcpRemove }, args) => mcpRemove(args.id, args.name, args.scope ?? "user")
|
|
124
|
+
}
|
|
125
|
+
];
|
|
126
|
+
function validationError(schema, value) {
|
|
127
|
+
const first = Errors(schema, value)[0];
|
|
128
|
+
if (!first) return "Invalid arguments";
|
|
129
|
+
return `Invalid arguments at ${first.instancePath || "/"}: ${first.message}`;
|
|
130
|
+
}
|
|
131
|
+
function errorResult(text) {
|
|
132
|
+
return {
|
|
133
|
+
content: [{
|
|
134
|
+
type: "text",
|
|
135
|
+
text: text.replaceAll(/\p{Cc}/gu, " ")
|
|
136
|
+
}],
|
|
137
|
+
isError: true
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function toCallToolResult(result) {
|
|
141
|
+
return {
|
|
142
|
+
content: result.content,
|
|
143
|
+
...result.isError === void 0 ? {} : { isError: result.isError }
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function createMcpServer() {
|
|
147
|
+
const toolsByName = new Map(tools.map((tool) => [tool.name, tool]));
|
|
148
|
+
const server = new Server({
|
|
149
|
+
name: "harnesses",
|
|
150
|
+
version
|
|
151
|
+
}, { capabilities: { tools: {} } });
|
|
152
|
+
server.setRequestHandler(ListToolsRequestSchema, () => ({ tools: tools.map((tool) => ({
|
|
153
|
+
name: tool.name,
|
|
154
|
+
title: tool.title,
|
|
155
|
+
description: tool.description,
|
|
156
|
+
inputSchema: tool.inputSchema,
|
|
157
|
+
annotations: tool.annotations
|
|
158
|
+
})) }));
|
|
159
|
+
server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
160
|
+
const tool = toolsByName.get(request.params.name);
|
|
161
|
+
if (!tool) return errorResult(`Unknown harnesses tool: ${JSON.stringify(request.params.name)}`);
|
|
162
|
+
const args = request.params.arguments ?? {};
|
|
163
|
+
if (!Check(tool.inputSchema, args)) return errorResult(validationError(tool.inputSchema, args));
|
|
164
|
+
try {
|
|
165
|
+
operationsPromise ??= import("./tool-operations.mjs");
|
|
166
|
+
const operations = await operationsPromise;
|
|
167
|
+
extra.signal.throwIfAborted();
|
|
168
|
+
return toCallToolResult(await tool.execute(operations, args, extra.signal));
|
|
169
|
+
} catch (error) {
|
|
170
|
+
return errorResult(`${tool.name} failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
return server;
|
|
174
|
+
}
|
|
2
175
|
export { createMcpServer };
|
|
176
|
+
|
|
177
|
+
//# sourceMappingURL=mcp.mjs.map
|
package/dist/mcp.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.mjs","names":["Type","Value.Errors","Value.Check"],"sources":["../src/mcp.ts"],"sourcesContent":["import { Server } from \"@modelcontextprotocol/sdk/server/index.js\";\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n type CallToolResult,\n type Tool,\n} from \"@modelcontextprotocol/sdk/types.js\";\nimport { Type, type TSchema } from \"typebox\";\nimport { Value } from \"typebox/value\";\nimport type { McpServerParams, ToolResult } from \"./tool-operations.ts\";\nimport { harnessToolSchemas } from \"./tool-schemas.ts\";\nimport { version } from \"./types.ts\";\n\ninterface ToolDefinition {\n name: string;\n title: string;\n description: string;\n inputSchema: TSchema;\n annotations: Tool[\"annotations\"];\n execute(\n operations: Readonly<typeof import(\"./tool-operations.ts\")>,\n args: Readonly<Record<string, unknown>>,\n signal: AbortSignal,\n ): ToolResult<unknown> | Promise<ToolResult<unknown>>;\n}\n\nconst READ_ONLY: Tool[\"annotations\"] = {\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: false,\n};\n\nconst EXEC_READ: Tool[\"annotations\"] = {\n readOnlyHint: false,\n destructiveHint: false,\n idempotentHint: false,\n openWorldHint: true,\n};\n\nconst CONFIG_WRITE: Tool[\"annotations\"] = {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: true,\n openWorldHint: false,\n};\n\nconst schemas = harnessToolSchemas<TSchema, TSchema>(Type);\nlet operationsPromise: Promise<typeof import(\"./tool-operations.ts\")> | undefined;\n\nconst tools: ToolDefinition[] = [\n {\n name: \"harnesses_detect\",\n title: \"Harnesses Detect\",\n description: \"List every known AI coding harness with its install state and version.\",\n inputSchema: schemas.detect,\n annotations: READ_ONLY,\n execute: ({ detectHarnesses }) => detectHarnesses(),\n },\n {\n name: \"harnesses_info\",\n title: \"Harnesses Info\",\n description:\n \"Full metadata for one or more AI coding harnesses, including supported invocation and model operations, configuration, sessions, instructions, skills, commands, prompt templates, hooks, and resolved paths.\",\n inputSchema: schemas.info,\n annotations: READ_ONLY,\n execute: ({ harnessInfo }, args) => harnessInfo(args.id as string | string[]),\n },\n {\n name: \"harnesses_models\",\n title: \"Harnesses Models\",\n description:\n \"List the models currently available to one AI coding harness through its native CLI, normalized across providers. An optional search filter is passed to harnesses that support it. The command may load project configuration and extensions.\",\n inputSchema: schemas.models,\n annotations: EXEC_READ,\n execute: ({ listHarnessModels }, args, signal) =>\n listHarnessModels(args.id as string, {\n search: args.search as string | undefined,\n cwd: args.cwd as string | undefined,\n timeoutSeconds: args.timeoutSeconds as number | undefined,\n signal,\n }),\n },\n {\n name: \"harnesses_run\",\n title: \"Harnesses Run\",\n description:\n \"Run one prompt through an AI coding harness's normalized non-interactive invocation and return its output. Pass tools=true whenever the task needs harness tools, including Grok native X search. Add readOnly=true to require native read-only tool enforcement. Pass tools=false only for an advisor without tools. Unsupported modes never widen access.\",\n inputSchema: schemas.run,\n annotations: {\n readOnlyHint: false,\n destructiveHint: true,\n idempotentHint: false,\n openWorldHint: true,\n },\n execute: ({ runHarness }, args, signal) =>\n runHarness(args.id as string, args.prompt as string, {\n cwd: args.cwd as string | undefined,\n model: args.model as string | undefined,\n timeoutSeconds: args.timeoutSeconds as number | undefined,\n signal,\n structured: args.structured as boolean | undefined,\n tools: args.tools as boolean | undefined,\n readOnly: args.readOnly as boolean | undefined,\n }),\n },\n {\n name: \"harnesses_mcp_list\",\n title: \"Harnesses MCP List\",\n description:\n \"List the MCP servers configured in each harness's config files, normalized across dialects. Omit id to scan every harness.\",\n inputSchema: schemas.mcpList,\n annotations: READ_ONLY,\n execute: ({ mcpList }, args) => mcpList(args.id as string | undefined),\n },\n {\n name: \"harnesses_mcp_add\",\n title: \"Harnesses MCP Add\",\n description:\n \"Add or replace one MCP server in a harness config. JSON configs are rewritten; TOML configs get a surgical, comment-preserving edit.\",\n inputSchema: schemas.mcpAdd,\n annotations: CONFIG_WRITE,\n execute: ({ mcpAdd }, args) =>\n mcpAdd(\n args.id as string,\n args as unknown as McpServerParams,\n (args.scope as \"user\" | \"project\") ?? \"user\",\n ),\n },\n {\n name: \"harnesses_mcp_sync\",\n title: \"Harnesses MCP Sync\",\n description:\n \"Reset every harness's user-scope MCP config to exactly the master list from ~/.config/agntn/mcp.jsonc: servers are added, replaced, and extras removed. Excluded harnesses keep their own servers, but master-listed names are withdrawn from them.\",\n inputSchema: schemas.mcpSync,\n annotations: CONFIG_WRITE,\n execute: ({ mcpSync }, args) => mcpSync(args.id as string | undefined),\n },\n {\n name: \"harnesses_agents_sync\",\n title: \"Harnesses Agents Sync\",\n description:\n \"Link every harness's global instructions file and declared companions to the master bundle, so edits made through any harness land in one place. Diverged copies are backed up and relinked. Pass check to only report.\",\n inputSchema: schemas.agentsSync,\n annotations: CONFIG_WRITE,\n execute: ({ agentsSync }, args) =>\n agentsSync(args.id as string | undefined, args.check === true),\n },\n {\n name: \"harnesses_prompts_sync\",\n title: \"Harnesses Prompts Sync\",\n description:\n \"Sync canonical Markdown prompt templates from the agntn XDG data directory into every supported harness. Markdown targets use links; Gemini receives generated TOML. Diverged files are backed up. Pass check to only report.\",\n inputSchema: schemas.promptsSync,\n annotations: CONFIG_WRITE,\n execute: ({ promptsSync }, args) =>\n promptsSync(args.id as string | undefined, args.check === true),\n },\n {\n name: \"harnesses_mcp_remove\",\n title: \"Harnesses MCP Remove\",\n description:\n \"Remove one MCP server from a harness config. JSON configs are rewritten; TOML configs get a surgical, comment-preserving edit.\",\n inputSchema: schemas.mcpRemove,\n annotations: CONFIG_WRITE,\n execute: ({ mcpRemove }, args) =>\n mcpRemove(\n args.id as string,\n args.name as string,\n (args.scope as \"user\" | \"project\") ?? \"user\",\n ),\n },\n];\n\n/**\n * Formats the first TypeBox validation failure for an MCP client.\n *\n * @param schema - Schema that rejected the value.\n * @param value - Rejected input value.\n * @returns {string} A client-facing validation message.\n */\nfunction validationError(schema: TSchema, value: unknown): string {\n const first = Value.Errors(schema, value)[0];\n if (!first) return \"Invalid arguments\";\n return `Invalid arguments at ${first.instancePath || \"/\"}: ${first.message}`;\n}\n\n/**\n * Wraps error text for the MCP client, replacing control bytes with spaces.\n *\n * Every error branch goes through here because parts of these messages echo\n * client-controlled values (a tool name, an argument) or downstream error\n * messages: one raw newline or escape byte would forge extra lines that read\n * as the server's own answer.\n *\n * @param text - Untrusted error text.\n * @returns {CallToolResult} A sanitized MCP error result.\n */\nfunction errorResult(text: string): CallToolResult {\n return {\n content: [{ type: \"text\", text: text.replaceAll(/\\p{Cc}/gu, \" \") }],\n isError: true,\n };\n}\n\n/**\n * Converts a shared tool result to the MCP text-result contract.\n *\n * `details` is dropped and `structuredContent` is never set: clients that see\n * structured output prefer it over `content` and would hide the readable answer.\n *\n * @param result - Shared tool result to adapt.\n * @returns {CallToolResult} The MCP text-result envelope.\n */\nfunction toCallToolResult(result: ToolResult<unknown>): CallToolResult {\n return {\n content: result.content,\n ...(result.isError === undefined ? {} : { isError: result.isError }),\n };\n}\n\n/**\n * Creates an unconnected MCP server exposing the harness registry tools.\n *\n * Built on the low-level `Server` even though the SDK marks it `@deprecated`,\n * because `McpServer.registerTool` accepts Standard Schema (Zod) only. TypeBox 1.x\n * does not implement Standard Schema, and this package's tool schemas are TypeBox,\n * shared with the Pi and OMP extensions. The high-level API would force a second\n * definition of every parameter.\n *\n * @returns {Server} An unconnected MCP server.\n */\nexport function createMcpServer(): Server {\n const toolsByName = new Map(tools.map((tool) => [tool.name, tool]));\n const server = new Server({ name: \"harnesses\", version }, { capabilities: { tools: {} } });\n\n server.setRequestHandler(ListToolsRequestSchema, () => ({\n tools: tools.map((tool): Tool => ({\n name: tool.name,\n title: tool.title,\n description: tool.description,\n inputSchema: tool.inputSchema as Tool[\"inputSchema\"],\n annotations: tool.annotations,\n })),\n }));\n\n server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {\n const tool = toolsByName.get(request.params.name);\n if (!tool) {\n return errorResult(`Unknown harnesses tool: ${JSON.stringify(request.params.name)}`);\n }\n\n const args = request.params.arguments ?? {};\n if (!Value.Check(tool.inputSchema, args)) {\n return errorResult(validationError(tool.inputSchema, args));\n }\n\n try {\n operationsPromise ??= import(\"./tool-operations.ts\");\n const operations = await operationsPromise;\n extra.signal.throwIfAborted();\n return toCallToolResult(await tool.execute(operations, args, extra.signal));\n } catch (error) {\n return errorResult(\n `${tool.name} failed: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n });\n\n return server;\n}\n"],"mappings":";;;;;AA0BA,MAAM,YAAiC;CACrC,cAAc;CACd,iBAAiB;CACjB,gBAAgB;CAChB,eAAe;AACjB;AAEA,MAAM,YAAiC;CACrC,cAAc;CACd,iBAAiB;CACjB,gBAAgB;CAChB,eAAe;AACjB;AAEA,MAAM,eAAoC;CACxC,cAAc;CACd,iBAAi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CACvE;CACA;EACE,MAAM;EACN,OAAO;EACP,aACE;EACF,aAAa,QAAQ;EACrB,aAAa;EACb,UAAU,EAAE,cAAc,SACxB,WAAW,KAAK,IAA0B,KAAK,UAAU,IAAI;CACjE;CACA;EACE,MAAM;EACN,OAAO;EACP,aACE;EACF,aAAa,QAAQ;EACrB,aAAa;EACb,UAAU,EAAE,eAAe,SACzB,YAAY,KAAK,IAA0B,KAAK,UAAU,IAAI;CAClE;CACA;EACE,MAAM;EACN,OAAO;EACP,aACE;EACF,aAAa,QAAQ;EACrB,aAAa;EACb,UAAU,EAAE,aAAa,SACvB,UACE,KAAK,IACL,KAAK,MACJ,KAAK,SAAgC,MACxC;CACJ;AACF;;;;;;AASA,SAAS,YAAA,MAAgB;CACvB,OAAM;EACN,SAAK,CAAA;GACL,MAAO;GACT,MAAA,KAAA,WAAA,YAAA,GAAA;;;;;;;;;;;AAcE,SAAO,kBAAA;CACL,MAAA,cAAU,IAAA,IAAA,MAAA,KAAA,SAAA,CAAA,KAAA,MAAA,IAAA,CAAA,CAAA;CAAE,MAAA,SAAM,IAAA,OAAA;EAAQ,MAAA;EAAuC;CACjE,GAAA,EAAA,cAAS,EAAA,OAAA,CAAA,EAAA,EAAA,CAAA;CACX,OAAA,kBAAA,+BAAA,EAAA,OAAA,MAAA,KAAA,UAAA;EACF,MAAA,KAAA;;;;;;;;;;EAWA,IAAA,CAAA,MAAS,KAAA,aAAiB,IAA6C,GAAA,OAAA,YAAA,gBAAA,KAAA,aAAA,IAAA,CAAA;EACrE,IAAA;GACE,sBAAgB,OAAA;GAChB,MAAI,aAAO,MAAY;GACzB,MAAA,OAAA,eAAA;GACF,OAAA,iBAAA,MAAA,KAAA,QAAA,YAAA,MAAA,MAAA,MAAA,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentsSyncReport, AvailableModel, HarnessCapabilities, HarnessDetection, HarnessId, HarnessInvocationModes, McpConfigListing, McpServerConfig, PathCandidate, ResolvedPaths, StorageDescriptor, SyncReport } from "./_chunks/
|
|
1
|
+
import { AgentsSyncReport, AvailableModel, HarnessCapabilities, HarnessDetection, HarnessId, HarnessInvocationModes, McpConfigListing, McpServerConfig, PathCandidate, PromptSyncReport, PromptTemplateSyncTarget, ResolvedPaths, StorageDescriptor, SyncReport } from "./_chunks/prompt-sync.mjs";
|
|
2
2
|
import { HARNESS_INFO_MAX_ITEMS } from "./_chunks/tool-schemas.mjs";
|
|
3
3
|
/** Text for the model plus details for the harness, shared by every tool surface. */
|
|
4
4
|
export interface ToolResult<Details> {
|
|
@@ -35,6 +35,8 @@ export interface HarnessMetadata {
|
|
|
35
35
|
instructions: PathCandidate[];
|
|
36
36
|
skills: PathCandidate[];
|
|
37
37
|
commands: PathCandidate[];
|
|
38
|
+
promptTemplates: PathCandidate[];
|
|
39
|
+
promptTemplateSyncTarget: PromptTemplateSyncTarget | null;
|
|
38
40
|
hooks: PathCandidate[];
|
|
39
41
|
persistence: StorageDescriptor[];
|
|
40
42
|
detection: HarnessDetection;
|
|
@@ -228,5 +230,13 @@ export declare function mcpSync(id?: string): ToolResult<SyncReport | RunFailure
|
|
|
228
230
|
* @returns {ToolResult<AgentsSyncReport | RunFailure>} The sync report or failure.
|
|
229
231
|
*/
|
|
230
232
|
export declare function agentsSync(id?: string, check?: boolean): ToolResult<AgentsSyncReport | RunFailure>;
|
|
231
|
-
|
|
233
|
+
/**
|
|
234
|
+
* Synchronizes canonical Markdown prompt templates into harness destinations.
|
|
235
|
+
*
|
|
236
|
+
* @param id - Optional harness id; omission targets every harness.
|
|
237
|
+
* @param check - Report intended changes without writing them.
|
|
238
|
+
* @returns {ToolResult<PromptSyncReport | RunFailure>} The sync report or failure.
|
|
239
|
+
*/
|
|
240
|
+
export declare function promptsSync(id?: string, check?: boolean): ToolResult<PromptSyncReport | RunFailure>;
|
|
241
|
+
export { type AgentsSyncReport, HARNESS_INFO_MAX_ITEMS, type HarnessInvocationModes, type PromptSyncReport, type SyncReport };
|
|
232
242
|
//# sourceMappingURL=tool-operations.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-operations.d.mts","names":[],"sources":["../src/tool-operations.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"tool-operations.d.mts","names":[],"sources":["../src/tool-operations.ts"],"mappings":";;;iBA4CiB,WAAW;EAC1B,SAAS;IAAQ;IAAc;;EAC/B,SAAS;;EAET;;;iBAIe;EACf,IAAI;EACJ;EACA;EACA;;;iBAIe;EACf,WAAW;;;iBAII;EACf,IAAI;EACJ;EACA;EACA,cAAc;EACd,iBAAiB;EACjB;EACA;EACA,QAAQ;EACR,UAAU;EACV,cAAc;EACd,QAAQ;EACR,UAAU;EACV,iBAAiB;EACjB,0BAA0B;EAC1B,OAAO;EACP,aAAa;EACb,WAAW;EACX,UAAU;;;iBAIK;EACf;EACA,OAAO;;;iBAIQ;EACf;;;YAIU,oBAAoB,kBAAkB;;YAGtC,qBAAqB,oBAAoB,sBAAsB;;qBAM9D;;qBAGA;;;;;;wBA2KG,mBAAmB,WAAW;;wBA6F9B,YAAY,aAAa,WAAW;;wBAEpC,YACd,yBACC,WAAW,sBAAsB;wBACpB,YAAY,oCAAoC,WAAW;;iBA2B1D;EACf;EACA;;EAEA;;EAEA,SAAS;;;iBAIM;EACf,IAAI;EACJ;EACA;EACA;EACA,QAAQ;EACR;EACA;EACA;EACA;;;;;;;;;wBAUoB,kBACpB,YACA,UAAS,gBACR,QAAQ,WAAW,gBAAgB;;iBA4CrB;EACf;;EAEA;;EAEA;;EAEA,SAAS;;EAET;;EAEA;;EAEA;;;iBAIe;EACf,IAAI;EACJ;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;iBAIe;EACf;EACA,QAAQ;;EAER,kBAAkB;;EAElB;IAAU;IAAmB;;IAAsB;;;;;;;;;;;;;;;;;wBAyB/B,WACpB,YACA,gBACA,UAAS,aACR,QAAQ,WAAW,aAAa;;iBAkClB;EACf,WAAW;IAAQ,IAAI;IAAW,SAAS;;;;iBAY5B;EACf,IAAI;EACJ;EACA;;;iBAIe;EACf;EACA,YAAY;EACZ;EACA;EACA,MAAM;EACN;EACA,UAAU;;;;;;;;wBASI,kBAAkB,QAAQ,kBAAkB;;;;;;;wBAmB5C,QAAQ,cAAc,WAAW,aAAa;;;;;;;;;wBAgD9C,OACd,YACA,QAAQ,iBACR,6BACC,WAAW,cAAc;;;;;;;;;wBAeZ,UACd,YACA,cACA,6BACC,WAAW,cAAc;;;;;;;wBAaZ,QAAQ,cAAc,WAAW,aAAa;;;;;;;;wBA+B9C,WAAW,aAAa,kBAAgB,WAAW,mBAAmB;;;;;;;;wBAgCtE,YAAY,aAAa,kBAAgB,WAAW,mBAAmB"}
|
package/dist/tool-operations.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { HARNESS_INFO_MAX_ITEMS } from "./_chunks/tool-schemas.mjs";
|
|
2
|
-
import { RUN_DEFAULT_TIMEOUT_SECONDS, RUN_MAX_OUTPUT_CHARS, agentsSync, detectHarnesses, harnessInfo, listHarnessModels, mcpAdd, mcpList, mcpRemove, mcpSync, runHarness, toMcpServerConfig } from "./_chunks/tool-operations.mjs";
|
|
3
|
-
export { HARNESS_INFO_MAX_ITEMS, RUN_DEFAULT_TIMEOUT_SECONDS, RUN_MAX_OUTPUT_CHARS, agentsSync, detectHarnesses, harnessInfo, listHarnessModels, mcpAdd, mcpList, mcpRemove, mcpSync, runHarness, toMcpServerConfig };
|
|
2
|
+
import { RUN_DEFAULT_TIMEOUT_SECONDS, RUN_MAX_OUTPUT_CHARS, agentsSync, detectHarnesses, harnessInfo, listHarnessModels, mcpAdd, mcpList, mcpRemove, mcpSync, promptsSync, runHarness, toMcpServerConfig } from "./_chunks/tool-operations.mjs";
|
|
3
|
+
export { HARNESS_INFO_MAX_ITEMS, RUN_DEFAULT_TIMEOUT_SECONDS, RUN_MAX_OUTPUT_CHARS, agentsSync, detectHarnesses, harnessInfo, listHarnessModels, mcpAdd, mcpList, mcpRemove, mcpSync, promptsSync, runHarness, toMcpServerConfig };
|
package/dist/tool-schemas.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { AgentsSyncParams, HARNESS_INFO_MAX_ITEMS, InfoParams, McpAddParams, McpListParams, McpRemoveParams, McpSchemaBuilder, McpSyncParams, ModelsParams, RUN_TIMEOUT_DEFAULT_SECONDS, RunParams, harnessToolSchemas } from "./_chunks/tool-schemas.mjs";
|
|
2
|
-
export { AgentsSyncParams, HARNESS_INFO_MAX_ITEMS, InfoParams, McpAddParams, McpListParams, McpRemoveParams, McpSchemaBuilder, McpSyncParams, ModelsParams, RUN_TIMEOUT_DEFAULT_SECONDS, RunParams, harnessToolSchemas };
|
|
1
|
+
import { AgentsSyncParams, HARNESS_INFO_MAX_ITEMS, InfoParams, McpAddParams, McpListParams, McpRemoveParams, McpSchemaBuilder, McpSyncParams, ModelsParams, PromptsSyncParams, RUN_TIMEOUT_DEFAULT_SECONDS, RunParams, harnessToolSchemas } from "./_chunks/tool-schemas.mjs";
|
|
2
|
+
export { AgentsSyncParams, HARNESS_INFO_MAX_ITEMS, InfoParams, McpAddParams, McpListParams, McpRemoveParams, McpSchemaBuilder, McpSyncParams, ModelsParams, PromptsSyncParams, RUN_TIMEOUT_DEFAULT_SECONDS, RunParams, harnessToolSchemas };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agntn/harnesses",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Metadata registry for AI coding harnesses: binaries, configs, sessions, and capabilities.",
|
|
5
5
|
"homepage": "https://harnesses.agntn.dev",
|
|
6
6
|
"bugs": "https://github.com/agntn/harnesses/issues",
|
|
@@ -38,14 +38,15 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
41
|
-
"@toon-format/toon": "
|
|
42
|
-
"citty": "
|
|
43
|
-
"consola": "
|
|
44
|
-
"smol-toml": "
|
|
45
|
-
"typebox": "
|
|
41
|
+
"@toon-format/toon": "4.1.1",
|
|
42
|
+
"citty": "0.2.2",
|
|
43
|
+
"consola": "3.4.2",
|
|
44
|
+
"smol-toml": "1.8.0",
|
|
45
|
+
"typebox": "1.3.34",
|
|
46
|
+
"yaml": "2.9.1"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@agntn/ox": "
|
|
49
|
+
"@agntn/ox": "0.1.0",
|
|
49
50
|
"@earendil-works/pi-coding-agent": "0.85.1",
|
|
50
51
|
"@earendil-works/pi-tui": "0.85.1",
|
|
51
52
|
"@oh-my-pi/omptype": "18.2.5",
|
|
@@ -53,13 +54,13 @@
|
|
|
53
54
|
"@oh-my-pi/pi-coding-agent": "18.2.5",
|
|
54
55
|
"@types/node": "latest",
|
|
55
56
|
"@typescript/native-preview": "latest",
|
|
56
|
-
"changelogen": "
|
|
57
|
-
"obuild": "
|
|
58
|
-
"oxfmt": "
|
|
59
|
-
"oxlint": "
|
|
60
|
-
"oxlint-tsgolint": "
|
|
57
|
+
"changelogen": "0.6.2",
|
|
58
|
+
"obuild": "0.4.40",
|
|
59
|
+
"oxfmt": "0.68.0",
|
|
60
|
+
"oxlint": "1.83.0",
|
|
61
|
+
"oxlint-tsgolint": "7.0.2002",
|
|
61
62
|
"typescript": "6.0.3",
|
|
62
|
-
"vitest": "
|
|
63
|
+
"vitest": "5.0.1"
|
|
63
64
|
},
|
|
64
65
|
"peerDependencies": {
|
|
65
66
|
"@earendil-works/pi-coding-agent": ">=0.84.2 <1",
|
|
@@ -88,7 +89,8 @@
|
|
|
88
89
|
"pi": {
|
|
89
90
|
"extensions": [
|
|
90
91
|
"./packages/pi/extensions/harnesses.ts"
|
|
91
|
-
]
|
|
92
|
+
],
|
|
93
|
+
"image": "https://harnesses.agntn.dev/image.png"
|
|
92
94
|
},
|
|
93
95
|
"scripts": {
|
|
94
96
|
"build": "obuild",
|
|
@@ -82,7 +82,7 @@ export default function harnessesExtension(pi: ExtensionAPI): void {
|
|
|
82
82
|
name: "harnesses_info",
|
|
83
83
|
label: HARNESS_TOOL_LABELS.harnesses_info,
|
|
84
84
|
description:
|
|
85
|
-
"Full metadata for one or more AI coding harnesses, including supported invocation and model operations, configuration, sessions, instructions, skills, commands, hooks, and resolved paths",
|
|
85
|
+
"Full metadata for one or more AI coding harnesses, including supported invocation and model operations, configuration, sessions, instructions, skills, commands, prompt templates, hooks, and resolved paths",
|
|
86
86
|
parameters: schemas.info,
|
|
87
87
|
approval: HARNESS_TOOL_APPROVALS.harnesses_info,
|
|
88
88
|
async execute(
|
|
@@ -239,6 +239,24 @@ export default function harnessesExtension(pi: ExtensionAPI): void {
|
|
|
239
239
|
...statusRenderers("harnesses_agents_sync"),
|
|
240
240
|
});
|
|
241
241
|
|
|
242
|
+
pi.registerTool({
|
|
243
|
+
name: "harnesses_prompts_sync",
|
|
244
|
+
label: HARNESS_TOOL_LABELS.harnesses_prompts_sync,
|
|
245
|
+
description:
|
|
246
|
+
"Sync canonical Markdown prompt templates from the agntn XDG data directory into supported harnesses; Gemini receives generated TOML. Diverged files are backed up. Pass check to only report",
|
|
247
|
+
parameters: schemas.promptsSync,
|
|
248
|
+
approval: HARNESS_TOOL_APPROVALS.harnesses_prompts_sync,
|
|
249
|
+
async execute(
|
|
250
|
+
_toolCallId,
|
|
251
|
+
params: Readonly<HarnessSchemas.PromptsSyncParams>,
|
|
252
|
+
): Promise<AgentToolResult<HarnessTools.PromptSyncReport | HarnessTools.RunFailure>> {
|
|
253
|
+
const { promptsSync } = await loadToolOperations();
|
|
254
|
+
const { content, details, isError } = promptsSync(params.id, params.check === true);
|
|
255
|
+
return { content, details, isError };
|
|
256
|
+
},
|
|
257
|
+
...statusRenderers("harnesses_prompts_sync"),
|
|
258
|
+
});
|
|
259
|
+
|
|
242
260
|
pi.registerTool({
|
|
243
261
|
name: "harnesses_mcp_remove",
|
|
244
262
|
label: HARNESS_TOOL_LABELS.harnesses_mcp_remove,
|
|
@@ -97,7 +97,7 @@ export default function harnessesExtension(pi: ExtensionAPI): void {
|
|
|
97
97
|
name: "harnesses_info",
|
|
98
98
|
label: HARNESS_TOOL_LABELS.harnesses_info,
|
|
99
99
|
description:
|
|
100
|
-
"Full metadata for one or more AI coding harnesses, including supported invocation and model operations, configuration, sessions, instructions, skills, commands, hooks, and resolved paths",
|
|
100
|
+
"Full metadata for one or more AI coding harnesses, including supported invocation and model operations, configuration, sessions, instructions, skills, commands, prompt templates, hooks, and resolved paths",
|
|
101
101
|
promptSnippet: "Use harnesses_info to look up where coding harnesses store their data.",
|
|
102
102
|
promptGuidelines: [
|
|
103
103
|
"Pass one harness id from harnesses_detect, or batch several ids in one call.",
|
|
@@ -270,6 +270,28 @@ export default function harnessesExtension(pi: ExtensionAPI): void {
|
|
|
270
270
|
},
|
|
271
271
|
});
|
|
272
272
|
|
|
273
|
+
pi.registerTool({
|
|
274
|
+
name: "harnesses_prompts_sync",
|
|
275
|
+
label: HARNESS_TOOL_LABELS.harnesses_prompts_sync,
|
|
276
|
+
description:
|
|
277
|
+
"Sync canonical Markdown prompt templates from the agntn XDG data directory into supported harnesses; Gemini receives generated TOML. Diverged files are backed up. Pass check to only report",
|
|
278
|
+
parameters: schemas.promptsSync,
|
|
279
|
+
...statusRenderers("harnesses_prompts_sync"),
|
|
280
|
+
async execute(
|
|
281
|
+
_toolCallId,
|
|
282
|
+
params: Readonly<HarnessSchemas.PromptsSyncParams>,
|
|
283
|
+
): Promise<AgentToolResult<HarnessTools.PromptSyncReport | HarnessTools.RunFailure>> {
|
|
284
|
+
const { promptsSync } = await loadToolOperations();
|
|
285
|
+
const { content, details, isError } = promptsSync(params.id, params.check === true);
|
|
286
|
+
if (isError) {
|
|
287
|
+
throw new Error(
|
|
288
|
+
"error" in details ? details.error : (content[0]?.text ?? "Prompt sync failed"),
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
return { content, details };
|
|
292
|
+
},
|
|
293
|
+
});
|
|
294
|
+
|
|
273
295
|
pi.registerTool({
|
|
274
296
|
name: "harnesses_mcp_remove",
|
|
275
297
|
label: HARNESS_TOOL_LABELS.harnesses_mcp_remove,
|
package/packages/shared/tui.ts
CHANGED
|
@@ -9,6 +9,7 @@ export const HARNESS_TOOL_LABELS = {
|
|
|
9
9
|
harnesses_mcp_add: "Harnesses MCP Add",
|
|
10
10
|
harnesses_mcp_sync: "Harnesses MCP Sync",
|
|
11
11
|
harnesses_agents_sync: "Harnesses Agents Sync",
|
|
12
|
+
harnesses_prompts_sync: "Harnesses Prompts Sync",
|
|
12
13
|
harnesses_mcp_remove: "Harnesses MCP Remove",
|
|
13
14
|
} as const;
|
|
14
15
|
|
|
@@ -23,6 +24,7 @@ export const HARNESS_TOOL_APPROVALS: Record<HarnessToolName, "read" | "exec" | "
|
|
|
23
24
|
harnesses_mcp_add: "write",
|
|
24
25
|
harnesses_mcp_sync: "write",
|
|
25
26
|
harnesses_agents_sync: "write",
|
|
27
|
+
harnesses_prompts_sync: "write",
|
|
26
28
|
harnesses_mcp_remove: "write",
|
|
27
29
|
};
|
|
28
30
|
|
|
@@ -93,8 +95,16 @@ function listLength(record: Readonly<Record<string, unknown>>, key: string): num
|
|
|
93
95
|
|
|
94
96
|
function resultText(result: RenderedToolResult): string {
|
|
95
97
|
const parts: string[] = [];
|
|
98
|
+
let length = 0;
|
|
96
99
|
for (const part of result.content ?? []) {
|
|
97
|
-
if (isRecord(part)
|
|
100
|
+
if (!isRecord(part) || typeof part.text !== "string") continue;
|
|
101
|
+
const separator = parts.length === 0 ? 0 : 1;
|
|
102
|
+
const remaining = RESULT_BODY_LIMIT + 1 - length - separator;
|
|
103
|
+
if (remaining < 0) break;
|
|
104
|
+
const text = part.text.slice(0, remaining);
|
|
105
|
+
parts.push(text);
|
|
106
|
+
length += separator + text.length;
|
|
107
|
+
if (length > RESULT_BODY_LIMIT) break;
|
|
98
108
|
}
|
|
99
109
|
return parts.join("\n");
|
|
100
110
|
}
|
|
@@ -150,6 +160,7 @@ const CALL_DESCRIPTIONS: Record<HarnessToolName, CallDescriptionRenderer> = {
|
|
|
150
160
|
harnesses_mcp_add: mutationDescription,
|
|
151
161
|
harnesses_mcp_sync: idDescription,
|
|
152
162
|
harnesses_agents_sync: agentsDescription,
|
|
163
|
+
harnesses_prompts_sync: agentsDescription,
|
|
153
164
|
harnesses_mcp_remove: mutationDescription,
|
|
154
165
|
};
|
|
155
166
|
|
|
@@ -267,6 +278,15 @@ function agentsSyncMeta(details: ResultDetails): string[] {
|
|
|
267
278
|
return [`${changed} targets`];
|
|
268
279
|
}
|
|
269
280
|
|
|
281
|
+
function promptsSyncMeta(details: ResultDetails): string[] {
|
|
282
|
+
const templates = listLength(details, "templates");
|
|
283
|
+
const targets = listLength(details, "targets");
|
|
284
|
+
return compactStrings([
|
|
285
|
+
templates === undefined ? undefined : `${templates} templates`,
|
|
286
|
+
targets === undefined ? undefined : `${targets} harnesses`,
|
|
287
|
+
]);
|
|
288
|
+
}
|
|
289
|
+
|
|
270
290
|
const RESULT_META: Record<HarnessToolName, ResultMetaRenderer> = {
|
|
271
291
|
harnesses_detect: detectMeta,
|
|
272
292
|
harnesses_info: infoMeta,
|
|
@@ -276,6 +296,7 @@ const RESULT_META: Record<HarnessToolName, ResultMetaRenderer> = {
|
|
|
276
296
|
harnesses_mcp_add: mutationMeta,
|
|
277
297
|
harnesses_mcp_sync: mcpSyncMeta,
|
|
278
298
|
harnesses_agents_sync: agentsSyncMeta,
|
|
299
|
+
harnesses_prompts_sync: promptsSyncMeta,
|
|
279
300
|
harnesses_mcp_remove: mutationMeta,
|
|
280
301
|
};
|
|
281
302
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agents-sync.d.mts","names":[],"sources":["../../src/types.ts","../../src/harness.ts","../../src/mcp-servers.ts","../../src/agents-sync.ts"],"mappings":"AAEA,qBAAa;YAED;YA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