dryai 2.1.0 → 3.0.0

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.
Files changed (47) hide show
  1. package/README.md +140 -122
  2. package/dest/cli.d.ts +68 -0
  3. package/dest/cli.js +147 -0
  4. package/dest/commands/skills/add.d.ts +4 -3
  5. package/dest/commands/skills/add.js +44 -12
  6. package/dest/commands/skills/index.d.ts +3 -3
  7. package/dest/commands/skills/index.js +19 -12
  8. package/dest/commands/skills/list.d.ts +2 -2
  9. package/dest/commands/skills/list.js +4 -3
  10. package/dest/commands/skills/rehash-all.d.ts +2 -2
  11. package/dest/commands/skills/rehash-all.js +6 -5
  12. package/dest/commands/skills/rehash.d.ts +2 -2
  13. package/dest/commands/skills/rehash.js +3 -2
  14. package/dest/commands/skills/remove.d.ts +2 -2
  15. package/dest/commands/skills/remove.js +3 -2
  16. package/dest/commands/skills/update-all.d.ts +2 -2
  17. package/dest/commands/skills/update-all.js +8 -7
  18. package/dest/commands/skills/update.d.ts +2 -2
  19. package/dest/commands/skills/update.js +6 -5
  20. package/dest/commands/sync.d.ts +6 -0
  21. package/dest/commands/sync.js +8 -0
  22. package/dest/lib/agent-definition-helpers.d.ts +74 -0
  23. package/dest/lib/agent-definition-helpers.js +68 -0
  24. package/dest/lib/agent-definitions.d.ts +333 -0
  25. package/dest/lib/agent-definitions.js +301 -0
  26. package/dest/lib/agent-types.d.ts +46 -0
  27. package/dest/lib/agent-types.js +1 -0
  28. package/dest/lib/agents.d.ts +81 -0
  29. package/dest/lib/agents.js +301 -0
  30. package/dest/lib/command-options.d.ts +1 -1
  31. package/dest/lib/command-options.js +1 -1
  32. package/dest/lib/context.d.ts +8 -25
  33. package/dest/lib/context.js +8 -26
  34. package/dest/lib/frontmatter.d.ts +27 -70
  35. package/dest/lib/frontmatter.js +23 -42
  36. package/dest/lib/object-helpers.d.ts +5 -0
  37. package/dest/lib/object-helpers.js +6 -0
  38. package/dest/lib/skills.d.ts +35 -93
  39. package/dest/lib/skills.js +66 -8
  40. package/dest/lib/sync.d.ts +7 -0
  41. package/dest/lib/sync.js +503 -0
  42. package/dest/main.js +6 -86
  43. package/package.json +3 -3
  44. package/dest/commands/install.d.ts +0 -3
  45. package/dest/commands/install.js +0 -4
  46. package/dest/lib/install.d.ts +0 -8
  47. package/dest/lib/install.js +0 -380
@@ -1,11 +1,11 @@
1
1
  import { Command } from 'commander';
2
- import { type AgentsContext } from '../../lib/context.js';
2
+ import type { CommandEnv } from '../../cli.js';
3
3
  /**
4
4
  * Registers the managed skills command tree on the parent CLI program.
5
5
  */
6
6
  export declare function addSkillsCommand(input: {
7
- parent: Command;
7
+ program: Command;
8
8
  commandName: string;
9
- resolveContext: () => AgentsContext;
9
+ resolveEnv: () => CommandEnv;
10
10
  }): Command;
11
11
  //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,6 @@
1
1
  import { Command } from 'commander';
2
2
  import dedent from 'dedent';
3
3
  import { z } from 'zod';
4
- import { nonEmptyOptionStringSchema, parseOptionsObject, parseOptionValue, } from '../../lib/command-options.js';
5
- import {} from '../../lib/context.js';
6
4
  import { runSkillsAddCommand } from './add.js';
7
5
  import { runSkillsListCommand } from './list.js';
8
6
  import { runSkillsRehashAllCommand } from './rehash-all.js';
@@ -10,10 +8,12 @@ import { runSkillsRehashCommand } from './rehash.js';
10
8
  import { runSkillsRemoveCommand } from './remove.js';
11
9
  import { runSkillsUpdateAllCommand } from './update-all.js';
12
10
  import { runSkillsUpdateCommand } from './update.js';
11
+ import { nonEmptyOptionStringSchema, parseOptionsObject, parseOptionValue, } from '../../lib/command-options.js';
13
12
  const skillsImportOptionsSchema = z.object({
14
13
  skill: z.array(z.string()).optional(),
15
14
  as: nonEmptyOptionStringSchema.optional(),
16
15
  pin: z.boolean().optional().default(false),
16
+ path: nonEmptyOptionStringSchema.optional(),
17
17
  ref: nonEmptyOptionStringSchema.optional(),
18
18
  });
19
19
  const skillsUpdateOptionsSchema = z.object({
@@ -23,8 +23,8 @@ const skillsUpdateOptionsSchema = z.object({
23
23
  * Registers the managed skills command tree on the parent CLI program.
24
24
  */
25
25
  export function addSkillsCommand(input) {
26
- const { parent, commandName, resolveContext } = input;
27
- const skills = parent
26
+ const { program, commandName, resolveEnv } = input;
27
+ const skills = program
28
28
  .command('skills')
29
29
  .description('Manage imported skills')
30
30
  .usage('<subcommand> [args]')
@@ -34,6 +34,8 @@ export function addSkillsCommand(input) {
34
34
  Examples:
35
35
  ${commandName} list
36
36
  ${commandName} add anthropics/skills --skill skill-creator
37
+ ${commandName} add anthropics/skills --path . --skill review-helper
38
+ ${commandName} add anthropics/skills --path tools --skill review-helper
37
39
  ${commandName} add vercel-labs/agent-skills --skill pr-review commit
38
40
  ${commandName} rehash skill-creator
39
41
  ${commandName} update skill-creator
@@ -45,12 +47,16 @@ export function addSkillsCommand(input) {
45
47
  .command('list')
46
48
  .description('List local skills')
47
49
  .action(async () => {
48
- await runSkillsListCommand(resolveContext());
50
+ await runSkillsListCommand(resolveEnv());
49
51
  });
50
52
  skills
51
53
  .command('add <repo>')
52
54
  .description('Add managed skills from a remote repository')
53
- .option('--skill <names...>', 'Import one or more skills from the repository root skills/ directory')
55
+ .option('--skill <names...>', 'Import one or more skills by directory name')
56
+ .option('--path <repoPath>', 'Resolve each --skill from a different repository subdirectory; use . for the repository root instead of the default skills/ directory', parseOptionValue({
57
+ schema: nonEmptyOptionStringSchema,
58
+ optionLabel: '--path',
59
+ }))
54
60
  .option('--as <name>', 'Store the imported skill under a different local managed name', parseOptionValue({
55
61
  schema: nonEmptyOptionStringSchema,
56
62
  optionLabel: '--as',
@@ -66,8 +72,9 @@ export function addSkillsCommand(input) {
66
72
  options,
67
73
  optionsLabel: 'skills add options',
68
74
  });
69
- await runSkillsAddCommand(resolveContext(), {
75
+ await runSkillsAddCommand(resolveEnv(), {
70
76
  repo,
77
+ repoPath: parsedOptions.path,
71
78
  skillNames: parsedOptions.skill ?? [],
72
79
  asName: parsedOptions.as,
73
80
  pin: parsedOptions.pin,
@@ -78,19 +85,19 @@ export function addSkillsCommand(input) {
78
85
  .command('remove <name>')
79
86
  .description('Remove a managed skill')
80
87
  .action(async (skillName) => {
81
- await runSkillsRemoveCommand(resolveContext(), { skillName });
88
+ await runSkillsRemoveCommand(resolveEnv(), { skillName });
82
89
  });
83
90
  skills
84
91
  .command('rehash <name>')
85
92
  .description('Refresh stored file hashes for one managed skill')
86
93
  .action(async (skillName) => {
87
- await runSkillsRehashCommand(resolveContext(), { skillName });
94
+ await runSkillsRehashCommand(resolveEnv(), { skillName });
88
95
  });
89
96
  skills
90
97
  .command('rehash-all')
91
98
  .description('Refresh stored file hashes for all managed skills')
92
99
  .action(async () => {
93
- await runSkillsRehashAllCommand(resolveContext());
100
+ await runSkillsRehashAllCommand(resolveEnv());
94
101
  });
95
102
  skills
96
103
  .command('update <name>')
@@ -102,7 +109,7 @@ export function addSkillsCommand(input) {
102
109
  options,
103
110
  optionsLabel: 'skills update options',
104
111
  });
105
- await runSkillsUpdateCommand(resolveContext(), {
112
+ await runSkillsUpdateCommand(resolveEnv(), {
106
113
  force: parsedOptions.force,
107
114
  skillName,
108
115
  });
@@ -117,7 +124,7 @@ export function addSkillsCommand(input) {
117
124
  options,
118
125
  optionsLabel: 'skills update-all options',
119
126
  });
120
- await runSkillsUpdateAllCommand(resolveContext(), {
127
+ await runSkillsUpdateAllCommand(resolveEnv(), {
121
128
  force: parsedOptions.force,
122
129
  });
123
130
  });
@@ -1,6 +1,6 @@
1
- import type { AgentsContext } from '../../lib/context.js';
1
+ import type { CommandEnv } from '../../cli.js';
2
2
  /**
3
3
  * Lists local skills and annotates which ones are managed by the lockfile.
4
4
  */
5
- export declare function runSkillsListCommand(context: AgentsContext): Promise<void>;
5
+ export declare function runSkillsListCommand(env: CommandEnv): Promise<void>;
6
6
  //# sourceMappingURL=list.d.ts.map
@@ -2,7 +2,8 @@ import { ensureSkillsRoot, findManagedSkill, formatManagedSkillSummary, listLoca
2
2
  /**
3
3
  * Lists local skills and annotates which ones are managed by the lockfile.
4
4
  */
5
- export async function runSkillsListCommand(context) {
5
+ export async function runSkillsListCommand(env) {
6
+ const { context, runtime } = env;
6
7
  await ensureSkillsRoot(context);
7
8
  const [localSkillDirectories, lockfile] = await Promise.all([
8
9
  listLocalSkillDirectories(context),
@@ -19,8 +20,8 @@ export async function runSkillsListCommand(context) {
19
20
  .map((managedSkill) => `- ${formatManagedSkillSummary(managedSkill)} missing-local-directory`);
20
21
  const outputLines = [...localSkillLines, ...missingManagedLines];
21
22
  if (outputLines.length === 0) {
22
- console.log('No local skills found.');
23
+ runtime.logInfo('No local skills found.');
23
24
  return;
24
25
  }
25
- console.log(outputLines.join('\n'));
26
+ runtime.logInfo(outputLines.join('\n'));
26
27
  }
@@ -1,6 +1,6 @@
1
- import type { AgentsContext } from '../../lib/context.js';
1
+ import type { CommandEnv } from '../../cli.js';
2
2
  /**
3
3
  * Refreshes the stored file hashes for every managed skill using current local directory contents.
4
4
  */
5
- export declare function runSkillsRehashAllCommand(context: AgentsContext): Promise<void>;
5
+ export declare function runSkillsRehashAllCommand(env: CommandEnv): Promise<void>;
6
6
  //# sourceMappingURL=rehash-all.d.ts.map
@@ -3,10 +3,11 @@ import { computeDirectoryHashes, createUpdatedSkillRecord, formatManagedSkillSum
3
3
  /**
4
4
  * Refreshes the stored file hashes for every managed skill using current local directory contents.
5
5
  */
6
- export async function runSkillsRehashAllCommand(context) {
6
+ export async function runSkillsRehashAllCommand(env) {
7
+ const { context, runtime } = env;
7
8
  let lockfile = await loadSkillsLockfile(context);
8
9
  if (lockfile.skills.length === 0) {
9
- console.log('No managed skills to rehash.');
10
+ runtime.logInfo('No managed skills to rehash.');
10
11
  return;
11
12
  }
12
13
  const rehashedLines = [];
@@ -31,12 +32,12 @@ export async function runSkillsRehashAllCommand(context) {
31
32
  }
32
33
  await saveSkillsLockfile(context, { lockfile });
33
34
  if (rehashedLines.length > 0) {
34
- console.log(`Rehashed ${rehashedLines.length} managed skills:\n${rehashedLines.join('\n')}`);
35
+ runtime.logInfo(`Rehashed ${rehashedLines.length} managed skills:\n${rehashedLines.join('\n')}`);
35
36
  }
36
37
  else {
37
- console.log('No managed skills were rehashed.');
38
+ runtime.logInfo('No managed skills were rehashed.');
38
39
  }
39
40
  if (skippedLines.length > 0) {
40
- console.warn(`Skipped ${skippedLines.length} managed skills because the local directory is missing:\n${skippedLines.join('\n')}`);
41
+ runtime.logWarn(`Skipped ${skippedLines.length} managed skills because the local directory is missing:\n${skippedLines.join('\n')}`);
41
42
  }
42
43
  }
@@ -1,8 +1,8 @@
1
- import type { AgentsContext } from '../../lib/context.js';
1
+ import type { CommandEnv } from '../../cli.js';
2
2
  /**
3
3
  * Refreshes the stored file hashes for one managed skill using the current local directory contents.
4
4
  */
5
- export declare function runSkillsRehashCommand(context: AgentsContext, input: {
5
+ export declare function runSkillsRehashCommand(env: CommandEnv, input: {
6
6
  skillName: string;
7
7
  }): Promise<void>;
8
8
  //# sourceMappingURL=rehash.d.ts.map
@@ -3,7 +3,8 @@ import { computeDirectoryHashes, createUpdatedSkillRecord, findManagedSkill, for
3
3
  /**
4
4
  * Refreshes the stored file hashes for one managed skill using the current local directory contents.
5
5
  */
6
- export async function runSkillsRehashCommand(context, input) {
6
+ export async function runSkillsRehashCommand(env, input) {
7
+ const { context, runtime } = env;
7
8
  const { skillName } = input;
8
9
  const lockfile = await loadSkillsLockfile(context);
9
10
  const managedSkill = findManagedSkill(lockfile, { name: skillName });
@@ -24,5 +25,5 @@ export async function runSkillsRehashCommand(context, input) {
24
25
  await saveSkillsLockfile(context, {
25
26
  lockfile: upsertManagedSkill(lockfile, { updatedSkill }),
26
27
  });
27
- console.log(`Rehashed ${formatManagedSkillSummary(updatedSkill)}`);
28
+ runtime.logInfo(`Rehashed ${formatManagedSkillSummary(updatedSkill)}`);
28
29
  }
@@ -1,8 +1,8 @@
1
- import type { AgentsContext } from '../../lib/context.js';
1
+ import type { CommandEnv } from '../../cli.js';
2
2
  /**
3
3
  * Removes a managed skill from the local directory and updates the lockfile.
4
4
  */
5
- export declare function runSkillsRemoveCommand(context: AgentsContext, input: {
5
+ export declare function runSkillsRemoveCommand(env: CommandEnv, input: {
6
6
  skillName: string;
7
7
  }): Promise<void>;
8
8
  //# sourceMappingURL=remove.d.ts.map
@@ -2,7 +2,8 @@ import { findManagedSkill, formatManagedSkillSummary, loadSkillsLockfile, remove
2
2
  /**
3
3
  * Removes a managed skill from the local directory and updates the lockfile.
4
4
  */
5
- export async function runSkillsRemoveCommand(context, input) {
5
+ export async function runSkillsRemoveCommand(env, input) {
6
+ const { context, runtime } = env;
6
7
  const { skillName } = input;
7
8
  const lockfile = await loadSkillsLockfile(context);
8
9
  const managedSkill = findManagedSkill(lockfile, { name: skillName });
@@ -13,5 +14,5 @@ export async function runSkillsRemoveCommand(context, input) {
13
14
  await saveSkillsLockfile(context, {
14
15
  lockfile: removeManagedSkill(lockfile, { name: skillName }),
15
16
  });
16
- console.log(`Removed ${formatManagedSkillSummary(managedSkill)}`);
17
+ runtime.logInfo(`Removed ${formatManagedSkillSummary(managedSkill)}`);
17
18
  }
@@ -1,8 +1,8 @@
1
- import type { AgentsContext } from '../../lib/context.js';
1
+ import type { CommandEnv } from '../../cli.js';
2
2
  /**
3
3
  * Updates every managed skill from its tracked remote source and saves the refreshed lockfile.
4
4
  */
5
- export declare function runSkillsUpdateAllCommand(context: AgentsContext, input: {
5
+ export declare function runSkillsUpdateAllCommand(env: CommandEnv, input: {
6
6
  force: boolean;
7
7
  }): Promise<void>;
8
8
  //# sourceMappingURL=update-all.d.ts.map
@@ -1,11 +1,12 @@
1
- import { computeDirectoryHashes, createUpdatedSkillRecord, detectLocalSkillEdits, fetchRemoteSkillSnapshot, formatManagedSkillSummary, getManagedSkillDirectory, loadSkillsLockfile, replaceManagedSkillDirectory, saveSkillsLockfile, timestampNow, upsertManagedSkill, } from '../../lib/skills.js';
1
+ import { cleanupRemoteSkillSnapshot, computeDirectoryHashes, createUpdatedSkillRecord, detectLocalSkillEdits, fetchRemoteSkillSnapshot, formatManagedSkillSummary, getManagedSkillDirectory, loadSkillsLockfile, replaceManagedSkillDirectory, saveSkillsLockfile, timestampNow, upsertManagedSkill, } from '../../lib/skills.js';
2
2
  /**
3
3
  * Updates every managed skill from its tracked remote source and saves the refreshed lockfile.
4
4
  */
5
- export async function runSkillsUpdateAllCommand(context, input) {
5
+ export async function runSkillsUpdateAllCommand(env, input) {
6
+ const { context, runtime } = env;
6
7
  let lockfile = await loadSkillsLockfile(context);
7
8
  if (lockfile.skills.length === 0) {
8
- console.log('No managed skills to update.');
9
+ runtime.logInfo('No managed skills to update.');
9
10
  return;
10
11
  }
11
12
  const updatedLines = [];
@@ -43,17 +44,17 @@ export async function runSkillsUpdateAllCommand(context, input) {
43
44
  updatedLines.push(`- ${formatManagedSkillSummary(updatedSkill)}`);
44
45
  }
45
46
  finally {
46
- await snapshot.cleanup();
47
+ await cleanupRemoteSkillSnapshot(snapshot);
47
48
  }
48
49
  }
49
50
  await saveSkillsLockfile(context, { lockfile });
50
51
  if (updatedLines.length > 0) {
51
- console.log(`Updated ${updatedLines.length} managed skills:\n${updatedLines.join('\n')}`);
52
+ runtime.logInfo(`Updated ${updatedLines.length} managed skills:\n${updatedLines.join('\n')}`);
52
53
  }
53
54
  else {
54
- console.log('No managed skills were updated.');
55
+ runtime.logInfo('No managed skills were updated.');
55
56
  }
56
57
  if (skippedLines.length > 0) {
57
- console.warn(`Skipped ${skippedLines.length} managed skills due to local edits. Re-run with --force to overwrite local changes:\n${skippedLines.join('\n')}`);
58
+ runtime.logWarn(`Skipped ${skippedLines.length} managed skills due to local edits. Re-run with --force to overwrite local changes:\n${skippedLines.join('\n')}`);
58
59
  }
59
60
  }
@@ -1,8 +1,8 @@
1
- import type { AgentsContext } from '../../lib/context.js';
1
+ import type { CommandEnv } from '../../cli.js';
2
2
  /**
3
3
  * Updates one managed skill from its tracked remote source and refreshes the lockfile.
4
4
  */
5
- export declare function runSkillsUpdateCommand(context: AgentsContext, input: {
5
+ export declare function runSkillsUpdateCommand(env: CommandEnv, input: {
6
6
  force: boolean;
7
7
  skillName: string;
8
8
  }): Promise<void>;
@@ -1,8 +1,9 @@
1
- import { computeDirectoryHashes, createUpdatedSkillRecord, detectLocalSkillEdits, fetchRemoteSkillSnapshot, findManagedSkill, formatManagedSkillSummary, getManagedSkillDirectory, loadSkillsLockfile, replaceManagedSkillDirectory, saveSkillsLockfile, timestampNow, upsertManagedSkill, } from '../../lib/skills.js';
1
+ import { cleanupRemoteSkillSnapshot, computeDirectoryHashes, createUpdatedSkillRecord, detectLocalSkillEdits, fetchRemoteSkillSnapshot, findManagedSkill, formatManagedSkillSummary, getManagedSkillDirectory, loadSkillsLockfile, replaceManagedSkillDirectory, saveSkillsLockfile, timestampNow, upsertManagedSkill, } from '../../lib/skills.js';
2
2
  /**
3
3
  * Updates one managed skill from its tracked remote source and refreshes the lockfile.
4
4
  */
5
- export async function runSkillsUpdateCommand(context, input) {
5
+ export async function runSkillsUpdateCommand(env, input) {
6
+ const { context, runtime } = env;
6
7
  const { force, skillName } = input;
7
8
  const lockfile = await loadSkillsLockfile(context);
8
9
  const managedSkill = findManagedSkill(lockfile, { name: skillName });
@@ -15,7 +16,7 @@ export async function runSkillsUpdateCommand(context, input) {
15
16
  storedFiles: managedSkill.files,
16
17
  });
17
18
  if (localEditState.modified && !force) {
18
- console.warn(`Skipped ${skillName} because local edits were detected in: ${localEditState.changedFiles.join(', ')}. Re-run with --force to overwrite local changes.`);
19
+ runtime.logWarn(`Skipped ${skillName} because local edits were detected in: ${localEditState.changedFiles.join(', ')}. Re-run with --force to overwrite local changes.`);
19
20
  return;
20
21
  }
21
22
  const snapshot = await fetchRemoteSkillSnapshot({
@@ -38,9 +39,9 @@ export async function runSkillsUpdateCommand(context, input) {
38
39
  await saveSkillsLockfile(context, {
39
40
  lockfile: upsertManagedSkill(lockfile, { updatedSkill }),
40
41
  });
41
- console.log(`Updated ${formatManagedSkillSummary(updatedSkill)}`);
42
+ runtime.logInfo(`Updated ${formatManagedSkillSummary(updatedSkill)}`);
42
43
  }
43
44
  finally {
44
- await snapshot.cleanup();
45
+ await cleanupRemoteSkillSnapshot(snapshot);
45
46
  }
46
47
  }
@@ -0,0 +1,6 @@
1
+ import type { CommandEnv } from '../cli.js';
2
+ /**
3
+ * Runs the sync command, writing all command, rule, and skill outputs into their agent target directories.
4
+ */
5
+ export declare function runSyncCommand(env: CommandEnv): Promise<void>;
6
+ //# sourceMappingURL=sync.d.ts.map
@@ -0,0 +1,8 @@
1
+ import { syncToTargets } from '../lib/sync.js';
2
+ /**
3
+ * Runs the sync command, writing all command, rule, and skill outputs into their agent target directories.
4
+ */
5
+ export async function runSyncCommand(env) {
6
+ const { context, runtime } = env;
7
+ await syncToTargets(context, runtime);
8
+ }
@@ -0,0 +1,74 @@
1
+ import { z } from 'zod';
2
+ import type { OwnershipKeyInput } from './agent-types.js';
3
+ type CreateTargetPathInput<TargetRoots> = {
4
+ targetRoots: TargetRoots;
5
+ itemName: string;
6
+ sourceFileStem: string;
7
+ };
8
+ type BuildTargetInput<Input, TargetRoots> = {
9
+ targetRoots: TargetRoots;
10
+ input: Input;
11
+ };
12
+ type AgentFrontmatterSectionEnv<SyncItemSpec> = {
13
+ currentInput: SyncItemSpec;
14
+ sectionValues: ReadonlyMap<string, unknown>;
15
+ };
16
+ /**
17
+ * Defines the ownership key namespace for one agent output type, providing a typed prefix and key-derivation functions.
18
+ */
19
+ export declare function defineOwnershipKey<Prefix extends string>(input: {
20
+ prefix: Prefix;
21
+ descriptionLabel: string;
22
+ selectSuffix: (value: OwnershipKeyInput) => string;
23
+ }): {
24
+ prefix: Prefix;
25
+ descriptionLabel: string;
26
+ createKey: (value: string) => `${Prefix}${string}`;
27
+ createKeyForInput: (value: OwnershipKeyInput) => `${Prefix}${string}`;
28
+ };
29
+ /**
30
+ * Defines a strict Zod schema and a `create` method for building validated frontmatter metadata objects.
31
+ */
32
+ export declare function defineMetadata<Input, Shape extends z.ZodRawShape>(input: {
33
+ shape: Shape;
34
+ buildMetadata: (value: Input) => Record<string, unknown>;
35
+ }): {
36
+ schema: z.ZodObject<Shape, z.core.$strict>;
37
+ create: (value: Input) => z.output<z.ZodObject<Shape, z.core.$strict>>;
38
+ };
39
+ /**
40
+ * Defines how to compute the outputPath and writePath for a sync target from target roots and source file metadata.
41
+ */
42
+ export declare function defineOutputPathCreators<TargetRoots>(input: {
43
+ createTargetPath: (value: CreateTargetPathInput<TargetRoots>) => string;
44
+ createWritePath?: (targetPath: string) => string;
45
+ }): {
46
+ createTargetPath: (value: CreateTargetPathInput<TargetRoots>) => string;
47
+ createWritePath: (targetPath: string) => string;
48
+ };
49
+ /**
50
+ * Wraps a typed buildTarget function for use in an agent's sync target definition.
51
+ */
52
+ export declare function defineTarget<Input, Target, TargetRoots = unknown>(input: {
53
+ buildTarget: (value: BuildTargetInput<Input, TargetRoots>) => Target;
54
+ }): {
55
+ buildTarget: (value: BuildTargetInput<Input, TargetRoots>) => Target;
56
+ };
57
+ /**
58
+ * Defines a validated frontmatter section that parses its value with a Zod schema and merges extra fields into the sync input.
59
+ */
60
+ export declare function defineAgentFrontmatterSection<Section, SyncItemSpec extends Record<string, unknown>>(input: {
61
+ schema: z.ZodType<Section>;
62
+ extendSyncInput: (value: Section, context: AgentFrontmatterSectionEnv<SyncItemSpec>) => Partial<SyncItemSpec>;
63
+ }): {
64
+ schema: z.ZodType<Section>;
65
+ createSyncInputExtension: (value: unknown, context: AgentFrontmatterSectionEnv<SyncItemSpec>) => {
66
+ success: true;
67
+ data: Partial<SyncItemSpec>;
68
+ } | {
69
+ success: false;
70
+ issues: readonly z.ZodIssue[];
71
+ };
72
+ };
73
+ export {};
74
+ //# sourceMappingURL=agent-definition-helpers.d.ts.map
@@ -0,0 +1,68 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Defines the ownership key namespace for one agent output type, providing a typed prefix and key-derivation functions.
4
+ */
5
+ export function defineOwnershipKey(input) {
6
+ return {
7
+ prefix: input.prefix,
8
+ descriptionLabel: input.descriptionLabel,
9
+ createKey(value) {
10
+ return `${input.prefix}${value}`;
11
+ },
12
+ createKeyForInput(value) {
13
+ return `${input.prefix}${input.selectSuffix(value)}`;
14
+ },
15
+ };
16
+ }
17
+ /**
18
+ * Defines a strict Zod schema and a `create` method for building validated frontmatter metadata objects.
19
+ */
20
+ export function defineMetadata(input) {
21
+ const schema = z.strictObject(input.shape);
22
+ return {
23
+ schema,
24
+ create(value) {
25
+ return schema.parse(input.buildMetadata(value));
26
+ },
27
+ };
28
+ }
29
+ /**
30
+ * Defines how to compute the outputPath and writePath for a sync target from target roots and source file metadata.
31
+ */
32
+ export function defineOutputPathCreators(input) {
33
+ return {
34
+ createTargetPath: input.createTargetPath,
35
+ createWritePath(targetPath) {
36
+ return input.createWritePath?.(targetPath) ?? targetPath;
37
+ },
38
+ };
39
+ }
40
+ /**
41
+ * Wraps a typed buildTarget function for use in an agent's sync target definition.
42
+ */
43
+ export function defineTarget(input) {
44
+ return {
45
+ buildTarget: input.buildTarget,
46
+ };
47
+ }
48
+ /**
49
+ * Defines a validated frontmatter section that parses its value with a Zod schema and merges extra fields into the sync input.
50
+ */
51
+ export function defineAgentFrontmatterSection(input) {
52
+ return {
53
+ schema: input.schema,
54
+ createSyncInputExtension(value, context) {
55
+ const result = input.schema.safeParse(value);
56
+ if (!result.success) {
57
+ return {
58
+ success: false,
59
+ issues: result.error.issues,
60
+ };
61
+ }
62
+ return {
63
+ success: true,
64
+ data: input.extendSyncInput(result.data, context),
65
+ };
66
+ },
67
+ };
68
+ }