@rbbtsn0w/adg 0.6.0 → 0.7.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 (83) hide show
  1. package/README.md +41 -9
  2. package/dist/bin/adg.js +4 -4
  3. package/dist/src/adapters/codex.js +12 -0
  4. package/dist/src/adapters/reverse.js +22 -1
  5. package/dist/src/agents/base.js +2 -1
  6. package/dist/src/agents/claude.js +52 -6
  7. package/dist/src/agents/codex.js +94 -14
  8. package/dist/src/cli/core-plugin-handlers.js +97 -0
  9. package/dist/src/cli/handlers.js +155 -210
  10. package/dist/src/cli/index.js +14 -4
  11. package/dist/src/codex-marketplace-migration.js +139 -0
  12. package/dist/src/commands/cache.js +92 -15
  13. package/dist/src/commands/inspect.js +41 -0
  14. package/dist/src/commands/install.js +140 -73
  15. package/dist/src/commands/link.js +4 -16
  16. package/dist/src/commands/marketplace.js +74 -20
  17. package/dist/src/commands/migrate.js +15 -3
  18. package/dist/src/commands/projection.js +15 -0
  19. package/dist/src/commands/select-components.js +12 -0
  20. package/dist/src/commands/state.js +4 -2
  21. package/dist/src/commands/sync.js +9 -15
  22. package/dist/src/commands/update.js +51 -10
  23. package/dist/src/commands/validate.js +9 -2
  24. package/dist/src/components.js +3 -0
  25. package/dist/src/default-dsl.js +142 -0
  26. package/dist/src/lock.js +25 -7
  27. package/dist/src/manifest.js +85 -4
  28. package/dist/src/materialize.js +5 -1
  29. package/dist/src/mcp.js +59 -0
  30. package/dist/src/paths.js +31 -4
  31. package/dist/src/render/plugins.js +7 -1
  32. package/dist/src/source-cache.js +140 -0
  33. package/dist/src/sources.js +76 -5
  34. package/dist/src/subprocess.js +53 -0
  35. package/dist/src/telemetry.js +28 -21
  36. package/dist/src/types.js +5 -1
  37. package/dist/vendor/skills/src/add.js +0 -15
  38. package/dist/vendor/skills/src/cli.js +6 -1
  39. package/dist/vendor/skills/src/git-tree.js +4 -4
  40. package/dist/vendor/skills/src/skill-lock.js +4 -3
  41. package/dist/vendor/skills/src/update.js +38 -77
  42. package/dist/vendor/skills/src/use.js +28 -4
  43. package/docs/agents-spec.md +27 -4
  44. package/docs/authoring.md +19 -2
  45. package/docs/branching-and-release.md +52 -0
  46. package/package.json +14 -3
  47. package/schemas/adg-plugin.schema.json +2 -0
  48. package/schemas/plugin-lock.schema.json +23 -1
  49. package/vendor/skills/PROVENANCE.md +2 -0
  50. package/vendor/skills/package.json +0 -144
  51. package/vendor/skills/src/add.ts +0 -2213
  52. package/vendor/skills/src/agents.ts +0 -811
  53. package/vendor/skills/src/blob.ts +0 -588
  54. package/vendor/skills/src/cli.ts +0 -391
  55. package/vendor/skills/src/constants.ts +0 -3
  56. package/vendor/skills/src/detect-agent.ts +0 -62
  57. package/vendor/skills/src/find.ts +0 -419
  58. package/vendor/skills/src/frontmatter.ts +0 -16
  59. package/vendor/skills/src/git-tree.ts +0 -36
  60. package/vendor/skills/src/git.ts +0 -277
  61. package/vendor/skills/src/install.ts +0 -91
  62. package/vendor/skills/src/installer.ts +0 -1307
  63. package/vendor/skills/src/list.ts +0 -231
  64. package/vendor/skills/src/local-lock.ts +0 -189
  65. package/vendor/skills/src/plugin-manifest.ts +0 -183
  66. package/vendor/skills/src/prompts/search-multiselect.ts +0 -387
  67. package/vendor/skills/src/providers/index.ts +0 -14
  68. package/vendor/skills/src/providers/registry.ts +0 -51
  69. package/vendor/skills/src/providers/types.ts +0 -97
  70. package/vendor/skills/src/providers/wellknown.ts +0 -812
  71. package/vendor/skills/src/remove.ts +0 -335
  72. package/vendor/skills/src/sanitize.ts +0 -65
  73. package/vendor/skills/src/self-cli.ts +0 -20
  74. package/vendor/skills/src/skill-lock.ts +0 -329
  75. package/vendor/skills/src/skills.ts +0 -316
  76. package/vendor/skills/src/source-parser.ts +0 -449
  77. package/vendor/skills/src/sync.ts +0 -478
  78. package/vendor/skills/src/telemetry.ts +0 -226
  79. package/vendor/skills/src/test-utils.ts +0 -73
  80. package/vendor/skills/src/types.ts +0 -129
  81. package/vendor/skills/src/update-source.ts +0 -90
  82. package/vendor/skills/src/update.ts +0 -821
  83. package/vendor/skills/src/use.ts +0 -682
@@ -1,449 +0,0 @@
1
- import { isAbsolute, resolve } from 'path';
2
- import type { ParsedSource } from './types.ts';
3
-
4
- /**
5
- * Extract owner/repo (or group/subgroup/repo for GitLab) from a parsed source
6
- * for lockfile tracking and telemetry.
7
- * Returns null for local paths or unparseable sources.
8
- * Supports any Git host with an owner/repo URL structure, including GitLab subgroups.
9
- */
10
- export function getOwnerRepo(parsed: ParsedSource): string | null {
11
- if (parsed.type === 'local') {
12
- return null;
13
- }
14
-
15
- // Handle Git SSH URLs (e.g., git@gitlab.com:owner/repo.git, git@github.com:owner/repo.git)
16
- const sshMatch = parsed.url.match(/^git@[^:]+:(.+)$/);
17
- if (sshMatch) {
18
- let path = sshMatch[1]!;
19
- path = path.replace(/\.git$/, '');
20
-
21
- // Must have at least owner/repo (one slash)
22
- if (path.includes('/')) {
23
- return path;
24
- }
25
- return null;
26
- }
27
-
28
- // Handle SSH URLs with a scheme (e.g., ssh://git@host:7999/owner/repo.git)
29
- if (parsed.url.startsWith('ssh://')) {
30
- try {
31
- const url = new URL(parsed.url);
32
- let path = url.pathname.slice(1);
33
- path = path.replace(/\.git$/, '');
34
-
35
- if (path.includes('/')) {
36
- return path;
37
- }
38
- return null;
39
- } catch {
40
- return null;
41
- }
42
- }
43
-
44
- // Handle HTTP(S) URLs
45
- if (!parsed.url.startsWith('http://') && !parsed.url.startsWith('https://')) {
46
- return null;
47
- }
48
-
49
- try {
50
- const url = new URL(parsed.url);
51
- // Get pathname, remove leading slash and trailing .git
52
- let path = url.pathname.slice(1);
53
- path = path.replace(/\.git$/, '');
54
-
55
- // Must have at least owner/repo (one slash)
56
- if (path.includes('/')) {
57
- return path;
58
- }
59
- } catch {
60
- // Invalid URL
61
- }
62
-
63
- return null;
64
- }
65
-
66
- /**
67
- * Extract owner and repo from an owner/repo string.
68
- * Returns null if the format is invalid.
69
- */
70
- export function parseOwnerRepo(ownerRepo: string): { owner: string; repo: string } | null {
71
- const match = ownerRepo.match(/^([^/]+)\/([^/]+)$/);
72
- if (match) {
73
- return { owner: match[1]!, repo: match[2]! };
74
- }
75
- return null;
76
- }
77
-
78
- /**
79
- * Check if a GitHub repository is private.
80
- * Returns true if private, false if public, null if unable to determine.
81
- * Only works for GitHub repositories (GitLab not supported).
82
- */
83
- export async function isRepoPrivate(owner: string, repo: string): Promise<boolean | null> {
84
- try {
85
- // ADG patch: GitHub's API rejects requests without a User-Agent (403), and
86
- // authenticating raises rate limits and reaches private repos. Read the
87
- // token from env directly to keep this best-effort check silent (no gh spawn).
88
- const headers: Record<string, string> = {
89
- 'User-Agent': 'skills-cli',
90
- Accept: 'application/vnd.github.v3+json',
91
- };
92
- const token = process.env.GITHUB_TOKEN || process.env.GH_TOKEN;
93
- if (token) {
94
- headers.Authorization = `Bearer ${token}`;
95
- }
96
- const res = await fetch(`https://api.github.com/repos/${owner}/${repo}`, { headers });
97
-
98
- // If repo doesn't exist or we don't have access, assume private to be safe
99
- if (!res.ok) {
100
- return null; // Unable to determine
101
- }
102
-
103
- const data = (await res.json()) as { private?: boolean };
104
- return data.private === true;
105
- } catch {
106
- // On error, return null to indicate we couldn't determine
107
- return null;
108
- }
109
- }
110
-
111
- /**
112
- * Sanitizes a subpath to prevent path traversal attacks.
113
- * Rejects subpaths containing ".." segments that could escape the repository root.
114
- * Returns the sanitized subpath, or throws if the subpath is unsafe.
115
- */
116
- export function sanitizeSubpath(subpath: string): string {
117
- // Normalize to forward slashes for consistent handling
118
- const normalized = subpath.replace(/\\/g, '/');
119
-
120
- // Check each segment for ".."
121
- const segments = normalized.split('/');
122
- for (const segment of segments) {
123
- if (segment === '..') {
124
- throw new Error(
125
- `Unsafe subpath: "${subpath}" contains path traversal segments. ` +
126
- `Subpaths must not contain ".." components.`
127
- );
128
- }
129
- }
130
-
131
- return subpath;
132
- }
133
-
134
- /**
135
- * Check if a string represents a local file system path
136
- */
137
- function isLocalPath(input: string): boolean {
138
- return (
139
- isAbsolute(input) ||
140
- input.startsWith('./') ||
141
- input.startsWith('../') ||
142
- input === '.' ||
143
- input === '..' ||
144
- // Windows absolute paths like C:\ or D:\
145
- /^[a-zA-Z]:[/\\]/.test(input)
146
- );
147
- }
148
-
149
- /**
150
- * Parse a source string into a structured format
151
- * Supports: local paths, GitHub URLs, GitLab URLs, GitHub shorthand, well-known URLs, and direct git URLs
152
- */
153
- // Source aliases: map common shorthand to canonical source
154
- const SOURCE_ALIASES: Record<string, string> = {
155
- 'coinbase/agentWallet': 'coinbase/agentic-wallet-skills',
156
- };
157
-
158
- interface FragmentRefResult {
159
- inputWithoutFragment: string;
160
- ref?: string;
161
- skillFilter?: string;
162
- }
163
-
164
- function decodeFragmentValue(value: string): string {
165
- try {
166
- return decodeURIComponent(value);
167
- } catch {
168
- return value;
169
- }
170
- }
171
-
172
- function looksLikeGitSource(input: string): boolean {
173
- if (input.startsWith('github:') || input.startsWith('gitlab:') || input.startsWith('git@')) {
174
- return true;
175
- }
176
-
177
- if (/^ssh:\/\/.+\.git(?:$|[/?])/i.test(input)) {
178
- return true;
179
- }
180
-
181
- if (input.startsWith('http://') || input.startsWith('https://')) {
182
- try {
183
- const parsed = new URL(input);
184
- const pathname = parsed.pathname;
185
-
186
- // Only treat GitHub fragments as refs for repo/tree URLs.
187
- if (parsed.hostname === 'github.com') {
188
- return /^\/[^/]+\/[^/]+(?:\.git)?(?:\/tree\/[^/]+(?:\/.*)?)?\/?$/.test(pathname);
189
- }
190
-
191
- // Only treat gitlab.com fragments as refs for repo/tree URLs.
192
- if (parsed.hostname === 'gitlab.com') {
193
- return /^\/.+?\/[^/]+(?:\.git)?(?:\/-\/tree\/[^/]+(?:\/.*)?)?\/?$/.test(pathname);
194
- }
195
- } catch {
196
- // Fall through to generic checks below.
197
- }
198
- }
199
-
200
- if (/^https?:\/\/.+\.git(?:$|[/?])/i.test(input)) {
201
- return true;
202
- }
203
-
204
- return (
205
- !input.includes(':') &&
206
- !input.startsWith('.') &&
207
- !input.startsWith('/') &&
208
- /^([^/]+)\/([^/]+)(?:\/(.+)|@(.+))?$/.test(input)
209
- );
210
- }
211
-
212
- function parseFragmentRef(input: string): FragmentRefResult {
213
- const hashIndex = input.indexOf('#');
214
- if (hashIndex < 0) {
215
- return { inputWithoutFragment: input };
216
- }
217
-
218
- const inputWithoutFragment = input.slice(0, hashIndex);
219
- const fragment = input.slice(hashIndex + 1);
220
-
221
- // Treat URL fragments as git refs only for git-like sources.
222
- // This avoids changing behavior for generic well-known URLs.
223
- if (!fragment || !looksLikeGitSource(inputWithoutFragment)) {
224
- return { inputWithoutFragment: input };
225
- }
226
-
227
- const atIndex = fragment.indexOf('@');
228
- if (atIndex === -1) {
229
- return {
230
- inputWithoutFragment,
231
- ref: decodeFragmentValue(fragment),
232
- };
233
- }
234
-
235
- const ref = fragment.slice(0, atIndex);
236
- const skillFilter = fragment.slice(atIndex + 1);
237
- return {
238
- inputWithoutFragment,
239
- ref: ref ? decodeFragmentValue(ref) : undefined,
240
- skillFilter: skillFilter ? decodeFragmentValue(skillFilter) : undefined,
241
- };
242
- }
243
-
244
- function appendFragmentRef(input: string, ref?: string, skillFilter?: string): string {
245
- if (!ref) {
246
- return input;
247
- }
248
- return `${input}#${ref}${skillFilter ? `@${skillFilter}` : ''}`;
249
- }
250
-
251
- export function parseSource(input: string): ParsedSource {
252
- // Local path: absolute, relative, or current directory
253
- if (isLocalPath(input)) {
254
- const resolvedPath = resolve(input);
255
- // Return local type even if path doesn't exist - we'll handle validation in main flow
256
- return {
257
- type: 'local',
258
- url: resolvedPath, // Store resolved path in url for consistency
259
- localPath: resolvedPath,
260
- };
261
- }
262
-
263
- const {
264
- inputWithoutFragment,
265
- ref: fragmentRef,
266
- skillFilter: fragmentSkillFilter,
267
- } = parseFragmentRef(input);
268
- input = inputWithoutFragment;
269
-
270
- // Resolve source aliases before parsing
271
- const alias = SOURCE_ALIASES[input];
272
- if (alias) {
273
- input = alias;
274
- }
275
-
276
- // Prefix shorthand: github:owner/repo -> owner/repo (handled by existing shorthand logic)
277
- // Also supports github:owner/repo/subpath and github:owner/repo@skill
278
- const githubPrefixMatch = input.match(/^github:(.+)$/);
279
- if (githubPrefixMatch) {
280
- return parseSource(appendFragmentRef(githubPrefixMatch[1]!, fragmentRef, fragmentSkillFilter));
281
- }
282
-
283
- // Prefix shorthand: gitlab:owner/repo -> https://gitlab.com/owner/repo
284
- const gitlabPrefixMatch = input.match(/^gitlab:(.+)$/);
285
- if (gitlabPrefixMatch) {
286
- return parseSource(
287
- appendFragmentRef(
288
- `https://gitlab.com/${gitlabPrefixMatch[1]!}`,
289
- fragmentRef,
290
- fragmentSkillFilter
291
- )
292
- );
293
- }
294
-
295
- // GitHub URL with path: https://github.com/owner/repo/tree/branch/path/to/skill
296
- const githubTreeWithPathMatch = input.match(/github\.com\/([^/]+)\/([^/]+)\/tree\/([^/]+)\/(.+)/);
297
- if (githubTreeWithPathMatch) {
298
- const [, owner, repo, ref, subpath] = githubTreeWithPathMatch;
299
- return {
300
- type: 'github',
301
- url: `https://github.com/${owner}/${repo}.git`,
302
- ref: ref || fragmentRef,
303
- subpath: subpath ? sanitizeSubpath(subpath) : subpath,
304
- };
305
- }
306
-
307
- // GitHub URL with branch only: https://github.com/owner/repo/tree/branch
308
- const githubTreeMatch = input.match(/github\.com\/([^/]+)\/([^/]+)\/tree\/([^/]+)$/);
309
- if (githubTreeMatch) {
310
- const [, owner, repo, ref] = githubTreeMatch;
311
- return {
312
- type: 'github',
313
- url: `https://github.com/${owner}/${repo}.git`,
314
- ref: ref || fragmentRef,
315
- };
316
- }
317
-
318
- // GitHub URL: https://github.com/owner/repo
319
- const githubRepoMatch = input.match(/github\.com\/([^/]+)\/([^/]+)/);
320
- if (githubRepoMatch) {
321
- const [, owner, repo] = githubRepoMatch;
322
- const cleanRepo = repo!.replace(/\.git$/, '');
323
- return {
324
- type: 'github',
325
- url: `https://github.com/${owner}/${cleanRepo}.git`,
326
- ...(fragmentRef ? { ref: fragmentRef } : {}),
327
- };
328
- }
329
-
330
- // GitLab URL with path (any GitLab instance): https://gitlab.com/owner/repo/-/tree/branch/path
331
- // Key identifier is the "/-/tree/" path pattern unique to GitLab.
332
- // Supports subgroups by using a non-greedy match for the repository path.
333
- const gitlabTreeWithPathMatch = input.match(
334
- /^(https?):\/\/([^/]+)\/(.+?)\/-\/tree\/([^/]+)\/(.+)/
335
- );
336
- if (gitlabTreeWithPathMatch) {
337
- const [, protocol, hostname, repoPath, ref, subpath] = gitlabTreeWithPathMatch;
338
- if (hostname !== 'github.com' && repoPath) {
339
- return {
340
- type: 'gitlab',
341
- url: `${protocol}://${hostname}/${repoPath.replace(/\.git$/, '')}.git`,
342
- ref: ref || fragmentRef,
343
- subpath: subpath ? sanitizeSubpath(subpath) : subpath,
344
- };
345
- }
346
- }
347
-
348
- // GitLab URL with branch only (any GitLab instance): https://gitlab.com/owner/repo/-/tree/branch
349
- const gitlabTreeMatch = input.match(/^(https?):\/\/([^/]+)\/(.+?)\/-\/tree\/([^/]+)$/);
350
- if (gitlabTreeMatch) {
351
- const [, protocol, hostname, repoPath, ref] = gitlabTreeMatch;
352
- if (hostname !== 'github.com' && repoPath) {
353
- return {
354
- type: 'gitlab',
355
- url: `${protocol}://${hostname}/${repoPath.replace(/\.git$/, '')}.git`,
356
- ref: ref || fragmentRef,
357
- };
358
- }
359
- }
360
-
361
- // GitLab.com URL: https://gitlab.com/owner/repo or https://gitlab.com/group/subgroup/repo
362
- // Only for the official gitlab.com domain for user convenience.
363
- // Supports nested subgroups (e.g., gitlab.com/group/subgroup1/subgroup2/repo).
364
- const gitlabRepoMatch = input.match(/gitlab\.com\/(.+?)(?:\.git)?\/?$/);
365
- if (gitlabRepoMatch) {
366
- const repoPath = gitlabRepoMatch[1]!;
367
- // Must have at least owner/repo (one slash)
368
- if (repoPath.includes('/')) {
369
- return {
370
- type: 'gitlab',
371
- url: `https://gitlab.com/${repoPath}.git`,
372
- ...(fragmentRef ? { ref: fragmentRef } : {}),
373
- };
374
- }
375
- }
376
-
377
- // GitHub shorthand: owner/repo, owner/repo/path/to/skill, or owner/repo@skill-name
378
- // Exclude paths that start with . or / to avoid matching local paths
379
- // First check for @skill syntax: owner/repo@skill-name
380
- const atSkillMatch = input.match(/^([^/]+)\/([^/@]+)@(.+)$/);
381
- if (atSkillMatch && !input.includes(':') && !input.startsWith('.') && !input.startsWith('/')) {
382
- const [, owner, repo, skillFilter] = atSkillMatch;
383
- return {
384
- type: 'github',
385
- url: `https://github.com/${owner}/${repo}.git`,
386
- ...(fragmentRef ? { ref: fragmentRef } : {}),
387
- skillFilter: fragmentSkillFilter || skillFilter,
388
- };
389
- }
390
-
391
- const shorthandMatch = input.match(/^([^/]+)\/([^/]+)(?:\/(.+?))?\/?$/);
392
- if (shorthandMatch && !input.includes(':') && !input.startsWith('.') && !input.startsWith('/')) {
393
- const [, owner, repo, subpath] = shorthandMatch;
394
- return {
395
- type: 'github',
396
- url: `https://github.com/${owner}/${repo}.git`,
397
- ...(fragmentRef ? { ref: fragmentRef } : {}),
398
- subpath: subpath ? sanitizeSubpath(subpath) : subpath,
399
- ...(fragmentSkillFilter ? { skillFilter: fragmentSkillFilter } : {}),
400
- };
401
- }
402
-
403
- // Well-known skills: arbitrary HTTP(S) URLs that aren't GitHub/GitLab
404
- // This is the final fallback for URLs - we'll check for /.well-known/agent-skills/index.json
405
- // then fall back to /.well-known/skills/index.json
406
- if (isWellKnownUrl(input)) {
407
- return {
408
- type: 'well-known',
409
- url: input,
410
- };
411
- }
412
-
413
- // Fallback: treat as direct git URL
414
- return {
415
- type: 'git',
416
- url: input,
417
- ...(fragmentRef ? { ref: fragmentRef } : {}),
418
- };
419
- }
420
-
421
- /**
422
- * Check if a URL could be a well-known skills endpoint.
423
- * Must be HTTP(S) and not a known git host (GitHub, GitLab).
424
- * Also excludes URLs that look like git repos (.git suffix).
425
- */
426
- function isWellKnownUrl(input: string): boolean {
427
- if (!input.startsWith('http://') && !input.startsWith('https://')) {
428
- return false;
429
- }
430
-
431
- try {
432
- const parsed = new URL(input);
433
-
434
- // Exclude known git hosts that have their own handling
435
- const excludedHosts = ['github.com', 'gitlab.com', 'raw.githubusercontent.com'];
436
- if (excludedHosts.includes(parsed.hostname)) {
437
- return false;
438
- }
439
-
440
- // Don't match URLs that look like git repos (should be handled by git type)
441
- if (input.endsWith('.git')) {
442
- return false;
443
- }
444
-
445
- return true;
446
- } catch {
447
- return false;
448
- }
449
- }