Skip to content
Merged
2 changes: 1 addition & 1 deletion scripts/sync-agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { readFileSync, writeFileSync } from 'fs';
import { join } from 'path';
import { homedir } from 'os';
import { agents } from '../src/agents.ts';
import { agents } from '../src/lib/agents/agents.ts';

const ROOT = join(import.meta.dirname, '..');
const README_PATH = join(ROOT, 'README.md');
Expand Down
2 changes: 1 addition & 1 deletion scripts/validate-agents.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node

import { agents } from '../src/agents.ts';
import { agents } from '../src/lib/agents/agents.ts';

let hasErrors = false;

Expand Down
12 changes: 6 additions & 6 deletions src/add-agents.test.ts → src/add/add-agents.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { multiselect, promptForAgents, selectAgentsInteractive } from './add-agents.js';
import * as skillLock from './skill-lock.js';
import * as searchMultiselectModule from './prompts/search-multiselect.js';
import { multiselect, promptForAgents, selectAgentsInteractive } from './add-agents.ts';
import * as skillLock from '../lib/lock/skill-lock.ts';
import * as searchMultiselectModule from '../lib/prompts/search-multiselect.ts';
import * as clack from '@clack/prompts';
import * as agentsModule from './agents.js';
import * as agentsModule from '../lib/agents/agents.ts';

// Mock dependencies
vi.mock('./skill-lock.js');
vi.mock('./prompts/search-multiselect.js');
vi.mock('../lib/lock/skill-lock.ts');
vi.mock('../lib/prompts/search-multiselect.ts');
vi.mock('@clack/prompts', async () => {
const actual = await vi.importActual('@clack/prompts');
return {
Expand Down
8 changes: 4 additions & 4 deletions src/add-agents.ts → src/add/add-agents.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as p from '@clack/prompts';
import pc from 'picocolors';
import { searchMultiselect } from './prompts/search-multiselect.ts';
import { agents, getUniversalAgents, getNonUniversalAgents } from './agents.ts';
import { getLastSelectedAgents, saveSelectedAgents } from './skill-lock.ts';
import type { AgentType } from './types.ts';
import { searchMultiselect } from '../lib/prompts/search-multiselect.ts';
import { agents, getUniversalAgents, getNonUniversalAgents } from '../lib/agents/index.ts';
import { getLastSelectedAgents, saveSelectedAgents } from '../lib/lock/index.ts';
import type { AgentType } from '../lib/types.ts';

// Helper to check if a value is a cancel symbol (works with both clack and our custom prompts)
const isCancelled = (value: unknown): value is symbol => typeof value === 'symbol';
Expand Down
4 changes: 2 additions & 2 deletions src/add-display.test.ts → src/add/add-display.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
ensureUniversalAgents,
buildResultLines,
} from './add-display.ts';
import type { AgentType } from './types.ts';
import type { AuditResponse, PartnerAudit } from './telemetry.ts';
import type { AgentType } from '../lib/types.ts';
import type { AuditResponse, PartnerAudit } from '../lib/telemetry.ts';

// Helper to strip ANSI escape codes for easier assertion
const stripAnsi = (s: string) => s.replace(/\x1b\[[0-9;]*m/g, '');
Expand Down
10 changes: 5 additions & 5 deletions src/add-display.ts → src/add/add-display.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import pc from 'picocolors';
import { formatList } from './utils.ts';
import { agents, getUniversalAgents, isUniversalAgent } from './agents.ts';
import type { AgentType } from './types.ts';
import type { InstallMode } from './skill-installer.ts';
import type { AuditResponse, PartnerAudit } from './telemetry.ts';
import { formatList } from '../lib/utils.ts';
import { agents, getUniversalAgents, isUniversalAgent } from '../lib/agents/index.ts';
import type { AgentType } from '../lib/types.ts';
import type { InstallMode } from '../lib/install/index.ts';
import type { AuditResponse, PartnerAudit } from '../lib/telemetry.ts';

// ─── Security Advisory ───

Expand Down
16 changes: 8 additions & 8 deletions src/add-install.test.ts → src/add/add-install.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import type { AddOptions } from './add-options.ts';
import type { AgentType } from './types.ts';
import type { AgentType } from '../lib/types.ts';

// --- Mocks ---

Expand All @@ -18,8 +18,8 @@ vi.mock('@clack/prompts', async () => {
};
});

vi.mock('./agents.ts', async () => {
const actual = await vi.importActual('./agents.ts');
vi.mock('../lib/agents/agents.ts', async () => {
const actual = await vi.importActual('../lib/agents/agents.ts');
return {
...actual,
detectInstalledAgents: vi.fn(),
Expand All @@ -32,8 +32,8 @@ vi.mock('./add-agents.ts', () => ({
selectAgentsInteractive: vi.fn(),
}));

vi.mock('./skill-installer.ts', async () => {
const actual = await vi.importActual('./skill-installer.ts');
vi.mock('../lib/install/skill-installer.ts', async () => {
const actual = await vi.importActual('../lib/install/skill-installer.ts');
return {
...actual,
isSkillInstalled: vi.fn(),
Expand All @@ -49,10 +49,10 @@ import {
displayInstallResults,
type InstallResult,
} from './add-install.ts';
import { detectInstalledAgents, agents } from './agents.ts';
import { detectInstalledAgents, agents } from '../lib/agents/index.ts';
import { promptForAgents, selectAgentsInteractive } from './add-agents.ts';
import { isSkillInstalled } from './skill-installer.ts';
import { CommandError } from './command-result.ts';
import { isSkillInstalled } from '../lib/install/index.ts';
import { CommandError } from '../lib/command-result.ts';

// --- Helpers ---

Expand Down
10 changes: 5 additions & 5 deletions src/add-install.ts → src/add/add-install.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import * as p from '@clack/prompts';
import pc from 'picocolors';
import { promptForAgents, selectAgentsInteractive } from './add-agents.ts';
import { isSkillInstalled, type InstallMode } from './skill-installer.ts';
import { detectInstalledAgents, agents } from './agents.ts';
import type { AgentType } from './types.ts';
import { isSkillInstalled, type InstallMode } from '../lib/install/index.ts';
import { detectInstalledAgents, agents } from '../lib/agents/index.ts';
import type { AgentType } from '../lib/types.ts';
import { ensureUniversalAgents, buildResultLines } from './add-display.ts';
import type { AddOptions } from './add-options.ts';
import { shortenPath, formatList, kebabToTitle } from './utils.ts';
import { CommandError } from './command-result.ts';
import { shortenPath, formatList, kebabToTitle } from '../lib/utils.ts';
import { CommandError } from '../lib/command-result.ts';

export interface InstallResult {
skill: string;
Expand Down
2 changes: 1 addition & 1 deletion src/add-options.test.ts → src/add/add-options.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect } from 'vitest';
import { parseAddOptions } from './add-options.ts';
import { resolveTargetAgents } from './context-add.ts';
import { resolveTargetAgents } from '../lib/install/index.ts';

// ---------------------------------------------------------------------------
// parseAddOptions — basic flags
Expand Down
4 changes: 2 additions & 2 deletions src/add-options.ts → src/add/add-options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ContextType } from './types.ts';
import { consumeMultiValues } from './cli-parse.ts';
import type { ContextType } from '../lib/types.ts';
import { consumeMultiValues } from '../cli-parse.ts';

export interface AddOptions {
global?: boolean;
Expand Down
14 changes: 7 additions & 7 deletions src/add-prompt.test.ts → src/add/add-prompt.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { promptForAgents } from './add.js';
import * as skillLock from './skill-lock.js';
import * as searchMultiselectModule from './prompts/search-multiselect.js';
import { promptForAgents } from './add.ts';
import * as skillLock from '../lib/lock/skill-lock.ts';
import * as searchMultiselectModule from '../lib/prompts/search-multiselect.ts';

// Mock dependencies
vi.mock('./skill-lock.js');
vi.mock('./prompts/search-multiselect.js');
vi.mock('./telemetry.js', () => ({
vi.mock('../lib/lock/skill-lock.ts');
vi.mock('../lib/prompts/search-multiselect.ts');
vi.mock('../lib/telemetry.ts', () => ({
setVersion: vi.fn(),
track: vi.fn(),
}));
vi.mock('../package.json', () => ({
vi.mock('../../package.json', () => ({
default: { version: '1.0.0' },
}));

Expand Down
40 changes: 20 additions & 20 deletions src/add-wellknown.test.ts → src/add/add-wellknown.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import type { WellKnownSkill } from './providers/index.ts';
import type { WellKnownSkill } from '../lib/providers/index.ts';
import type { AddOptions } from './add-options.ts';
import type { AgentType } from './types.ts';
import type { AgentType } from '../lib/types.ts';

// --- Mocks ---

Expand All @@ -18,23 +18,23 @@ vi.mock('@clack/prompts', async () => {
};
});

vi.mock('./providers/index.ts', () => ({
vi.mock('../lib/providers/index.ts', () => ({
wellKnownProvider: {
fetchAllSkills: vi.fn(),
getSourceIdentifier: vi.fn().mockReturnValue('wellknown/example.com'),
},
}));

vi.mock('./agents.ts', async () => {
const actual = await vi.importActual('./agents.ts');
vi.mock('../lib/agents/agents.ts', async () => {
const actual = await vi.importActual('../lib/agents/agents.ts');
return {
...actual,
detectInstalledAgents: vi.fn(),
};
});

vi.mock('./skill-installer.ts', async () => {
const actual = await vi.importActual('./skill-installer.ts');
vi.mock('../lib/install/skill-installer.ts', async () => {
const actual = await vi.importActual('../lib/install/skill-installer.ts');
return {
...actual,
isSkillInstalled: vi.fn().mockResolvedValue(false),
Expand All @@ -49,21 +49,21 @@ vi.mock('./add-agents.ts', () => ({
selectAgentsInteractive: vi.fn(),
}));

vi.mock('./telemetry.ts', () => ({
vi.mock('../lib/telemetry.ts', () => ({
track: vi.fn(),
}));

vi.mock('./skill-lock.ts', () => ({
vi.mock('../lib/lock/skill-lock.ts', () => ({
addSkillToLock: vi.fn(),
}));

vi.mock('./local-lock.ts', () => ({
vi.mock('../lib/lock/local-lock.ts', () => ({
addSkillToLocalLock: vi.fn(),
computeSkillFolderHash: vi.fn().mockResolvedValue('abc123'),
}));

vi.mock('./source-parser.ts', async () => {
const actual = await vi.importActual('./source-parser.ts');
vi.mock('../lib/parsers/source-parser.ts', async () => {
const actual = await vi.importActual('../lib/parsers/source-parser.ts');
return {
...actual,
isSourcePrivate: vi.fn().mockResolvedValue(false),
Expand All @@ -74,14 +74,14 @@ vi.mock('./source-parser.ts', async () => {

import * as p from '@clack/prompts';
import { handleWellKnownSkills } from './add-wellknown.ts';
import { wellKnownProvider } from './providers/index.ts';
import { detectInstalledAgents } from './agents.ts';
import { isSkillInstalled, installWellKnownSkillForAgent } from './skill-installer.ts';
import { track } from './telemetry.ts';
import { CommandError } from './command-result.ts';
import { addSkillToLock } from './skill-lock.ts';
import { addSkillToLocalLock, computeSkillFolderHash } from './local-lock.ts';
import { isSourcePrivate } from './source-parser.ts';
import { wellKnownProvider } from '../lib/providers/index.ts';
import { detectInstalledAgents } from '../lib/agents/index.ts';
import { isSkillInstalled, installWellKnownSkillForAgent } from '../lib/install/index.ts';
import { track } from '../lib/telemetry.ts';
import { CommandError } from '../lib/command-result.ts';
import { addSkillToLock } from '../lib/lock/index.ts';
import { addSkillToLocalLock, computeSkillFolderHash } from '../lib/lock/index.ts';
import { isSourcePrivate } from '../lib/parsers/index.ts';
import { multiselect } from './add-agents.ts';

// --- Helpers ---
Expand Down
20 changes: 10 additions & 10 deletions src/add-wellknown.ts → src/add/add-wellknown.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import * as p from '@clack/prompts';
import pc from 'picocolors';
import { isSourcePrivate } from './source-parser.ts';
import { shortenPath, formatList } from './utils.ts';
import { getCanonicalPath, installWellKnownSkillForAgent } from './skill-installer.ts';
import { agents } from './agents.ts';
import { track } from './telemetry.ts';
import { wellKnownProvider, type WellKnownSkill } from './providers/index.ts';
import { addSkillToLock } from './skill-lock.ts';
import { addSkillToLocalLock, computeSkillFolderHash } from './local-lock.ts';
import type { AgentType } from './types.ts';
import { isSourcePrivate } from '../lib/parsers/index.ts';
import { shortenPath, formatList } from '../lib/utils.ts';
import { getCanonicalPath, installWellKnownSkillForAgent } from '../lib/install/index.ts';
import { agents } from '../lib/agents/index.ts';
import { track } from '../lib/telemetry.ts';
import { wellKnownProvider, type WellKnownSkill } from '../lib/providers/index.ts';
import { addSkillToLock } from '../lib/lock/index.ts';
import { addSkillToLocalLock, computeSkillFolderHash } from '../lib/lock/index.ts';
import type { AgentType } from '../lib/types.ts';
import { buildAgentSummaryLines } from './add-display.ts';
import type { AddOptions } from './add-options.ts';
import { multiselect } from './add-agents.ts';
import { CommandError } from './command-result.ts';
import { CommandError } from '../lib/command-result.ts';
import {
resolveInstallTargets,
checkOverwrites,
Expand Down
4 changes: 2 additions & 2 deletions src/add.test.ts → src/add/add.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest';
import { existsSync, rmSync, mkdirSync, writeFileSync } from 'fs';
import { join } from 'path';
import { tmpdir } from 'os';
import { runCli } from './test-utils.ts';
import { shouldInstallInternalSkills } from './skill-discovery.ts';
import { runCli } from '../lib/test-utils.ts';
import { shouldInstallInternalSkills } from '../lib/discovery/index.ts';
import { parseAddOptions } from './add.ts';

describe('add command', () => {
Expand Down
39 changes: 24 additions & 15 deletions src/add.ts → src/add/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,40 @@ import * as p from '@clack/prompts';
import pc from 'picocolors';
import { existsSync } from 'fs';
import { sep } from 'path';
import { parseSource, getOwnerRepo, parseOwnerRepo, isRepoPrivate } from './source-parser.ts';
import { shortenPath, formatList, kebabToTitle } from './utils.ts';
import { parseSource, getOwnerRepo, parseOwnerRepo, isRepoPrivate } from '../lib/parsers/index.ts';
import { shortenPath, formatList, kebabToTitle } from '../lib/utils.ts';
import { multiselect } from './add-agents.ts';
export { promptForAgents } from './add-agents.ts';
import { cloneRepo, cleanupTempDir, GitCloneError } from './git.ts';
import { CommandError } from './command-result.ts';
import { addPrompts, addAgents, addInstructions, resolveTargetAgents } from './context-add.ts';
import { TARGET_AGENTS } from './target-agents.ts';
import { discoverSkills, getSkillDisplayName, filterSkills } from './skill-discovery.ts';
import { discover } from './context-discovery.ts';
import { installSkillForAgent, isSkillInstalled, getCanonicalPath } from './skill-installer.ts';
import { agents } from './agents.ts';
import { track, setVersion, fetchAuditData } from './telemetry.ts';
import { cloneRepo, cleanupTempDir, GitCloneError } from '../lib/git/index.ts';
import { CommandError } from '../lib/command-result.ts';
import {
addPrompts,
addAgents,
addInstructions,
resolveTargetAgents,
} from '../lib/install/index.ts';
import { TARGET_AGENTS } from '../lib/agents/index.ts';
import {
discoverSkills,
getSkillDisplayName,
filterSkills,
discover,
} from '../lib/discovery/index.ts';
import { installSkillForAgent, isSkillInstalled, getCanonicalPath } from '../lib/install/index.ts';
import { agents } from '../lib/agents/index.ts';
import { track, setVersion, fetchAuditData } from '../lib/telemetry.ts';
import { handleWellKnownSkills } from './add-wellknown.ts';
import {
addSkillToLock,
fetchSkillFolderHash,
isPromptDismissed,
dismissPrompt,
} from './skill-lock.ts';
import { addSkillToLocalLock, computeSkillFolderHash } from './local-lock.ts';
import type { Skill, AgentType, TargetAgent, ContextType } from './types.ts';
} from '../lib/lock/index.ts';
import { addSkillToLocalLock, computeSkillFolderHash } from '../lib/lock/index.ts';
import type { Skill, AgentType, TargetAgent, ContextType } from '../lib/types.ts';
import { parseAddOptions, type AddOptions } from './add-options.ts';
export { parseAddOptions, type AddOptions } from './add-options.ts';
import packageJson from '../package.json' with { type: 'json' };
import packageJson from '../../package.json' with { type: 'json' };
import { buildSecurityLines, buildAgentSummaryLines } from './add-display.ts';
import {
resolveInstallTargets,
Expand Down
3 changes: 3 additions & 0 deletions src/add/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { runAdd, initTelemetry } from './add.ts';
export { parseAddOptions, type AddOptions } from './add-options.ts';
export { promptForAgents } from './add-agents.ts';
8 changes: 4 additions & 4 deletions src/check.test.ts → src/check/check.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { findSkillUpdates } from './check.ts';
import type { SkillLockEntry } from './skill-lock.ts';
import type { SkillLockEntry } from '../lib/lock/index.ts';

// Mock fetchSkillFolderHash from skill-lock.ts
vi.mock('./skill-lock.ts', async (importOriginal) => {
const original = await importOriginal<typeof import('./skill-lock.ts')>();
vi.mock('../lib/lock/skill-lock.ts', async (importOriginal) => {
const original = await importOriginal<typeof import('../lib/lock/skill-lock.ts')>();
return {
...original,
fetchSkillFolderHash: vi.fn(),
};
});

import { fetchSkillFolderHash } from './skill-lock.ts';
import { fetchSkillFolderHash } from '../lib/lock/index.ts';
const mockFetch = vi.mocked(fetchSkillFolderHash);

function makeEntry(overrides: Partial<SkillLockEntry> = {}): SkillLockEntry {
Expand Down
Loading