/** * Shared utilities for platform configurators. * * Extracted here to avoid circular dependencies (index.ts imports configurators, * configurators cannot import from index.ts). */ import type { TemplateContext } from "../types/ai-tools.js"; export declare function setResolvedPythonCommand(cmd: string): void; /** Test helper — clear the resolved cache between unit tests. */ export declare function resetResolvedPythonCommand(): void; /** * Get the Python command for the host platform. * * Returns the resolved command if `setResolvedPythonCommand` has been called; * otherwise the static platform default — Windows: `python`, others: * `python3`. Pass an explicit `platform` arg only for unit tests (it bypasses * the resolved cache). */ export declare function getPythonCommandForPlatform(platform?: NodeJS.Platform): string; /** * Replace literal `python3` with the resolved Python command, excluding * shebang lines. * * Applied at init/update write time so that all file types (including .py, * .md, .toml, .json) get the correct command for the host platform without * template-level changes. * * No-op when the resolved command is `python3` (the template default). * Idempotent: running it twice produces the same result. */ export declare function replacePythonCommandLiterals(content: string): string; export declare function resolvePlaceholders(content: string, context?: TemplateContext): string; /** * Resolve placeholders for files written under `.agents/skills/` (the shared * Agent Skills directory consumed by multiple platforms via the upstream * `.agents/skills/` workspace alias — Codex, Gemini CLI 0.40+, etc.). * * Identical to {@link resolvePlaceholders} except that {@link CMD_REF} is * rendered in a platform-neutral form (`` `name` (Trellis command) ``) * instead of substituting a platform-specific prefix. This is the only * placeholder that varies between platforms in the 5 shared workflow skills * (`brainstorm`, `before-dev`, `check`, `break-loop`, `update-spec`), so * neutralizing it makes the rendered SKILL.md files byte-identical regardless * of which Trellis configurator wrote them — eliminating the * "last-writer-wins" collision when both Codex and Gemini target * `.agents/skills/`. * * `{{CLI_FLAG}}`, `{{EXECUTOR_AI}}`, `{{USER_ACTION_LABEL}}`, conditionals, * and `{{PYTHON_CMD}}` are still resolved from the platform context. The 5 * shared skills do not use those placeholders, so they remain platform- * neutral. Codex-only skill files (e.g. `trellis-continue/SKILL.md`, * `trellis-finish-work/SKILL.md` written via `resolveAllAsSkillsNeutral`) DO * use `{{CLI_FLAG}}` / `{{PYTHON_CMD}}` and resolve to Codex-correct values * — no other platform writes those files, so byte-identity is not required. */ export declare function resolvePlaceholdersNeutral(content: string, context?: TemplateContext): string; /** * Wrap resolved template content with YAML frontmatter for skill format. * Used by platforms that use SKILL.md (Codex, Kiro, Qoder, etc.). */ export declare function wrapWithSkillFrontmatter(name: string, content: string): string; /** Wrap resolved command content with YAML frontmatter (name + description). */ export declare function wrapWithCommandFrontmatter(name: string, content: string): string; /** A resolved template ready to be written to disk. */ export interface ResolvedTemplate { name: string; content: string; } /** A resolved file inside a multi-file skill directory. */ export interface ResolvedSkillFile { /** POSIX path relative to the skills root, e.g. "trellis-meta/SKILL.md" */ relativePath: string; content: string; } /** * Resolve ALL templates as skills with trellis- prefix. * Used by skill-only platforms (Kiro, Qoder, Codex) where everything is a skill. * * `start` is filtered out on agent-capable platforms — the session-start hook * injects the workflow overview instead. */ export declare function resolveAllAsSkills(ctx: TemplateContext): ResolvedTemplate[]; /** * Resolve command templates as plain commands (no wrapping). * Used by "both" platforms for the user-ritual commands. * * `start` is filtered out on agent-capable platforms. */ export declare function resolveCommands(ctx: TemplateContext): ResolvedTemplate[]; /** * Resolve the auto-triggered skill templates with trellis- prefix + SKILL.md frontmatter. * Used by "both" platforms for the auto-triggered skills. */ export declare function resolveSkills(ctx: TemplateContext): ResolvedTemplate[]; /** * Same as {@link resolveSkills} but uses {@link resolvePlaceholdersNeutral} * so the rendered SKILL.md files are byte-identical across any two platforms * that target `.agents/skills/`. Use this for shared `.agents/skills/` * writes (Gemini); platform-private skill roots should keep * {@link resolveSkills}. */ export declare function resolveSkillsNeutral(ctx: TemplateContext): ResolvedTemplate[]; /** * Same as {@link resolveAllAsSkills} but uses * {@link resolvePlaceholdersNeutral} for the shared skills. Command templates * folded into the skill set still resolve `{{CLI_FLAG}}` / `{{PYTHON_CMD}}` * per platform — only Codex writes those files into `.agents/skills/`, so * byte-identity isn't required there. */ export declare function resolveAllAsSkillsNeutral(ctx: TemplateContext): ResolvedTemplate[]; /** * Codex needs a `trellis-start` skill in `.agents/skills/` so the * `` notice from `inject-workflow-state.py` resolves * to an actual skill file (the bootstrap notice tells the AI to invoke * `$trellis-start` once on the first `no_task` turn — added in 0.5.5 * after the Codex SessionStart hook was removed for de-recursion). * * Built from `common/commands/start.md` + skill frontmatter; renders * neutrally so init and update produce byte-identical output. Returns * `null` if the template is missing (defensive — should never happen). * * Used by both `configureCodex()` (init path, file write) and * `collectPlatformTemplates.codex` (update path, manifest map). Both * paths must agree, otherwise upgraded users miss the file (which broke * 0.4.x → 0.5.5/0.5.6 upgrades — see #247-style symptom: AI reports * "no .agents/skills/trellis-start/SKILL.md" because update only ran * `collectTemplates` and never wrote the file). */ export declare function resolveCodexTrellisStartSkill(ctx: TemplateContext): ResolvedTemplate | null; /** * Resolve multi-file built-in skills. * * Unlike workflow skills, bundled skills already contain their own SKILL.md * frontmatter and may include references/assets. They are still rendered * through placeholder resolution so init and update get byte-identical output. */ export declare function resolveBundledSkills(ctx: TemplateContext): ResolvedSkillFile[]; /** Collect skill files under a target root for update hash tracking. */ export declare function collectSkillTemplates(skillsRoot: string, skills: readonly { name: string; content: string; }[], bundledSkills?: readonly ResolvedSkillFile[]): Map; /** Write skill directories from resolved templates and bundled skill files. */ export declare function writeSkills(skillsRoot: string, skills: { name: string; content: string; }[], bundledSkills?: readonly ResolvedSkillFile[]): Promise; /** Write agent/droid definition files */ export declare function writeAgents(agentsDir: string, agents: { name: string; content: string; }[], ext?: string): Promise; /** Write the shared hook scripts that `platform` actually registers. */ export declare function writeSharedHooks(hooksDir: string, platform: import("../templates/shared-hooks/index.js").SharedHookPlatform): Promise; export type SubAgentType = "implement" | "check"; /** Build the standard "load Trellis context first" prelude block. */ export declare function buildPullBasedPrelude(agentType: SubAgentType): string; /** Insert prelude into a markdown agent definition (after YAML frontmatter). */ export declare function injectPullBasedPreludeMarkdown(content: string, agentType: SubAgentType): string; /** Insert prelude into a TOML agent (codex `developer_instructions`). */ export declare function injectPullBasedPreludeToml(content: string, agentType: SubAgentType): string; /** Best-effort detect agent type from filename ("trellis-implement.md" → "implement"). * Returns null for research and unknown names — they skip the prelude. */ export declare function detectSubAgentType(name: string): SubAgentType | null; /** Shared transform: given a list of agents, prepend pull-based prelude to * implement/check definitions. Used by both configurator (init-time write) * and collectPlatformTemplates (update-time hash comparison) so the two * code paths always agree on what's on disk. */ export interface AgentContent { name: string; content: string; } export declare function applyPullBasedPreludeMarkdown(agents: readonly AgentContent[]): AgentContent[]; export declare function normalizeCopilotMarkdownAgents(agents: readonly AgentContent[]): AgentContent[]; export declare function applyPullBasedPreludeToml(agents: readonly AgentContent[]): AgentContent[]; //# sourceMappingURL=shared.d.ts.map