dryai 2.2.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 +25 -21
  2. package/dest/cli.d.ts +68 -0
  3. package/dest/cli.js +147 -0
  4. package/dest/commands/skills/add.d.ts +2 -2
  5. package/dest/commands/skills/add.js +23 -7
  6. package/dest/commands/skills/index.d.ts +3 -3
  7. package/dest/commands/skills/index.js +10 -11
  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 +17 -93
  39. package/dest/lib/skills.js +25 -7
  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
@@ -0,0 +1,301 @@
1
+ import path from 'node:path';
2
+ import { z } from 'zod';
3
+ import { defineAgentFrontmatterSection, defineMetadata, defineOutputPathCreators, defineOwnershipKey, defineTarget, } from './agent-definition-helpers.js';
4
+ import { compactObject } from './object-helpers.js';
5
+ const nonEmptyStringSchema = z.string().trim().min(1);
6
+ /**
7
+ * The central sync agent registry, mapping each agent name to its command, rule, and skill definitions.
8
+ */
9
+ export const AGENT_DEFINITIONS = {
10
+ copilot: {
11
+ displayLabel: 'Copilot',
12
+ targetRoots: {
13
+ prompts: ['.copilot', 'prompts'],
14
+ instructions: ['.copilot', 'instructions'],
15
+ skills: ['.copilot', 'skills'],
16
+ },
17
+ command: (() => {
18
+ const outputPathCreators = defineOutputPathCreators({
19
+ createTargetPath: ({ targetRoots, sourceFileStem }) => path.join(targetRoots.copilot.prompts, `${sourceFileStem}.prompt.md`),
20
+ });
21
+ const frontmatterSectionSchema = z.strictObject({}).optional();
22
+ const metadata = defineMetadata({
23
+ shape: {
24
+ name: z.string().min(1),
25
+ description: z.string().min(1),
26
+ },
27
+ buildMetadata: (value) => compactObject({
28
+ name: value.name,
29
+ description: value.description,
30
+ }),
31
+ });
32
+ return {
33
+ frontmatterSection: defineAgentFrontmatterSection({
34
+ schema: frontmatterSectionSchema,
35
+ extendSyncInput: () => ({}),
36
+ }),
37
+ ownershipKey: defineOwnershipKey({
38
+ prefix: 'copilot:prompt-path:',
39
+ descriptionLabel: 'Copilot prompt output',
40
+ selectSuffix: (value) => value.outputPath,
41
+ }),
42
+ outputPathCreators,
43
+ metadata,
44
+ target: defineTarget({
45
+ buildTarget: ({ targetRoots, input, }) => {
46
+ const outputPath = outputPathCreators.createTargetPath({
47
+ targetRoots,
48
+ itemName: input.name,
49
+ sourceFileStem: input.sourceFileStem,
50
+ });
51
+ return {
52
+ agent: 'copilot',
53
+ body: input.body,
54
+ metadata: metadata.create({
55
+ name: input.name,
56
+ description: input.description,
57
+ }),
58
+ outputPath,
59
+ targetType: 'markdown',
60
+ writePath: outputPath,
61
+ };
62
+ },
63
+ }),
64
+ };
65
+ })(),
66
+ rule: (() => {
67
+ const outputPathCreators = defineOutputPathCreators({
68
+ createTargetPath: ({ targetRoots, sourceFileStem }) => path.join(targetRoots.copilot.instructions, `${sourceFileStem}.instructions.md`),
69
+ });
70
+ const frontmatterSectionSchema = z.strictObject({
71
+ applyTo: nonEmptyStringSchema,
72
+ });
73
+ const metadata = defineMetadata({
74
+ shape: {
75
+ description: z.string().min(1),
76
+ applyTo: z.string().min(1),
77
+ },
78
+ buildMetadata: (value) => compactObject({
79
+ description: value.description,
80
+ applyTo: value.applyTo,
81
+ }),
82
+ });
83
+ return {
84
+ frontmatterSection: defineAgentFrontmatterSection({
85
+ schema: frontmatterSectionSchema,
86
+ extendSyncInput: (value) => ({
87
+ applyTo: value.applyTo,
88
+ }),
89
+ }),
90
+ ownershipKey: defineOwnershipKey({
91
+ prefix: 'copilot:instruction-path:',
92
+ descriptionLabel: 'Copilot instruction output',
93
+ selectSuffix: (value) => value.outputPath,
94
+ }),
95
+ outputPathCreators,
96
+ metadata,
97
+ target: defineTarget({
98
+ buildTarget: ({ targetRoots, input, }) => {
99
+ const outputPath = outputPathCreators.createTargetPath({
100
+ targetRoots,
101
+ itemName: input.name,
102
+ sourceFileStem: input.sourceFileStem,
103
+ });
104
+ return {
105
+ agent: 'copilot',
106
+ body: input.body,
107
+ metadata: metadata.create({
108
+ description: input.description,
109
+ applyTo: input.applyTo,
110
+ }),
111
+ outputPath,
112
+ targetType: 'markdown',
113
+ writePath: outputPath,
114
+ };
115
+ },
116
+ }),
117
+ };
118
+ })(),
119
+ skill: (() => {
120
+ const outputPathCreators = defineOutputPathCreators({
121
+ createTargetPath: ({ targetRoots, itemName }) => path.join(targetRoots.copilot.skills, itemName),
122
+ });
123
+ return {
124
+ ownershipKey: defineOwnershipKey({
125
+ prefix: 'copilot:skill-name:',
126
+ descriptionLabel: 'Copilot skill name',
127
+ selectSuffix: (value) => value.name,
128
+ }),
129
+ outputPathCreators,
130
+ target: defineTarget({
131
+ buildTarget: ({ targetRoots, input, }) => ({
132
+ agent: 'copilot',
133
+ outputPath: outputPathCreators.createTargetPath({
134
+ targetRoots,
135
+ itemName: input.name,
136
+ sourceFileStem: input.name,
137
+ }),
138
+ sourceDir: input.sourceDir,
139
+ targetType: 'directory',
140
+ }),
141
+ }),
142
+ };
143
+ })(),
144
+ },
145
+ cursor: {
146
+ displayLabel: 'Cursor',
147
+ targetRoots: {
148
+ rules: ['.cursor', 'rules'],
149
+ skills: ['.cursor', 'skills'],
150
+ },
151
+ command: (() => {
152
+ const outputPathCreators = defineOutputPathCreators({
153
+ createTargetPath: ({ targetRoots, itemName }) => path.join(targetRoots.cursor.skills, itemName),
154
+ createWritePath: (targetPath) => path.join(targetPath, 'SKILL.md'),
155
+ });
156
+ const frontmatterSectionSchema = z
157
+ .strictObject({
158
+ 'disable-model-invocation': z.boolean().optional(),
159
+ })
160
+ .optional();
161
+ const metadata = defineMetadata({
162
+ shape: {
163
+ name: z.string().min(1),
164
+ description: z.string().min(1),
165
+ 'disable-model-invocation': z.boolean().optional(),
166
+ },
167
+ buildMetadata: (value) => compactObject({
168
+ name: value.name,
169
+ description: value.description,
170
+ 'disable-model-invocation': value.disableModelInvocation,
171
+ }),
172
+ });
173
+ return {
174
+ frontmatterSection: defineAgentFrontmatterSection({
175
+ schema: frontmatterSectionSchema,
176
+ extendSyncInput: (value) => ({
177
+ disableModelInvocation: value?.['disable-model-invocation'],
178
+ }),
179
+ }),
180
+ ownershipKey: defineOwnershipKey({
181
+ prefix: 'cursor:skill-name:',
182
+ descriptionLabel: 'Cursor skill name',
183
+ selectSuffix: (value) => value.name,
184
+ }),
185
+ outputPathCreators,
186
+ metadata,
187
+ target: defineTarget({
188
+ buildTarget: ({ targetRoots, input, }) => {
189
+ const outputPath = outputPathCreators.createTargetPath({
190
+ targetRoots,
191
+ itemName: input.name,
192
+ sourceFileStem: input.sourceFileStem,
193
+ });
194
+ return {
195
+ agent: 'cursor',
196
+ body: input.body,
197
+ metadata: metadata.create({
198
+ name: input.name,
199
+ description: input.description,
200
+ disableModelInvocation: input.disableModelInvocation,
201
+ }),
202
+ outputPath,
203
+ targetType: 'markdown',
204
+ writePath: outputPathCreators.createWritePath(outputPath),
205
+ };
206
+ },
207
+ }),
208
+ };
209
+ })(),
210
+ rule: (() => {
211
+ const outputPathCreators = defineOutputPathCreators({
212
+ createTargetPath: ({ targetRoots, sourceFileStem }) => path.join(targetRoots.cursor.rules, `${sourceFileStem}.mdc`),
213
+ });
214
+ const frontmatterSectionSchema = z
215
+ .strictObject({
216
+ alwaysApply: z.boolean().optional(),
217
+ globs: nonEmptyStringSchema.optional(),
218
+ })
219
+ .optional();
220
+ const metadata = defineMetadata({
221
+ shape: {
222
+ description: z.string().min(1),
223
+ globs: z.string().min(1).optional(),
224
+ alwaysApply: z.boolean(),
225
+ },
226
+ buildMetadata: (value) => compactObject({
227
+ description: value.description,
228
+ globs: value.globs,
229
+ alwaysApply: value.alwaysApply,
230
+ }),
231
+ });
232
+ return {
233
+ frontmatterSection: defineAgentFrontmatterSection({
234
+ schema: frontmatterSectionSchema,
235
+ extendSyncInput: (value, { currentInput }) => {
236
+ const scopedGlobs = value?.globs ?? currentInput.applyTo;
237
+ const alwaysApply = value?.alwaysApply ??
238
+ (scopedGlobs === undefined || scopedGlobs === '**');
239
+ return {
240
+ alwaysApply,
241
+ globs: alwaysApply ? undefined : scopedGlobs,
242
+ };
243
+ },
244
+ }),
245
+ ownershipKey: defineOwnershipKey({
246
+ prefix: 'cursor:rule-path:',
247
+ descriptionLabel: 'Cursor rule output',
248
+ selectSuffix: (value) => value.outputPath,
249
+ }),
250
+ outputPathCreators,
251
+ metadata,
252
+ target: defineTarget({
253
+ buildTarget: ({ targetRoots, input, }) => {
254
+ const outputPath = outputPathCreators.createTargetPath({
255
+ targetRoots,
256
+ itemName: input.name,
257
+ sourceFileStem: input.sourceFileStem,
258
+ });
259
+ return {
260
+ agent: 'cursor',
261
+ body: input.body,
262
+ metadata: metadata.create({
263
+ description: input.description,
264
+ globs: input.globs,
265
+ alwaysApply: input.alwaysApply,
266
+ }),
267
+ outputPath,
268
+ targetType: 'markdown',
269
+ writePath: outputPath,
270
+ };
271
+ },
272
+ }),
273
+ };
274
+ })(),
275
+ skill: (() => {
276
+ const outputPathCreators = defineOutputPathCreators({
277
+ createTargetPath: ({ targetRoots, itemName }) => path.join(targetRoots.cursor.skills, itemName),
278
+ });
279
+ return {
280
+ ownershipKey: defineOwnershipKey({
281
+ prefix: 'cursor:skill-name:',
282
+ descriptionLabel: 'Cursor skill name',
283
+ selectSuffix: (value) => value.name,
284
+ }),
285
+ outputPathCreators,
286
+ target: defineTarget({
287
+ buildTarget: ({ targetRoots, input, }) => ({
288
+ agent: 'cursor',
289
+ outputPath: outputPathCreators.createTargetPath({
290
+ targetRoots,
291
+ itemName: input.name,
292
+ sourceFileStem: input.name,
293
+ }),
294
+ sourceDir: input.sourceDir,
295
+ targetType: 'directory',
296
+ }),
297
+ }),
298
+ };
299
+ })(),
300
+ },
301
+ };
@@ -0,0 +1,46 @@
1
+ import type { TargetRoots } from './agents.js';
2
+ export declare const SYNC_ITEM_KINDS: readonly ["command", "rule", "skill"];
3
+ export type SyncItemKind = (typeof SYNC_ITEM_KINDS)[number];
4
+ export type OwnershipKeyInput = {
5
+ name: string;
6
+ outputPath: string;
7
+ };
8
+ export type AgentCmdSyncSpec = {
9
+ name: string;
10
+ description: string;
11
+ sourceFileStem: string;
12
+ body: string;
13
+ disableModelInvocation: boolean | undefined;
14
+ };
15
+ export type AgentRuleSyncSpec = {
16
+ name: string;
17
+ description: string;
18
+ sourceFileStem: string;
19
+ body: string;
20
+ applyTo: string;
21
+ globs: string | undefined;
22
+ alwaysApply: boolean;
23
+ };
24
+ export type AgentSkillSyncSpec = {
25
+ name: string;
26
+ sourceDir: string;
27
+ };
28
+ export type AgentSyncSpecByKind = {
29
+ command: AgentCmdSyncSpec;
30
+ rule: AgentRuleSyncSpec;
31
+ skill: AgentSkillSyncSpec;
32
+ };
33
+ export type SyncTargetSpec = {
34
+ kind: 'command';
35
+ input: AgentCmdSyncSpec;
36
+ targetRoots: TargetRoots;
37
+ } | {
38
+ kind: 'rule';
39
+ input: AgentRuleSyncSpec;
40
+ targetRoots: TargetRoots;
41
+ } | {
42
+ kind: 'skill';
43
+ input: AgentSkillSyncSpec;
44
+ targetRoots: TargetRoots;
45
+ };
46
+ //# sourceMappingURL=agent-types.d.ts.map
@@ -0,0 +1 @@
1
+ export const SYNC_ITEM_KINDS = ['command', 'rule', 'skill'];
@@ -0,0 +1,81 @@
1
+ import type { CLIRuntime } from '../cli.js';
2
+ import { AGENT_DEFINITIONS } from './agent-definitions.js';
3
+ import { type SyncTargetSpec, type AgentCmdSyncSpec, type OwnershipKeyInput, type AgentRuleSyncSpec, type SyncItemKind } from './agent-types.js';
4
+ import type { CommandFrontmatter, RuleFrontmatter } from './frontmatter.js';
5
+ export { AGENT_DEFINITIONS } from './agent-definitions.js';
6
+ export { SYNC_ITEM_KINDS, type SyncTargetSpec as BuildSyncTargetsInput, type AgentCmdSyncSpec as CommandSyncSource, type OwnershipKeyInput, type AgentRuleSyncSpec as RuleSyncSource, type AgentSkillSyncSpec as SkillSyncSource, type SyncItemKind, type AgentSyncSpecByKind as SyncSourceByKind, } from './agent-types.js';
7
+ export type SyncAgent = keyof typeof AGENT_DEFINITIONS;
8
+ export type TargetRoots = Record<string, Record<string, string>>;
9
+ /**
10
+ * Returns whether a string is a recognized sync agent name.
11
+ */
12
+ export declare function isSyncAgent(value: string): value is SyncAgent;
13
+ export declare const SYNC_AGENTS: ("copilot" | "cursor")[];
14
+ export type OwnershipKey = string;
15
+ export type SyncTarget = {
16
+ agent: string;
17
+ outputPath: string;
18
+ targetType: 'markdown';
19
+ body: string;
20
+ metadata: Record<string, unknown>;
21
+ writePath: string;
22
+ } | {
23
+ agent: string;
24
+ outputPath: string;
25
+ targetType: 'directory';
26
+ sourceDir: string;
27
+ };
28
+ export type MarkdownSyncTarget = Extract<SyncTarget, {
29
+ targetType: 'markdown';
30
+ }>;
31
+ export type DirectorySyncTarget = Extract<SyncTarget, {
32
+ targetType: 'directory';
33
+ }>;
34
+ export type SyncMarkdownMetadata = MarkdownSyncTarget['metadata'];
35
+ /**
36
+ * Builds the map of output root directory paths for every agent, each resolved relative to baseDir.
37
+ */
38
+ export declare function createTargetRoots(baseDir: string): TargetRoots;
39
+ /**
40
+ * Returns the display label used for one agent in user-facing sync reports.
41
+ */
42
+ export declare function getAgentLabel(agent: SyncAgent): string;
43
+ /**
44
+ * Returns the supported agent names joined as a natural English list.
45
+ */
46
+ export declare function describeSupportedAgents(): string;
47
+ /**
48
+ * Returns every output root directory path from the given TargetRoots map.
49
+ */
50
+ export declare function listTargetRootPaths(targetRoots: TargetRoots): string[];
51
+ /**
52
+ * Builds one sync target per supported agent for the given item kind and input.
53
+ */
54
+ export declare function buildSyncTargets(value: SyncTargetSpec): SyncTarget[];
55
+ /**
56
+ * Returns the ownership key for the given agent, item kind, and input.
57
+ */
58
+ export declare function createOwnershipKey(agent: SyncAgent, kind: SyncItemKind, value: OwnershipKeyInput): OwnershipKey;
59
+ /**
60
+ * Formats an ownership key as a human-readable phrase for use in warning messages.
61
+ */
62
+ export declare function describeOwnershipKey(ownershipKey: OwnershipKey): string;
63
+ /**
64
+ * Builds a CommandSyncSource from parsed command frontmatter. Returns null if any per-agent section fails validation.
65
+ */
66
+ export declare function createAgentCmdSyncSpec(runtime: CLIRuntime, input: {
67
+ filePath: string;
68
+ sourceFileStem: string;
69
+ body: string;
70
+ frontmatter: CommandFrontmatter;
71
+ }): AgentCmdSyncSpec | null;
72
+ /**
73
+ * Builds a RuleSyncSource from parsed rule frontmatter. Returns null if any per-agent section fails validation.
74
+ */
75
+ export declare function createAgentRuleSyncSpec(runtime: CLIRuntime, input: {
76
+ filePath: string;
77
+ sourceFileStem: string;
78
+ body: string;
79
+ frontmatter: RuleFrontmatter;
80
+ }): AgentRuleSyncSpec | null;
81
+ //# sourceMappingURL=agents.d.ts.map