@clicksmith/agent-config 0.1.1 → 0.1.3
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/dist/index.d.ts +2 -3
- package/dist/index.js +9 -52
- package/dist/index.js.map +1 -1
- package/package.json +7 -9
- package/LICENSE +0 -21
package/dist/index.d.ts
CHANGED
|
@@ -371,9 +371,8 @@ interface InstructionTemplateOptions {
|
|
|
371
371
|
declare const DEFAULT_MCP_TOOLS: readonly ["get_session", "list_elements", "get_element_by_id", "get_latest_request"];
|
|
372
372
|
/**
|
|
373
373
|
* The single, shared instruction body. Every native renderer wraps this exact
|
|
374
|
-
* text
|
|
375
|
-
* same
|
|
376
|
-
* plan/worktree safety contract.
|
|
374
|
+
* text so Claude, Cursor, Codex, Antigravity and generic agents all receive the
|
|
375
|
+
* same compact fast-path contract.
|
|
377
376
|
*/
|
|
378
377
|
declare function renderInstructionBody(options?: InstructionTemplateOptions): string;
|
|
379
378
|
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { access, constants } from 'fs/promises';
|
|
3
3
|
import { delimiter, join } from 'path';
|
|
4
|
-
import
|
|
4
|
+
import '@clicksmith/core';
|
|
5
5
|
|
|
6
6
|
// src/types.ts
|
|
7
7
|
var PLACEHOLDER_KEYS = [
|
|
@@ -167,60 +167,14 @@ var DEFAULT_MCP_TOOLS = [
|
|
|
167
167
|
"get_latest_request"
|
|
168
168
|
];
|
|
169
169
|
function renderInstructionBody(options = {}) {
|
|
170
|
-
const tools = options.mcpTools ?? DEFAULT_MCP_TOOLS;
|
|
171
170
|
const attrs = options.stableAttrs ?? [];
|
|
172
|
-
|
|
173
|
-
return `# ClickSmith \u2014 working with captured UI requests
|
|
171
|
+
return `# ClickSmith
|
|
174
172
|
|
|
175
|
-
|
|
176
|
-
with ClickSmith. Each request arrives as a **capture bundle** (a JSON file whose
|
|
177
|
-
path is provided to you) describing one or more elements and a free-text prompt.
|
|
173
|
+
**The user message already contains the exact file location and the change to make.**
|
|
178
174
|
|
|
179
|
-
|
|
175
|
+
Execute ONLY the "Immediate actions" listed in the user message. Do NOT read AGENTS.md, CLAUDE.md, .cursor/rules, guidelines, skills, or any other project docs. Do NOT use MCP tools, list resources, or explore the repo. Run the listed grep (\u2264 2), edit the one matching file, done.${attrs.length ? `
|
|
180
176
|
|
|
181
|
-
|
|
182
|
-
prompt refers to them by number, e.g. _"make #1 match #2's style"_. Always resolve
|
|
183
|
-
\`#N\` to \`elements[]\` entries with the matching \`id\` field. Never guess which
|
|
184
|
-
element is meant \u2014 read the bundle.
|
|
185
|
-
|
|
186
|
-
## 2. Locator priority
|
|
187
|
-
|
|
188
|
-
Each element carries a \`locator\`. Trust them in this exact order, best first:
|
|
189
|
-
|
|
190
|
-
${locatorList}
|
|
191
|
-
|
|
192
|
-
- **source** gives an exact \`file:line\` (injected in dev by @clicksmith/unplugin) \u2014
|
|
193
|
-
edit there directly.
|
|
194
|
-
- **attr** is a stable attribute${attrs.length ? ` (this project uses: ${attrs.map((a) => `\`${a}\``).join(", ")})` : ""}; grep for it to find the JSX/template.
|
|
195
|
-
- **behavioral** is an ARIA role + accessible name; search for the visible text/label.
|
|
196
|
-
- **dom** is a structural fallback; use \`el.text\`, \`el.attrs\`, and \`near\` context to
|
|
197
|
-
locate the component, and prefer adding a stable attribute while you're there.
|
|
198
|
-
|
|
199
|
-
## 3. Plan / worktree safety (read carefully)
|
|
200
|
-
|
|
201
|
-
ClickSmith runs you inside an **isolated git worktree** by default. The execution
|
|
202
|
-
mode is in \`execution.mode\`:
|
|
203
|
-
|
|
204
|
-
- **plan** (the default): produce a clear plan and, if helpful, a diff \u2014 but **do
|
|
205
|
-
not** assume your edits ship. The human reviews your plan/diff and explicitly
|
|
206
|
-
clicks **Apply**. Your job is to propose, precisely.
|
|
207
|
-
- **edit**: you may modify files in the sandbox. They still do **not** reach the
|
|
208
|
-
user's main working tree until they click Apply.
|
|
209
|
-
|
|
210
|
-
Never run destructive git commands, never push, and never touch files outside the
|
|
211
|
-
sandbox working directory.
|
|
212
|
-
|
|
213
|
-
## 4. Reading the request
|
|
214
|
-
|
|
215
|
-
The bundle path is passed on the command line / via your harness. ${tools.length ? `You can also use these MCP tools (server \`clicksmith\`): ${tools.map((t) => `\`${t}\``).join(", ")}. Use \`get_latest_request\` to fetch the most recent submission, then \`get_element_by_id\` to resolve a specific \`#N\`.` : ""}
|
|
216
|
-
|
|
217
|
-
Each element includes: \`locator\`, \`el\` (tag/text/role/label/attrs/icon hints),
|
|
218
|
-
\`near\` (surrounding labels & headings), \`conditions\` (viewport/theme), and an
|
|
219
|
-
optional \`screenshot\` thumbnail. Use \`near\` and \`app.route\` to disambiguate when
|
|
220
|
-
multiple elements look similar.
|
|
221
|
-
${options.daemonPort ? `
|
|
222
|
-
The ClickSmith daemon is at http://127.0.0.1:${options.daemonPort}.
|
|
223
|
-
` : ""}`;
|
|
177
|
+
Project stable attrs: ${attrs.join(", ")}.` : ""}`;
|
|
224
178
|
}
|
|
225
179
|
|
|
226
180
|
// src/renderers.ts
|
|
@@ -249,7 +203,7 @@ ${block}`;
|
|
|
249
203
|
function cursorMdc(body) {
|
|
250
204
|
return `---
|
|
251
205
|
description: ClickSmith \u2014 how to handle captured UI change requests
|
|
252
|
-
alwaysApply:
|
|
206
|
+
alwaysApply: false
|
|
253
207
|
---
|
|
254
208
|
|
|
255
209
|
${body.trim()}
|
|
@@ -322,6 +276,9 @@ var DEFAULT_AGENTS = [
|
|
|
322
276
|
"--sandbox",
|
|
323
277
|
"workspace-write",
|
|
324
278
|
"--skip-git-repo-check",
|
|
279
|
+
"--ephemeral",
|
|
280
|
+
"-c",
|
|
281
|
+
'model_reasoning_effort="low"',
|
|
325
282
|
"{agentPrompt}"
|
|
326
283
|
],
|
|
327
284
|
detect: { anyOf: ["codex"] },
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts","../src/config-schema.ts","../src/placeholders.ts","../src/bin-exists.ts","../src/adapter.ts","../src/instruction-template.ts","../src/renderers.ts","../src/defaults.ts","../src/merge.ts"],"names":[],"mappings":";;;;;;AAGO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,YAAA;AAAA,EACA,QAAA;AAAA,EACA,aAAA;AAAA,EACA,iBAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF;ACRO,IAAM,uBAAA,GAA0B,EAAE,IAAA,CAAK;AAAA,EAC5C,QAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF,CAAC;AAIM,IAAM,qBAAA,GAAwB,EAAE,IAAA,CAAK,CAAC,UAAU,QAAA,EAAU,OAAA,EAAS,UAAA,EAAY,MAAM,CAAC;AAQtF,IAAM,iBAAA,GAAoB,EAAE,MAAA,CAAO;AAAA,EACxC,EAAA,EAAI,CAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA,EACpB,KAAA,EAAO,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA;AAAA,EAE3B,OAAA,EAAS,CAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA;AAAA,EAEzB,IAAA,EAAM,EAAE,KAAA,CAAM,CAAA,CAAE,QAAQ,CAAA,CAAE,OAAA,CAAQ,EAAE,CAAA;AAAA;AAAA,EAEpC,KAAK,CAAA,CAAE,MAAA,CAAO,EAAE,MAAA,EAAQ,EAAE,QAAA,EAAS;AAAA;AAAA,EAEnC,GAAA,EAAK,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA;AAAA,EAEzB,MAAA,EAAQ,EACL,MAAA,CAAO;AAAA,IACN,KAAA,EAAO,EAAE,KAAA,CAAM,CAAA,CAAE,QAAQ,CAAA,CAAE,IAAI,CAAC;AAAA,GACjC,EACA,QAAA,EAAS;AAAA;AAAA,EAEZ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KAAM,CAAA,CAAE,EAAA,KAAO,MAAA,CAAO,YAAY,CAAA;AACpE,IAAA,IAAI,OAAO,OAAO,KAAA;AAAA,EACpB;AACA,EAAA,OAAO,MAAA,CAAO,OAAO,CAAC,CAAA;AACxB","file":"index.js","sourcesContent":["import type { ExecutionMode, Isolation } from '@clicksmith/core';\n\n/** Every placeholder the launcher knows how to resolve in a command template. */\nexport const PLACEHOLDER_KEYS = [\n 'bundlePath',\n 'prompt',\n 'agentPrompt',\n 'instructionFile',\n 'mode',\n 'mcpServer',\n 'cwd',\n] as const;\n\nexport type PlaceholderKey = (typeof PLACEHOLDER_KEYS)[number];\n\n/**\n * Everything the launcher needs to turn a config-driven command template into a\n * concrete process invocation. This is also the `ctx` passed to adapter hooks.\n */\nexport interface AgentLaunchContext {\n /** Absolute path to the serialized capture bundle. */\n bundlePath: string;\n /** The user's free-text prompt. */\n prompt: string;\n /** Full agent-ready prompt containing the ClickSmith bundle and instruction paths. */\n agentPrompt: string;\n /** Absolute path to the rendered instruction file for this agent. */\n instructionFile: string;\n /** Execution mode (`plan` | `edit`). */\n mode: ExecutionMode;\n /** A reference the agent can use to reach the ClickSmith MCP server. */\n mcpServer: string;\n /** Working directory for the spawned process (the sandbox). */\n cwd: string;\n /** Isolation strategy in effect for this run. */\n isolation: Isolation;\n /** The agent id being launched. */\n agentId: string;\n /**\n * Resolves whether an executable exists on PATH. Injected by the daemon so\n * adapters never have to spawn processes themselves. Defaults to a PATH scan.\n */\n binExists?: (bin: string) => Promise<boolean>;\n}\n\n/** A concrete, ready-to-spawn process specification. */\nexport interface CommandSpec {\n command: string;\n args: string[];\n env?: Record<string, string>;\n cwd?: string;\n}\n\n/** A normalized event parsed from an agent's stdout/stderr stream. */\nexport type AgentEvent =\n | { type: 'plan-ready'; plan?: string; diff?: string }\n | { type: 'progress'; message: string }\n | { type: 'error'; message: string };\n\n/**\n * The adapter contract. Built-in adapters are produced from `agents.config.json`\n * by {@link configToAdapter}; the launcher only resolves placeholders. Authors\n * may also hand-write adapters that satisfy this interface.\n */\nexport interface AgentAdapter {\n id: string;\n /** Whether the agent's CLI is installed/usable in this context. */\n isAvailable(ctx: AgentLaunchContext): Promise<boolean>;\n /** Build the concrete command to spawn. */\n buildCommand(ctx: AgentLaunchContext): CommandSpec;\n /** Optionally map a raw output chunk into structured events. */\n parseEvents?(chunk: string, ctx: AgentLaunchContext): AgentEvent[];\n}\n","import { z } from 'zod';\n\n/** Which native instruction format a renderer should target. */\nexport const InstructionTargetSchema = z.enum([\n 'claude',\n 'cursor',\n 'codex',\n 'antigravity',\n 'generic',\n]);\nexport type InstructionTarget = z.infer<typeof InstructionTargetSchema>;\n\n/** How (and whether) to register the daemon's MCP server for this agent. */\nexport const McpRegistrationSchema = z.enum(['claude', 'cursor', 'codex', 'mcp-json', 'none']);\nexport type McpRegistration = z.infer<typeof McpRegistrationSchema>;\n\n/**\n * One agent definition. The `command`/`args` are templates containing\n * placeholders like `{prompt}` — they are **data**, never code. Changing a\n * vendor flag is an edit here, not a code change.\n */\nexport const AgentConfigSchema = z.object({\n id: z.string().min(1),\n label: z.string().optional(),\n /** Executable name or path. May contain placeholders. */\n command: z.string().min(1),\n /** Argument templates; each entry may contain placeholders. */\n args: z.array(z.string()).default([]),\n /** Extra environment variables (values may contain placeholders). */\n env: z.record(z.string()).optional(),\n /** Working directory override (placeholders allowed). Defaults to the sandbox. */\n cwd: z.string().optional(),\n /** How to detect availability: any of these executables must be on PATH. */\n detect: z\n .object({\n anyOf: z.array(z.string()).min(1),\n })\n .optional(),\n /** Where to render this agent's instruction file. */\n instructions: z\n .object({\n target: InstructionTargetSchema,\n file: z.string().min(1),\n })\n .optional(),\n /** How to register the daemon MCP server for this agent. */\n mcp: z\n .object({\n register: McpRegistrationSchema,\n })\n .optional(),\n /** Optional regexes that map log lines to structured events. */\n parse: z\n .object({\n planReady: z.string().optional(),\n error: z.string().optional(),\n })\n .optional(),\n});\nexport type AgentConfig = z.infer<typeof AgentConfigSchema>;\n\n/** The top-level `agents.config.json` document. */\nexport const AgentsConfigSchema = z.object({\n version: z.literal(1).default(1),\n defaultAgent: z.string().optional(),\n agents: z.array(AgentConfigSchema).default([]),\n});\nexport type AgentsConfig = z.infer<typeof AgentsConfigSchema>;\n\n/** Parse and validate an `agents.config.json` value without throwing. */\nexport function parseAgentsConfig(value: unknown):\n | { ok: true; config: AgentsConfig }\n | { ok: false; error: z.ZodError } {\n const result = AgentsConfigSchema.safeParse(value);\n return result.success\n ? { ok: true, config: result.data }\n : { ok: false, error: result.error };\n}\n","import {\n PLACEHOLDER_KEYS,\n type AgentLaunchContext,\n type CommandSpec,\n type PlaceholderKey,\n} from './types.js';\nimport type { AgentConfig } from './config-schema.js';\n\n/** Build the placeholder → value map from a launch context. */\nexport function placeholderValues(ctx: AgentLaunchContext): Record<PlaceholderKey, string> {\n return {\n bundlePath: ctx.bundlePath,\n prompt: ctx.prompt,\n agentPrompt: ctx.agentPrompt,\n instructionFile: ctx.instructionFile,\n mode: ctx.mode,\n mcpServer: ctx.mcpServer,\n cwd: ctx.cwd,\n };\n}\n\nconst PLACEHOLDER_RE = /\\{([a-zA-Z]+)\\}/g;\n\n/**\n * Replace every known `{placeholder}` in a template string with its value.\n * Unknown placeholders are left untouched (so literal braces survive). This is\n * the *entire* job of the launcher — no vendor-specific knowledge lives here.\n */\nexport function resolvePlaceholders(template: string, ctx: AgentLaunchContext): string {\n const values = placeholderValues(ctx);\n return template.replace(PLACEHOLDER_RE, (match, key: string) => {\n return key in values ? values[key as PlaceholderKey] : match;\n });\n}\n\n/** Resolve an entire {@link AgentConfig} into a concrete {@link CommandSpec}. */\nexport function resolveCommand(config: AgentConfig, ctx: AgentLaunchContext): CommandSpec {\n const env = config.env\n ? Object.fromEntries(\n Object.entries(config.env).map(([k, v]) => [k, resolvePlaceholders(v, ctx)]),\n )\n : undefined;\n return {\n command: resolvePlaceholders(config.command, ctx),\n args: config.args.map((a) => resolvePlaceholders(a, ctx)),\n cwd: config.cwd ? resolvePlaceholders(config.cwd, ctx) : ctx.cwd,\n ...(env ? { env } : {}),\n };\n}\n\n/** List the placeholders actually referenced by a template string. */\nexport function referencedPlaceholders(template: string): PlaceholderKey[] {\n const found = new Set<PlaceholderKey>();\n for (const m of template.matchAll(PLACEHOLDER_RE)) {\n const key = m[1] as string;\n if ((PLACEHOLDER_KEYS as readonly string[]).includes(key)) {\n found.add(key as PlaceholderKey);\n }\n }\n return [...found];\n}\n","import { access, constants } from 'node:fs/promises';\nimport { delimiter, join } from 'node:path';\n\n/**\n * Default executable-on-PATH check. Scans `PATH` for the given binary,\n * honoring `PATHEXT` on Windows. Adapters receive this via the launch context\n * but the daemon may override it (e.g. for tests).\n */\nexport async function defaultBinExists(bin: string): Promise<boolean> {\n // An explicit path: just check it directly.\n if (bin.includes('/') || bin.includes('\\\\')) {\n return canExecute(bin);\n }\n const pathEnv = process.env.PATH ?? '';\n const exts = process.platform === 'win32' ? (process.env.PATHEXT ?? '.EXE;.CMD;.BAT').split(';') : [''];\n for (const dir of pathEnv.split(delimiter)) {\n if (!dir) continue;\n for (const ext of exts) {\n if (await canExecute(join(dir, bin + ext))) return true;\n }\n }\n return false;\n}\n\nasync function canExecute(file: string): Promise<boolean> {\n try {\n await access(file, constants.X_OK);\n return true;\n } catch {\n return false;\n }\n}\n","import { defaultBinExists } from './bin-exists.js';\nimport { resolveCommand } from './placeholders.js';\nimport type { AgentConfig } from './config-schema.js';\nimport type { AgentAdapter, AgentEvent, AgentLaunchContext } from './types.js';\n\n/**\n * Turn a config entry into a live {@link AgentAdapter}. This is the bridge that\n * lets *data* (`agents.config.json`) behave like a built-in adapter:\n *\n * - `isAvailable` checks the configured `detect.anyOf` executables on PATH.\n * - `buildCommand` resolves placeholders into a concrete command.\n * - `parseEvents` applies the optional regexes from `config.parse`.\n */\nexport function configToAdapter(config: AgentConfig): AgentAdapter {\n const planRe = config.parse?.planReady ? new RegExp(config.parse.planReady, 'i') : undefined;\n const errRe = config.parse?.error ? new RegExp(config.parse.error, 'i') : undefined;\n\n return {\n id: config.id,\n\n async isAvailable(ctx: AgentLaunchContext): Promise<boolean> {\n const bins = config.detect?.anyOf ?? [config.command];\n const exists = ctx.binExists ?? defaultBinExists;\n for (const bin of bins) {\n if (await exists(bin)) return true;\n }\n return false;\n },\n\n buildCommand(ctx: AgentLaunchContext) {\n return resolveCommand(config, ctx);\n },\n\n parseEvents(chunk: string): AgentEvent[] {\n if (!planRe && !errRe) return [];\n const events: AgentEvent[] = [];\n for (const line of chunk.split(/\\r?\\n/)) {\n if (!line.trim()) continue;\n if (errRe?.test(line)) events.push({ type: 'error', message: line.trim() });\n else if (planRe?.test(line)) events.push({ type: 'plan-ready' });\n }\n return events;\n },\n };\n}\n\n/** Build adapters for every agent in a config, keyed by id. */\nexport function buildAdapters(configs: readonly AgentConfig[]): Map<string, AgentAdapter> {\n const map = new Map<string, AgentAdapter>();\n for (const config of configs) {\n map.set(config.id, configToAdapter(config));\n }\n return map;\n}\n","import { LOCATOR_PRIORITY } from '@clicksmith/core';\n\nexport interface InstructionTemplateOptions {\n /** MCP tool names exposed by the daemon. */\n mcpTools?: readonly string[];\n /** The daemon port, for the agent's reference. */\n daemonPort?: number;\n /** Project-specific stable attributes the project relies on (e.g. data-testid). */\n stableAttrs?: readonly string[];\n}\n\nexport const DEFAULT_MCP_TOOLS = [\n 'get_session',\n 'list_elements',\n 'get_element_by_id',\n 'get_latest_request',\n] as const;\n\n/**\n * The single, shared instruction body. Every native renderer wraps this exact\n * text — so Claude, Cursor, Codex, Antigravity and generic agents all learn the\n * same three things: the `#N` reference system, locator priority, and the\n * plan/worktree safety contract.\n */\nexport function renderInstructionBody(options: InstructionTemplateOptions = {}): string {\n const tools = options.mcpTools ?? DEFAULT_MCP_TOOLS;\n const attrs = options.stableAttrs ?? [];\n const locatorList = LOCATOR_PRIORITY.map((kind, i) => `${i + 1}. **${kind}**`).join(' → ');\n\n return `# ClickSmith — working with captured UI requests\n\nYou are being asked to change UI elements that a human pointed at in their browser\nwith ClickSmith. Each request arrives as a **capture bundle** (a JSON file whose\npath is provided to you) describing one or more elements and a free-text prompt.\n\n## 1. The \\`#N\\` reference system\n\nElements are numbered \\`#1\\`, \\`#2\\`, … in the order they were captured. The user's\nprompt refers to them by number, e.g. _\"make #1 match #2's style\"_. Always resolve\n\\`#N\\` to \\`elements[]\\` entries with the matching \\`id\\` field. Never guess which\nelement is meant — read the bundle.\n\n## 2. Locator priority\n\nEach element carries a \\`locator\\`. Trust them in this exact order, best first:\n\n${locatorList}\n\n- **source** gives an exact \\`file:line\\` (injected in dev by @clicksmith/unplugin) —\n edit there directly.\n- **attr** is a stable attribute${attrs.length ? ` (this project uses: ${attrs.map((a) => `\\`${a}\\``).join(', ')})` : ''}; grep for it to find the JSX/template.\n- **behavioral** is an ARIA role + accessible name; search for the visible text/label.\n- **dom** is a structural fallback; use \\`el.text\\`, \\`el.attrs\\`, and \\`near\\` context to\n locate the component, and prefer adding a stable attribute while you're there.\n\n## 3. Plan / worktree safety (read carefully)\n\nClickSmith runs you inside an **isolated git worktree** by default. The execution\nmode is in \\`execution.mode\\`:\n\n- **plan** (the default): produce a clear plan and, if helpful, a diff — but **do\n not** assume your edits ship. The human reviews your plan/diff and explicitly\n clicks **Apply**. Your job is to propose, precisely.\n- **edit**: you may modify files in the sandbox. They still do **not** reach the\n user's main working tree until they click Apply.\n\nNever run destructive git commands, never push, and never touch files outside the\nsandbox working directory.\n\n## 4. Reading the request\n\nThe bundle path is passed on the command line / via your harness. ${\n tools.length\n ? `You can also use these MCP tools (server \\`clicksmith\\`): ${tools\n .map((t) => `\\`${t}\\``)\n .join(', ')}. Use \\`get_latest_request\\` to fetch the most recent submission, then \\`get_element_by_id\\` to resolve a specific \\`#N\\`.`\n : ''\n}\n\nEach element includes: \\`locator\\`, \\`el\\` (tag/text/role/label/attrs/icon hints),\n\\`near\\` (surrounding labels & headings), \\`conditions\\` (viewport/theme), and an\noptional \\`screenshot\\` thumbnail. Use \\`near\\` and \\`app.route\\` to disambiguate when\nmultiple elements look similar.\n${options.daemonPort ? `\\nThe ClickSmith daemon is at http://127.0.0.1:${options.daemonPort}.\\n` : ''}`;\n}\n","import { renderInstructionBody, type InstructionTemplateOptions } from './instruction-template.js';\nimport type { InstructionTarget } from './config-schema.js';\n\nexport const MANAGED_BEGIN = '<!-- BEGIN CLICKSMITH (managed — do not edit by hand) -->';\nexport const MANAGED_END = '<!-- END CLICKSMITH (managed) -->';\n\nexport interface RenderedInstruction {\n target: InstructionTarget;\n /** Default relative path for this target's native file. */\n path: string;\n /**\n * `true` when the target file commonly holds other content (e.g. `CLAUDE.md`,\n * `AGENTS.md`). The installer then inserts {@link content} as a managed block\n * rather than overwriting the whole file.\n */\n shared: boolean;\n /** Full file content (dedicated files) or managed-block body (shared files). */\n content: string;\n}\n\n/** Wrap a body in the managed-block markers. */\nexport function wrapManagedBlock(body: string): string {\n return `${MANAGED_BEGIN}\\n${body.trim()}\\n${MANAGED_END}\\n`;\n}\n\n/**\n * Insert or replace the ClickSmith managed block within existing file content,\n * preserving everything the user wrote outside the markers.\n */\nexport function applyManagedBlock(existing: string | undefined, body: string): string {\n const block = wrapManagedBlock(body);\n if (!existing || !existing.trim()) return block;\n const begin = existing.indexOf(MANAGED_BEGIN);\n const end = existing.indexOf(MANAGED_END);\n if (begin !== -1 && end !== -1 && end > begin) {\n const before = existing.slice(0, begin);\n const after = existing.slice(end + MANAGED_END.length);\n return `${before}${block.trimEnd()}${after}`.replace(/\\n{3,}/g, '\\n\\n');\n }\n return `${existing.trimEnd()}\\n\\n${block}`;\n}\n\nfunction cursorMdc(body: string): string {\n // Cursor \"Project Rules\" use MDC frontmatter; alwaysApply keeps it active.\n return `---\ndescription: ClickSmith — how to handle captured UI change requests\nalwaysApply: true\n---\n\n${body.trim()}\n`;\n}\n\n/** Render the shared instruction body into a target's native file. */\nexport function renderInstructions(\n target: InstructionTarget,\n options: InstructionTemplateOptions = {},\n): RenderedInstruction {\n const body = renderInstructionBody(options);\n switch (target) {\n case 'claude':\n return { target, path: 'CLAUDE.md', shared: true, content: body };\n case 'codex':\n return { target, path: 'AGENTS.md', shared: true, content: body };\n case 'cursor':\n return { target, path: '.cursor/rules/clicksmith.mdc', shared: false, content: cursorMdc(body) };\n case 'antigravity':\n return {\n target,\n path: '.antigravity/rules/clicksmith.md',\n shared: false,\n content: `${body.trim()}\\n`,\n };\n case 'generic':\n return {\n target,\n path: '.clicksmith/AGENT_INSTRUCTIONS.md',\n shared: false,\n content: `${body.trim()}\\n`,\n };\n default: {\n const _exhaustive: never = target;\n throw new Error(`Unknown instruction target: ${String(_exhaustive)}`);\n }\n }\n}\n\n/** Render instruction files for several targets at once. */\nexport function renderAllInstructions(\n targets: readonly InstructionTarget[],\n options: InstructionTemplateOptions = {},\n): RenderedInstruction[] {\n return targets.map((t) => renderInstructions(t, options));\n}\n","import type { AgentConfig, AgentsConfig } from './config-schema.js';\n\n/**\n * Built-in agent templates. **These are example defaults — data, not launcher\n * logic.** Changing a vendor's CLI flag means editing `agents.config.json`\n * (or these defaults), never the daemon. The launcher only resolves the\n * `{placeholders}` below; it has no idea what `claude` or `codex` actually do.\n */\nexport const DEFAULT_AGENTS: AgentConfig[] = [\n {\n id: 'claude',\n label: 'Claude Code',\n command: 'claude',\n args: ['-p', '{agentPrompt}', '--append-system-prompt', '@{instructionFile}'],\n detect: { anyOf: ['claude'] },\n instructions: { target: 'claude', file: 'CLAUDE.md' },\n mcp: { register: 'claude' },\n parse: { planReady: 'plan ready|here is the plan|## plan', error: '^error:|fatal:' },\n },\n {\n id: 'cursor',\n label: 'Cursor Agent',\n command: 'cursor-agent',\n args: ['--print', '{agentPrompt}'],\n detect: { anyOf: ['cursor-agent', 'cursor'] },\n instructions: { target: 'cursor', file: '.cursor/rules/clicksmith.mdc' },\n mcp: { register: 'cursor' },\n },\n {\n id: 'codex',\n label: 'OpenAI Codex',\n command: 'codex',\n args: [\n 'exec',\n '--cd',\n '{cwd}',\n '--sandbox',\n 'workspace-write',\n '--skip-git-repo-check',\n '{agentPrompt}',\n ],\n detect: { anyOf: ['codex'] },\n instructions: { target: 'codex', file: 'AGENTS.md' },\n mcp: { register: 'codex' },\n },\n {\n id: 'antigravity',\n label: 'Antigravity',\n command: 'antigravity',\n args: ['run', '--prompt', '{agentPrompt}'],\n detect: { anyOf: ['antigravity'] },\n instructions: { target: 'antigravity', file: '.antigravity/rules/clicksmith.md' },\n mcp: { register: 'mcp-json' },\n },\n {\n id: 'generic',\n label: 'Generic agent (customize me)',\n command: 'sh',\n args: [\n '-c',\n 'echo \"ClickSmith request: {prompt}\"; echo \"Bundle: {bundlePath}\"; echo \"Instructions: {instructionFile}\"; echo \"Mode: {mode}\"; echo \"Prompt: {agentPrompt}\"',\n ],\n instructions: { target: 'generic', file: '.clicksmith/AGENT_INSTRUCTIONS.md' },\n mcp: { register: 'mcp-json' },\n },\n];\n\n/** The full default `agents.config.json` document. */\nexport const DEFAULT_AGENTS_CONFIG: AgentsConfig = {\n version: 1,\n defaultAgent: 'claude',\n agents: DEFAULT_AGENTS,\n};\n","import type { AgentConfig, AgentsConfig } from './config-schema.js';\n\n/**\n * Layer agent configs: shipped defaults → project config → user config. Agents\n * with the same `id` are replaced by later layers; new ids are appended in\n * order. `defaultAgent` from the last layer that sets it wins.\n */\nexport function mergeAgentsConfig(base: AgentsConfig, ...overlays: AgentsConfig[]): AgentsConfig {\n let agents = [...base.agents];\n let defaultAgent = base.defaultAgent;\n\n for (const overlay of overlays) {\n agents = mergeAgentList(agents, overlay.agents);\n if (overlay.defaultAgent) defaultAgent = overlay.defaultAgent;\n }\n\n return {\n version: 1,\n ...(defaultAgent ? { defaultAgent } : {}),\n agents,\n };\n}\n\nfunction mergeAgentList(base: AgentConfig[], overlay: AgentConfig[]): AgentConfig[] {\n const byId = new Map(base.map((a) => [a.id, a]));\n const order = base.map((a) => a.id);\n for (const agent of overlay) {\n if (!byId.has(agent.id)) order.push(agent.id);\n byId.set(agent.id, agent);\n }\n return order.map((id) => byId.get(id)!);\n}\n\n/** Resolve the effective agent for a run: explicit id → defaultAgent → first. */\nexport function resolveAgent(config: AgentsConfig, agentId?: string): AgentConfig | undefined {\n if (agentId) return config.agents.find((a) => a.id === agentId);\n if (config.defaultAgent) {\n const found = config.agents.find((a) => a.id === config.defaultAgent);\n if (found) return found;\n }\n return config.agents[0];\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/types.ts","../src/config-schema.ts","../src/placeholders.ts","../src/bin-exists.ts","../src/adapter.ts","../src/instruction-template.ts","../src/renderers.ts","../src/defaults.ts","../src/merge.ts"],"names":[],"mappings":";;;;;;AAGO,IAAM,gBAAA,GAAmB;AAAA,EAC9B,YAAA;AAAA,EACA,QAAA;AAAA,EACA,aAAA;AAAA,EACA,iBAAA;AAAA,EACA,MAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF;ACRO,IAAM,uBAAA,GAA0B,EAAE,IAAA,CAAK;AAAA,EAC5C,QAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF,CAAC;AAIM,IAAM,qBAAA,GAAwB,EAAE,IAAA,CAAK,CAAC,UAAU,QAAA,EAAU,OAAA,EAAS,UAAA,EAAY,MAAM,CAAC;AAQtF,IAAM,iBAAA,GAAoB,EAAE,MAAA,CAAO;AAAA,EACxC,EAAA,EAAI,CAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA,EACpB,KAAA,EAAO,CAAA,CAAE,MAAA,EAAO,CAAE,QAAA,EAAS;AAAA;AAAA,EAE3B,OAAA,EAAS,CAAA,CAAE,MAAA,EAAO,CAAE,IAAI,CAAC,CAAA;AAAA;AAAA,EAEzB,IAAA,EAAM,EAAE,KAAA,CAAM,CAAA,CAAE,QAAQ,CAAA,CAAE,OAAA,CAAQ,EAAE,CAAA;AAAA;AAAA,EAEpC,KAAK,CAAA,CAAE,MAAA,CAAO,EAAE,MAAA,EAAQ,EAAE,QAAA,EAAS;AAAA;AAAA,EAEnC,GAAA,EA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AA;AAC/C,EAAA,MAAM,QAAQ,IAAA,CAAK,GAAA,CAAI,CAAC,CAAA,KAAM,EAAE,EAAE,CAAA;AAClC,EAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC3B,IAAA,IAAI,CAAC,KAAK,GAAA,CAAI,KAAA,CAAM,EAAE,CAAA,EAAG,KAAA,CAAM,IAAA,CAAK,KAAA,CAAM,EAAE,CAAA;AAC5C,IAAA,IAAA,CAAK,GAAA,CAAI,KAAA,CAAM,EAAA,EAAI,KAAK,CAAA;AAAA,EAC1B;AACA,EAAA,OAAO,MAAM,GAAA,CAAI,CAAC,OAAO,IAAA,CAAK,GAAA,CAAI,EAAE,CAAE,CAAA;AACxC;AAGO,SAAS,YAAA,CAAa,QAAsB,OAAA,EAA2C;AAC5F,EAAA,IAAI,OAAA,SAAgB,MAAA,CAAO,MAAA,CAAO,KAAK,CAAC,CAAA,KAAM,CAAA,CAAE,EAAA,KAAO,OAAO,CAAA;AAC9D,EAAA,IAAI,OAAO,YAAA,EAAc;AACvB,IAAA,MAAM,KAAA,GAAQ,OAAO,MAAA,CAAO,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,EAAA,KAAO,MAAA,CAAO,YAAY,CAAA;AACpE,IAAA,IAAI,OAAO,OAAO,KAAA;AAAA,EACpB;AACA,EAAA,OAAO,MAAA,CAAO,OAAO,CAAC,CAAA;AACxB","file":"index.js","sourcesContent":["import type { ExecutionMode, Isolation } from '@clicksmith/core';\n\n/** Every placeholder the launcher knows how to resolve in a command template. */\nexport const PLACEHOLDER_KEYS = [\n 'bundlePath',\n 'prompt',\n 'agentPrompt',\n 'instructionFile',\n 'mode',\n 'mcpServer',\n 'cwd',\n] as const;\n\nexport type PlaceholderKey = (typeof PLACEHOLDER_KEYS)[number];\n\n/**\n * Everything the launcher needs to turn a config-driven command template into a\n * concrete process invocation. This is also the `ctx` passed to adapter hooks.\n */\nexport interface AgentLaunchContext {\n /** Absolute path to the serialized capture bundle. */\n bundlePath: string;\n /** The user's free-text prompt. */\n prompt: string;\n /** Full agent-ready prompt containing the ClickSmith bundle and instruction paths. */\n agentPrompt: string;\n /** Absolute path to the rendered instruction file for this agent. */\n instructionFile: string;\n /** Execution mode (`plan` | `edit`). */\n mode: ExecutionMode;\n /** A reference the agent can use to reach the ClickSmith MCP server. */\n mcpServer: string;\n /** Working directory for the spawned process (the sandbox). */\n cwd: string;\n /** Isolation strategy in effect for this run. */\n isolation: Isolation;\n /** The agent id being launched. */\n agentId: string;\n /**\n * Resolves whether an executable exists on PATH. Injected by the daemon so\n * adapters never have to spawn processes themselves. Defaults to a PATH scan.\n */\n binExists?: (bin: string) => Promise<boolean>;\n}\n\n/** A concrete, ready-to-spawn process specification. */\nexport interface CommandSpec {\n command: string;\n args: string[];\n env?: Record<string, string>;\n cwd?: string;\n}\n\n/** A normalized event parsed from an agent's stdout/stderr stream. */\nexport type AgentEvent =\n | { type: 'plan-ready'; plan?: string; diff?: string }\n | { type: 'progress'; message: string }\n | { type: 'error'; message: string };\n\n/**\n * The adapter contract. Built-in adapters are produced from `agents.config.json`\n * by {@link configToAdapter}; the launcher only resolves placeholders. Authors\n * may also hand-write adapters that satisfy this interface.\n */\nexport interface AgentAdapter {\n id: string;\n /** Whether the agent's CLI is installed/usable in this context. */\n isAvailable(ctx: AgentLaunchContext): Promise<boolean>;\n /** Build the concrete command to spawn. */\n buildCommand(ctx: AgentLaunchContext): CommandSpec;\n /** Optionally map a raw output chunk into structured events. */\n parseEvents?(chunk: string, ctx: AgentLaunchContext): AgentEvent[];\n}\n","import { z } from 'zod';\n\n/** Which native instruction format a renderer should target. */\nexport const InstructionTargetSchema = z.enum([\n 'claude',\n 'cursor',\n 'codex',\n 'antigravity',\n 'generic',\n]);\nexport type InstructionTarget = z.infer<typeof InstructionTargetSchema>;\n\n/** How (and whether) to register the daemon's MCP server for this agent. */\nexport const McpRegistrationSchema = z.enum(['claude', 'cursor', 'codex', 'mcp-json', 'none']);\nexport type McpRegistration = z.infer<typeof McpRegistrationSchema>;\n\n/**\n * One agent definition. The `command`/`args` are templates containing\n * placeholders like `{prompt}` — they are **data**, never code. Changing a\n * vendor flag is an edit here, not a code change.\n */\nexport const AgentConfigSchema = z.object({\n id: z.string().min(1),\n label: z.string().optional(),\n /** Executable name or path. May contain placeholders. */\n command: z.string().min(1),\n /** Argument templates; each entry may contain placeholders. */\n args: z.array(z.string()).default([]),\n /** Extra environment variables (values may contain placeholders). */\n env: z.record(z.string()).optional(),\n /** Working directory override (placeholders allowed). Defaults to the sandbox. */\n cwd: z.string().optional(),\n /** How to detect availability: any of these executables must be on PATH. */\n detect: z\n .object({\n anyOf: z.array(z.string()).min(1),\n })\n .optional(),\n /** Where to render this agent's instruction file. */\n instructions: z\n .object({\n target: InstructionTargetSchema,\n file: z.string().min(1),\n })\n .optional(),\n /** How to register the daemon MCP server for this agent. */\n mcp: z\n .object({\n register: McpRegistrationSchema,\n })\n .optional(),\n /** Optional regexes that map log lines to structured events. */\n parse: z\n .object({\n planReady: z.string().optional(),\n error: z.string().optional(),\n })\n .optional(),\n});\nexport type AgentConfig = z.infer<typeof AgentConfigSchema>;\n\n/** The top-level `agents.config.json` document. */\nexport const AgentsConfigSchema = z.object({\n version: z.literal(1).default(1),\n defaultAgent: z.string().optional(),\n agents: z.array(AgentConfigSchema).default([]),\n});\nexport type AgentsConfig = z.infer<typeof AgentsConfigSchema>;\n\n/** Parse and validate an `agents.config.json` value without throwing. */\nexport function parseAgentsConfig(value: unknown):\n | { ok: true; config: AgentsConfig }\n | { ok: false; error: z.ZodError } {\n const result = AgentsConfigSchema.safeParse(value);\n return result.success\n ? { ok: true, config: result.data }\n : { ok: false, error: result.error };\n}\n","import {\n PLACEHOLDER_KEYS,\n type AgentLaunchContext,\n type CommandSpec,\n type PlaceholderKey,\n} from './types.js';\nimport type { AgentConfig } from './config-schema.js';\n\n/** Build the placeholder → value map from a launch context. */\nexport function placeholderValues(ctx: AgentLaunchContext): Record<PlaceholderKey, string> {\n return {\n bundlePath: ctx.bundlePath,\n prompt: ctx.prompt,\n agentPrompt: ctx.agentPrompt,\n instructionFile: ctx.instructionFile,\n mode: ctx.mode,\n mcpServer: ctx.mcpServer,\n cwd: ctx.cwd,\n };\n}\n\nconst PLACEHOLDER_RE = /\\{([a-zA-Z]+)\\}/g;\n\n/**\n * Replace every known `{placeholder}` in a template string with its value.\n * Unknown placeholders are left untouched (so literal braces survive). This is\n * the *entire* job of the launcher — no vendor-specific knowledge lives here.\n */\nexport function resolvePlaceholders(template: string, ctx: AgentLaunchContext): string {\n const values = placeholderValues(ctx);\n return template.replace(PLACEHOLDER_RE, (match, key: string) => {\n return key in values ? values[key as PlaceholderKey] : match;\n });\n}\n\n/** Resolve an entire {@link AgentConfig} into a concrete {@link CommandSpec}. */\nexport function resolveCommand(config: AgentConfig, ctx: AgentLaunchContext): CommandSpec {\n const env = config.env\n ? Object.fromEntries(\n Object.entries(config.env).map(([k, v]) => [k, resolvePlaceholders(v, ctx)]),\n )\n : undefined;\n return {\n command: resolvePlaceholders(config.command, ctx),\n args: config.args.map((a) => resolvePlaceholders(a, ctx)),\n cwd: config.cwd ? resolvePlaceholders(config.cwd, ctx) : ctx.cwd,\n ...(env ? { env } : {}),\n };\n}\n\n/** List the placeholders actually referenced by a template string. */\nexport function referencedPlaceholders(template: string): PlaceholderKey[] {\n const found = new Set<PlaceholderKey>();\n for (const m of template.matchAll(PLACEHOLDER_RE)) {\n const key = m[1] as string;\n if ((PLACEHOLDER_KEYS as readonly string[]).includes(key)) {\n found.add(key as PlaceholderKey);\n }\n }\n return [...found];\n}\n","import { access, constants } from 'node:fs/promises';\nimport { delimiter, join } from 'node:path';\n\n/**\n * Default executable-on-PATH check. Scans `PATH` for the given binary,\n * honoring `PATHEXT` on Windows. Adapters receive this via the launch context\n * but the daemon may override it (e.g. for tests).\n */\nexport async function defaultBinExists(bin: string): Promise<boolean> {\n // An explicit path: just check it directly.\n if (bin.includes('/') || bin.includes('\\\\')) {\n return canExecute(bin);\n }\n const pathEnv = process.env.PATH ?? '';\n const exts = process.platform === 'win32' ? (process.env.PATHEXT ?? '.EXE;.CMD;.BAT').split(';') : [''];\n for (const dir of pathEnv.split(delimiter)) {\n if (!dir) continue;\n for (const ext of exts) {\n if (await canExecute(join(dir, bin + ext))) return true;\n }\n }\n return false;\n}\n\nasync function canExecute(file: string): Promise<boolean> {\n try {\n await access(file, constants.X_OK);\n return true;\n } catch {\n return false;\n }\n}\n","import { defaultBinExists } from './bin-exists.js';\nimport { resolveCommand } from './placeholders.js';\nimport type { AgentConfig } from './config-schema.js';\nimport type { AgentAdapter, AgentEvent, AgentLaunchContext } from './types.js';\n\n/**\n * Turn a config entry into a live {@link AgentAdapter}. This is the bridge that\n * lets *data* (`agents.config.json`) behave like a built-in adapter:\n *\n * - `isAvailable` checks the configured `detect.anyOf` executables on PATH.\n * - `buildCommand` resolves placeholders into a concrete command.\n * - `parseEvents` applies the optional regexes from `config.parse`.\n */\nexport function configToAdapter(config: AgentConfig): AgentAdapter {\n const planRe = config.parse?.planReady ? new RegExp(config.parse.planReady, 'i') : undefined;\n const errRe = config.parse?.error ? new RegExp(config.parse.error, 'i') : undefined;\n\n return {\n id: config.id,\n\n async isAvailable(ctx: AgentLaunchContext): Promise<boolean> {\n const bins = config.detect?.anyOf ?? [config.command];\n const exists = ctx.binExists ?? defaultBinExists;\n for (const bin of bins) {\n if (await exists(bin)) return true;\n }\n return false;\n },\n\n buildCommand(ctx: AgentLaunchContext) {\n return resolveCommand(config, ctx);\n },\n\n parseEvents(chunk: string): AgentEvent[] {\n if (!planRe && !errRe) return [];\n const events: AgentEvent[] = [];\n for (const line of chunk.split(/\\r?\\n/)) {\n if (!line.trim()) continue;\n if (errRe?.test(line)) events.push({ type: 'error', message: line.trim() });\n else if (planRe?.test(line)) events.push({ type: 'plan-ready' });\n }\n return events;\n },\n };\n}\n\n/** Build adapters for every agent in a config, keyed by id. */\nexport function buildAdapters(configs: readonly AgentConfig[]): Map<string, AgentAdapter> {\n const map = new Map<string, AgentAdapter>();\n for (const config of configs) {\n map.set(config.id, configToAdapter(config));\n }\n return map;\n}\n","import { LOCATOR_PRIORITY } from '@clicksmith/core';\n\nexport interface InstructionTemplateOptions {\n /** MCP tool names exposed by the daemon. */\n mcpTools?: readonly string[];\n /** The daemon port, for the agent's reference. */\n daemonPort?: number;\n /** Project-specific stable attributes the project relies on (e.g. data-testid). */\n stableAttrs?: readonly string[];\n}\n\nexport const DEFAULT_MCP_TOOLS = [\n 'get_session',\n 'list_elements',\n 'get_element_by_id',\n 'get_latest_request',\n] as const;\n\n/**\n * The single, shared instruction body. Every native renderer wraps this exact\n * text so Claude, Cursor, Codex, Antigravity and generic agents all receive the\n * same compact fast-path contract.\n */\nexport function renderInstructionBody(options: InstructionTemplateOptions = {}): string {\n const attrs = options.stableAttrs ?? [];\n\n return `# ClickSmith\n\n**The user message already contains the exact file location and the change to make.**\n\nExecute ONLY the \"Immediate actions\" listed in the user message. Do NOT read AGENTS.md, CLAUDE.md, .cursor/rules, guidelines, skills, or any other project docs. Do NOT use MCP tools, list resources, or explore the repo. Run the listed grep (≤ 2), edit the one matching file, done.${\n attrs.length ? `\\n\\nProject stable attrs: ${attrs.join(', ')}.` : ''\n }`;\n}\n","import { renderInstructionBody, type InstructionTemplateOptions } from './instruction-template.js';\nimport type { InstructionTarget } from './config-schema.js';\n\nexport const MANAGED_BEGIN = '<!-- BEGIN CLICKSMITH (managed — do not edit by hand) -->';\nexport const MANAGED_END = '<!-- END CLICKSMITH (managed) -->';\n\nexport interface RenderedInstruction {\n target: InstructionTarget;\n /** Default relative path for this target's native file. */\n path: string;\n /**\n * `true` when the target file commonly holds other content (e.g. `CLAUDE.md`,\n * `AGENTS.md`). The installer then inserts {@link content} as a managed block\n * rather than overwriting the whole file.\n */\n shared: boolean;\n /** Full file content (dedicated files) or managed-block body (shared files). */\n content: string;\n}\n\n/** Wrap a body in the managed-block markers. */\nexport function wrapManagedBlock(body: string): string {\n return `${MANAGED_BEGIN}\\n${body.trim()}\\n${MANAGED_END}\\n`;\n}\n\n/**\n * Insert or replace the ClickSmith managed block within existing file content,\n * preserving everything the user wrote outside the markers.\n */\nexport function applyManagedBlock(existing: string | undefined, body: string): string {\n const block = wrapManagedBlock(body);\n if (!existing || !existing.trim()) return block;\n const begin = existing.indexOf(MANAGED_BEGIN);\n const end = existing.indexOf(MANAGED_END);\n if (begin !== -1 && end !== -1 && end > begin) {\n const before = existing.slice(0, begin);\n const after = existing.slice(end + MANAGED_END.length);\n return `${before}${block.trimEnd()}${after}`.replace(/\\n{3,}/g, '\\n\\n');\n }\n return `${existing.trimEnd()}\\n\\n${block}`;\n}\n\nfunction cursorMdc(body: string): string {\n // alwaysApply: false — the agentPrompt carries all context; auto-loading this\n // file as system context makes agents explore instead of act immediately.\n return `---\ndescription: ClickSmith — how to handle captured UI change requests\nalwaysApply: false\n---\n\n${body.trim()}\n`;\n}\n\n/** Render the shared instruction body into a target's native file. */\nexport function renderInstructions(\n target: InstructionTarget,\n options: InstructionTemplateOptions = {},\n): RenderedInstruction {\n const body = renderInstructionBody(options);\n switch (target) {\n case 'claude':\n return { target, path: 'CLAUDE.md', shared: true, content: body };\n case 'codex':\n return { target, path: 'AGENTS.md', shared: true, content: body };\n case 'cursor':\n return { target, path: '.cursor/rules/clicksmith.mdc', shared: false, content: cursorMdc(body) };\n case 'antigravity':\n return {\n target,\n path: '.antigravity/rules/clicksmith.md',\n shared: false,\n content: `${body.trim()}\\n`,\n };\n case 'generic':\n return {\n target,\n path: '.clicksmith/AGENT_INSTRUCTIONS.md',\n shared: false,\n content: `${body.trim()}\\n`,\n };\n default: {\n const _exhaustive: never = target;\n throw new Error(`Unknown instruction target: ${String(_exhaustive)}`);\n }\n }\n}\n\n/** Render instruction files for several targets at once. */\nexport function renderAllInstructions(\n targets: readonly InstructionTarget[],\n options: InstructionTemplateOptions = {},\n): RenderedInstruction[] {\n return targets.map((t) => renderInstructions(t, options));\n}\n","import type { AgentConfig, AgentsConfig } from './config-schema.js';\n\n/**\n * Built-in agent templates. **These are example defaults — data, not launcher\n * logic.** Changing a vendor's CLI flag means editing `agents.config.json`\n * (or these defaults), never the daemon. The launcher only resolves the\n * `{placeholders}` below; it has no idea what `claude` or `codex` actually do.\n */\nexport const DEFAULT_AGENTS: AgentConfig[] = [\n {\n id: 'claude',\n label: 'Claude Code',\n command: 'claude',\n args: ['-p', '{agentPrompt}', '--append-system-prompt', '@{instructionFile}'],\n detect: { anyOf: ['claude'] },\n instructions: { target: 'claude', file: 'CLAUDE.md' },\n mcp: { register: 'claude' },\n parse: { planReady: 'plan ready|here is the plan|## plan', error: '^error:|fatal:' },\n },\n {\n id: 'cursor',\n label: 'Cursor Agent',\n command: 'cursor-agent',\n args: ['--print', '{agentPrompt}'],\n detect: { anyOf: ['cursor-agent', 'cursor'] },\n instructions: { target: 'cursor', file: '.cursor/rules/clicksmith.mdc' },\n mcp: { register: 'cursor' },\n },\n {\n id: 'codex',\n label: 'OpenAI Codex',\n command: 'codex',\n args: [\n 'exec',\n '--cd',\n '{cwd}',\n '--sandbox',\n 'workspace-write',\n '--skip-git-repo-check',\n '--ephemeral',\n '-c',\n 'model_reasoning_effort=\"low\"',\n '{agentPrompt}',\n ],\n detect: { anyOf: ['codex'] },\n instructions: { target: 'codex', file: 'AGENTS.md' },\n mcp: { register: 'codex' },\n },\n {\n id: 'antigravity',\n label: 'Antigravity',\n command: 'antigravity',\n args: ['run', '--prompt', '{agentPrompt}'],\n detect: { anyOf: ['antigravity'] },\n instructions: { target: 'antigravity', file: '.antigravity/rules/clicksmith.md' },\n mcp: { register: 'mcp-json' },\n },\n {\n id: 'generic',\n label: 'Generic agent (customize me)',\n command: 'sh',\n args: [\n '-c',\n 'echo \"ClickSmith request: {prompt}\"; echo \"Bundle: {bundlePath}\"; echo \"Instructions: {instructionFile}\"; echo \"Mode: {mode}\"; echo \"Prompt: {agentPrompt}\"',\n ],\n instructions: { target: 'generic', file: '.clicksmith/AGENT_INSTRUCTIONS.md' },\n mcp: { register: 'mcp-json' },\n },\n];\n\n/** The full default `agents.config.json` document. */\nexport const DEFAULT_AGENTS_CONFIG: AgentsConfig = {\n version: 1,\n defaultAgent: 'claude',\n agents: DEFAULT_AGENTS,\n};\n","import type { AgentConfig, AgentsConfig } from './config-schema.js';\n\n/**\n * Layer agent configs: shipped defaults → project config → user config. Agents\n * with the same `id` are replaced by later layers; new ids are appended in\n * order. `defaultAgent` from the last layer that sets it wins.\n */\nexport function mergeAgentsConfig(base: AgentsConfig, ...overlays: AgentsConfig[]): AgentsConfig {\n let agents = [...base.agents];\n let defaultAgent = base.defaultAgent;\n\n for (const overlay of overlays) {\n agents = mergeAgentList(agents, overlay.agents);\n if (overlay.defaultAgent) defaultAgent = overlay.defaultAgent;\n }\n\n return {\n version: 1,\n ...(defaultAgent ? { defaultAgent } : {}),\n agents,\n };\n}\n\nfunction mergeAgentList(base: AgentConfig[], overlay: AgentConfig[]): AgentConfig[] {\n const byId = new Map(base.map((a) => [a.id, a]));\n const order = base.map((a) => a.id);\n for (const agent of overlay) {\n if (!byId.has(agent.id)) order.push(agent.id);\n byId.set(agent.id, agent);\n }\n return order.map((id) => byId.get(id)!);\n}\n\n/** Resolve the effective agent for a run: explicit id → defaultAgent → first. */\nexport function resolveAgent(config: AgentsConfig, agentId?: string): AgentConfig | undefined {\n if (agentId) return config.agents.find((a) => a.id === agentId);\n if (config.defaultAgent) {\n const found = config.agents.find((a) => a.id === config.defaultAgent);\n if (found) return found;\n }\n return config.agents[0];\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clicksmith/agent-config",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Config-driven agent adapters and the shared ClickSmith instruction template, rendered to native files for Claude, Cursor, Codex, Antigravity, and generic agents.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -13,13 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"main": "./dist/index.js",
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
|
-
"files": [
|
|
17
|
-
"dist"
|
|
18
|
-
],
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"zod": "^3.23.8",
|
|
21
|
-
"@clicksmith/core": "0.1.0"
|
|
22
|
-
},
|
|
16
|
+
"files": ["dist"],
|
|
23
17
|
"scripts": {
|
|
24
18
|
"build": "tsup",
|
|
25
19
|
"dev": "tsup --watch",
|
|
@@ -28,5 +22,9 @@
|
|
|
28
22
|
"typecheck": "tsc --noEmit",
|
|
29
23
|
"lint": "eslint src",
|
|
30
24
|
"clean": "rimraf dist .turbo"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@clicksmith/core": "workspace:*",
|
|
28
|
+
"zod": "^3.23.8"
|
|
31
29
|
}
|
|
32
|
-
}
|
|
30
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 ClickSmith contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|