@rbbtsn0w/adg 0.6.0-beta.10 → 0.6.0-beta.11

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 (50) hide show
  1. package/README.md +10 -7
  2. package/dist/bin/adg.js +4 -3
  3. package/dist/src/agents/base.js +2 -1
  4. package/dist/src/cli/core-plugin-handlers.js +97 -0
  5. package/dist/src/cli/handlers.js +4 -82
  6. package/dist/src/manifest.js +56 -3
  7. package/dist/src/subprocess.js +53 -0
  8. package/dist/vendor/skills/src/add.js +0 -15
  9. package/dist/vendor/skills/src/git-tree.js +4 -4
  10. package/dist/vendor/skills/src/skill-lock.js +4 -3
  11. package/dist/vendor/skills/src/update.js +9 -73
  12. package/dist/vendor/skills/src/use.js +28 -4
  13. package/docs/branching-and-release.md +52 -0
  14. package/package.json +7 -2
  15. package/schemas/adg-plugin.schema.json +1 -0
  16. package/vendor/skills/PROVENANCE.md +2 -0
  17. package/vendor/skills/package.json +0 -144
  18. package/vendor/skills/src/add.ts +0 -2213
  19. package/vendor/skills/src/agents.ts +0 -811
  20. package/vendor/skills/src/blob.ts +0 -588
  21. package/vendor/skills/src/cli.ts +0 -396
  22. package/vendor/skills/src/constants.ts +0 -3
  23. package/vendor/skills/src/detect-agent.ts +0 -62
  24. package/vendor/skills/src/find.ts +0 -419
  25. package/vendor/skills/src/frontmatter.ts +0 -16
  26. package/vendor/skills/src/git-tree.ts +0 -36
  27. package/vendor/skills/src/git.ts +0 -277
  28. package/vendor/skills/src/install.ts +0 -91
  29. package/vendor/skills/src/installer.ts +0 -1307
  30. package/vendor/skills/src/list.ts +0 -231
  31. package/vendor/skills/src/local-lock.ts +0 -189
  32. package/vendor/skills/src/plugin-manifest.ts +0 -183
  33. package/vendor/skills/src/prompts/search-multiselect.ts +0 -387
  34. package/vendor/skills/src/providers/index.ts +0 -14
  35. package/vendor/skills/src/providers/registry.ts +0 -51
  36. package/vendor/skills/src/providers/types.ts +0 -97
  37. package/vendor/skills/src/providers/wellknown.ts +0 -812
  38. package/vendor/skills/src/remove.ts +0 -335
  39. package/vendor/skills/src/sanitize.ts +0 -65
  40. package/vendor/skills/src/self-cli.ts +0 -20
  41. package/vendor/skills/src/skill-lock.ts +0 -329
  42. package/vendor/skills/src/skills.ts +0 -316
  43. package/vendor/skills/src/source-parser.ts +0 -449
  44. package/vendor/skills/src/sync.ts +0 -478
  45. package/vendor/skills/src/telemetry.ts +0 -226
  46. package/vendor/skills/src/test-utils.ts +0 -73
  47. package/vendor/skills/src/types.ts +0 -129
  48. package/vendor/skills/src/update-source.ts +0 -90
  49. package/vendor/skills/src/update.ts +0 -849
  50. package/vendor/skills/src/use.ts +0 -682
@@ -1,277 +0,0 @@
1
- // ADG patch: named import. The default import is not callable under the root
2
- // tsconfig (NodeNext + verbatimModuleSyntax, no esModuleInterop); simple-git
3
- // exposes `simpleGit` as a named export. See vendor/skills/PROVENANCE.md.
4
- import { simpleGit } from 'simple-git';
5
- import { join, normalize, resolve, sep } from 'path';
6
- import { mkdtemp, mkdir, rm } from 'fs/promises';
7
- import { tmpdir } from 'os';
8
- import { execFile } from 'child_process';
9
- import { promisify } from 'util';
10
-
11
- const DEFAULT_CLONE_TIMEOUT_MS = 300_000; // 5 minutes
12
- const CLONE_TIMEOUT_MS = (() => {
13
- const raw = process.env.SKILLS_CLONE_TIMEOUT_MS;
14
- if (!raw) return DEFAULT_CLONE_TIMEOUT_MS;
15
- const parsed = Number.parseInt(raw, 10);
16
- return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_CLONE_TIMEOUT_MS;
17
- })();
18
- const execFileAsync = promisify(execFile);
19
-
20
- interface GitHubRepoInfo {
21
- owner: string;
22
- repo: string;
23
- slug: string;
24
- sshUrl: string;
25
- }
26
-
27
- export class GitCloneError extends Error {
28
- readonly url: string;
29
- readonly isTimeout: boolean;
30
- readonly isAuthError: boolean;
31
-
32
- constructor(message: string, url: string, isTimeout = false, isAuthError = false) {
33
- super(message);
34
- this.name = 'GitCloneError';
35
- this.url = url;
36
- this.isTimeout = isTimeout;
37
- this.isAuthError = isAuthError;
38
- }
39
- }
40
-
41
- export function parseGitHubRepoUrl(url: string): GitHubRepoInfo | null {
42
- const sshMatch = url.match(/^git@github\.com:([^/]+)\/([^/]+?)(?:\.git)?$/i);
43
- if (sshMatch) {
44
- const owner = sshMatch[1]!;
45
- const repo = sshMatch[2]!;
46
- return {
47
- owner,
48
- repo,
49
- slug: `${owner}/${repo}`,
50
- sshUrl: `git@github.com:${owner}/${repo}.git`,
51
- };
52
- }
53
-
54
- try {
55
- const parsed = new URL(url);
56
- if (parsed.hostname !== 'github.com') return null;
57
-
58
- const match = parsed.pathname.match(/^\/([^/]+)\/([^/]+?)(?:\.git)?\/?$/);
59
- if (!match) return null;
60
-
61
- const owner = match[1]!;
62
- const repo = match[2]!;
63
- return {
64
- owner,
65
- repo,
66
- slug: `${owner}/${repo}`,
67
- sshUrl: `git@github.com:${owner}/${repo}.git`,
68
- };
69
- } catch {
70
- return null;
71
- }
72
- }
73
-
74
- export function isGitHubHttpsCloneUrl(url: string): boolean {
75
- try {
76
- const parsed = new URL(url);
77
- return parsed.protocol === 'https:' && parsed.hostname === 'github.com';
78
- } catch {
79
- return false;
80
- }
81
- }
82
-
83
- export function isGitHubSsoAuthError(message: string): boolean {
84
- const lower = message.toLowerCase();
85
- return (
86
- lower.includes('saml sso') ||
87
- lower.includes('enforced sso') ||
88
- lower.includes('enabled or enforced saml') ||
89
- lower.includes('re-authorize the oauth application')
90
- );
91
- }
92
-
93
- function isAuthFailure(message: string): boolean {
94
- return (
95
- message.includes('Authentication failed') ||
96
- message.includes('could not read Username') ||
97
- message.includes('Permission denied') ||
98
- message.includes('Repository not found') ||
99
- message.includes('requested URL returned error: 403') ||
100
- isGitHubSsoAuthError(message)
101
- );
102
- }
103
-
104
- function createGitClient(extraEnv?: NodeJS.ProcessEnv) {
105
- return simpleGit({
106
- timeout: { block: CLONE_TIMEOUT_MS },
107
- // When git-lfs is NOT installed, GIT_LFS_SKIP_SMUDGE has no effect —
108
- // git sees `filter=lfs` in .gitattributes, tries to run
109
- // `git-lfs filter-process`, and aborts the checkout with:
110
- // git-lfs filter-process: git-lfs: command not found
111
- // fatal: the remote end hung up unexpectedly
112
- // warning: Clone succeeded, but checkout failed.
113
- // Overriding filter.lfs.* at the command level disables the filter
114
- // entirely for this clone, so checkout succeeds regardless of whether
115
- // git-lfs is installed. LFS-tracked files are left as ~130-byte
116
- // pointer files, which the skills installer doesn't read anyway
117
- // (skills are plain text — HTML/MD/JSON — never LFS-tracked).
118
- //
119
- // Reported downstream: heygen-com/hyperframes#407.
120
- config: [
121
- 'filter.lfs.required=false',
122
- 'filter.lfs.smudge=',
123
- 'filter.lfs.clean=',
124
- 'filter.lfs.process=',
125
- ],
126
- // ADG patch: simple-git >=3.36 blocks `filter.*.smudge/clean` configs (an RCE
127
- // vector via a malicious filter command) unless explicitly allowed, failing
128
- // every clone with "Configuring filter.smudge is not permitted without
129
- // enabling allowUnsafeFilter". Here the filters are set to EMPTY — we are
130
- // *disabling* the LFS filter, not running one — so opting in is safe and is
131
- // exactly the intent of the config above. See vendor/skills/PROVENANCE.md.
132
- unsafe: {
133
- allowUnsafeFilter: true,
134
- },
135
- // ADG patch: env must be applied via `.env()`, not as a constructor option.
136
- // simple-git's factory only reads baseDir/maxConcurrentProcesses/trimmed from
137
- // the options object and silently drops `env`, so the GIT_TERMINAL_PROMPT /
138
- // GIT_LFS_SKIP_SMUDGE / GIT_SSH_COMMAND overrides below never reached the
139
- // spawned git before this. See vendor/skills/PROVENANCE.md.
140
- }).env({
141
- ...process.env,
142
- GIT_TERMINAL_PROMPT: '0',
143
- // When git-lfs IS installed, tell it not to download LFS content during
144
- // checkout. See #952 for context and empirical impact.
145
- GIT_LFS_SKIP_SMUDGE: '1',
146
- ...extraEnv,
147
- });
148
- }
149
-
150
- async function resetTempDir(dir: string): Promise<void> {
151
- await rm(dir, { recursive: true, force: true }).catch(() => {});
152
- await mkdir(dir, { recursive: true });
153
- }
154
-
155
- async function tryGhClone(repo: GitHubRepoInfo, tempDir: string, ref?: string): Promise<boolean> {
156
- let cloneTarget = repo.slug;
157
-
158
- try {
159
- const { stdout, stderr } = await execFileAsync('gh', ['auth', 'status', '-h', 'github.com'], {
160
- timeout: 5000,
161
- env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
162
- });
163
- const statusOutput = `${stdout}${stderr}`;
164
- if (/Git operations protocol:\s+ssh/i.test(statusOutput)) {
165
- cloneTarget = repo.sshUrl;
166
- }
167
- } catch {
168
- return false;
169
- }
170
-
171
- const gitFlags = ref ? ['--depth=1', '--branch', ref] : ['--depth=1'];
172
- await execFileAsync('gh', ['repo', 'clone', cloneTarget, tempDir, '--', ...gitFlags], {
173
- timeout: CLONE_TIMEOUT_MS,
174
- env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
175
- });
176
- return true;
177
- }
178
-
179
- function buildGitHubAuthError(url: string, repo: GitHubRepoInfo | null, message: string): string {
180
- if (repo && isGitHubSsoAuthError(message)) {
181
- return (
182
- `GitHub blocked HTTPS access to ${url} because the organization enforces SAML SSO.\n` +
183
- ` skills tried your existing git credentials and available fallbacks, but none succeeded.\n` +
184
- ` - Re-authorize your GitHub credentials/app for that org's SSO policy\n` +
185
- ` - Or rerun with SSH: npx skills add ${repo.sshUrl}\n` +
186
- ` - Verify access with: gh auth status -h github.com or ssh -T git@github.com`
187
- );
188
- }
189
-
190
- if (repo) {
191
- return (
192
- `Authentication failed for ${url}.\n` +
193
- ` - For private repos, ensure you have access\n` +
194
- ` - Retry with SSH: npx skills add ${repo.sshUrl}\n` +
195
- ` - Check access with: gh auth status -h github.com or ssh -T git@github.com`
196
- );
197
- }
198
-
199
- return (
200
- `Authentication failed for ${url}.\n` +
201
- ` - For private repos, ensure you have access\n` +
202
- ` - For SSH: Check your keys with 'ssh -T git@github.com'\n` +
203
- ` - For HTTPS: Run 'gh auth login' or configure git credentials`
204
- );
205
- }
206
-
207
- export async function cloneRepo(url: string, ref?: string): Promise<string> {
208
- const tempDir = await mkdtemp(join(tmpdir(), 'skills-'));
209
- const cloneOptions = ref ? ['--depth', '1', '--branch', ref] : ['--depth', '1'];
210
- const repo = parseGitHubRepoUrl(url);
211
-
212
- try {
213
- await createGitClient().clone(url, tempDir, cloneOptions);
214
- return tempDir;
215
- } catch (error) {
216
- const errorMessage = error instanceof Error ? error.message : String(error);
217
- const isTimeout = errorMessage.includes('block timeout') || errorMessage.includes('timed out');
218
- const isAuthError = isAuthFailure(errorMessage);
219
-
220
- if (isTimeout) {
221
- await rm(tempDir, { recursive: true, force: true }).catch(() => {});
222
- const seconds = Math.round(CLONE_TIMEOUT_MS / 1000);
223
- throw new GitCloneError(
224
- `Clone timed out after ${seconds}s. Common causes:\n` +
225
- ` - Large repository: raise the timeout with SKILLS_CLONE_TIMEOUT_MS=600000 (10m)\n` +
226
- ` - Slow network: retry, or clone manually and pass the local path to 'skills add'\n` +
227
- ` - Private repo without credentials: ensure auth is configured\n` +
228
- ` - For SSH: ssh-add -l (to check loaded keys)\n` +
229
- ` - For HTTPS: gh auth status (if using GitHub CLI)`,
230
- url,
231
- true,
232
- false
233
- );
234
- }
235
-
236
- if (isAuthError && repo && isGitHubHttpsCloneUrl(url)) {
237
- try {
238
- await resetTempDir(tempDir);
239
- if (await tryGhClone(repo, tempDir, ref)) {
240
- return tempDir;
241
- }
242
- } catch {
243
- // Fall through to SSH retry.
244
- }
245
-
246
- try {
247
- await resetTempDir(tempDir);
248
- await createGitClient({
249
- GIT_SSH_COMMAND: process.env.GIT_SSH_COMMAND ?? 'ssh -o BatchMode=yes',
250
- }).clone(repo.sshUrl, tempDir, cloneOptions);
251
- return tempDir;
252
- } catch {
253
- // Fall through to the targeted auth error below.
254
- }
255
- }
256
-
257
- await rm(tempDir, { recursive: true, force: true }).catch(() => {});
258
-
259
- if (isAuthError) {
260
- throw new GitCloneError(buildGitHubAuthError(url, repo, errorMessage), url, false, true);
261
- }
262
-
263
- throw new GitCloneError(`Failed to clone ${url}: ${errorMessage}`, url, false, false);
264
- }
265
- }
266
-
267
- export async function cleanupTempDir(dir: string): Promise<void> {
268
- // Validate that the directory path is within tmpdir to prevent deletion of arbitrary paths
269
- const normalizedDir = normalize(resolve(dir));
270
- const normalizedTmpDir = normalize(resolve(tmpdir()));
271
-
272
- if (!normalizedDir.startsWith(normalizedTmpDir + sep) && normalizedDir !== normalizedTmpDir) {
273
- throw new Error('Attempted to clean up directory outside of temp directory');
274
- }
275
-
276
- await rm(dir, { recursive: true, force: true });
277
- }
@@ -1,91 +0,0 @@
1
- import * as p from '@clack/prompts';
2
- import pc from 'picocolors';
3
- import { readLocalLock } from './local-lock.ts';
4
- import { runAdd } from './add.ts';
5
- import { runSync, parseSyncOptions } from './sync.ts';
6
- import { getUniversalAgents } from './agents.ts';
7
-
8
- /**
9
- * Install all skills from the local skills-lock.json.
10
- * Groups skills by source and calls `runAdd` for each group.
11
- *
12
- * Only installs to .agents/skills/ (universal agents) -- the canonical
13
- * project-level location. Does not install to agent-specific directories.
14
- *
15
- * node_modules skills are handled via experimental_sync.
16
- */
17
- export async function runInstallFromLock(args: string[]): Promise<void> {
18
- const cwd = process.cwd();
19
- const lock = await readLocalLock(cwd);
20
- const skillEntries = Object.entries(lock.skills);
21
-
22
- if (skillEntries.length === 0) {
23
- p.log.warn('No project skills found in skills-lock.json');
24
- p.log.info(
25
- `Add project-level skills with ${pc.cyan('adg skills add <package>')} (without ${pc.cyan('-g')})`
26
- );
27
- return;
28
- }
29
-
30
- // Only install to .agents/skills/ (universal agents)
31
- const universalAgentNames = getUniversalAgents();
32
-
33
- // Separate node_modules skills from remote skills
34
- const nodeModuleSkills: string[] = [];
35
- const bySource = new Map<string, { sourceType: string; skills: string[] }>();
36
-
37
- for (const [skillName, entry] of skillEntries) {
38
- if (entry.sourceType === 'node_modules') {
39
- nodeModuleSkills.push(skillName);
40
- continue;
41
- }
42
-
43
- const installSource = entry.ref ? `${entry.source}#${entry.ref}` : entry.source;
44
- const existing = bySource.get(installSource);
45
- if (existing) {
46
- existing.skills.push(skillName);
47
- } else {
48
- bySource.set(installSource, {
49
- sourceType: entry.sourceType,
50
- skills: [skillName],
51
- });
52
- }
53
- }
54
-
55
- const remoteCount = skillEntries.length - nodeModuleSkills.length;
56
- if (remoteCount > 0) {
57
- p.log.info(
58
- `Restoring ${pc.cyan(String(remoteCount))} skill${remoteCount !== 1 ? 's' : ''} from skills-lock.json into ${pc.dim('.agents/skills/')}`
59
- );
60
- }
61
-
62
- // Install remote skills grouped by source
63
- for (const [source, { skills }] of bySource) {
64
- try {
65
- await runAdd([source], {
66
- skill: skills,
67
- agent: universalAgentNames,
68
- yes: true,
69
- });
70
- } catch (error) {
71
- p.log.error(
72
- `Failed to install from ${pc.cyan(source)}: ${error instanceof Error ? error.message : 'Unknown error'}`
73
- );
74
- }
75
- }
76
-
77
- // Handle node_modules skills via sync
78
- if (nodeModuleSkills.length > 0) {
79
- p.log.info(
80
- `${pc.cyan(String(nodeModuleSkills.length))} skill${nodeModuleSkills.length !== 1 ? 's' : ''} from node_modules`
81
- );
82
- try {
83
- const { options: syncOptions } = parseSyncOptions(args);
84
- await runSync(args, { ...syncOptions, yes: true, agent: universalAgentNames });
85
- } catch (error) {
86
- p.log.error(
87
- `Failed to sync node_modules skills: ${error instanceof Error ? error.message : 'Unknown error'}`
88
- );
89
- }
90
- }
91
- }