Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@
"dist/",
"README.md"
]
}
}
26 changes: 22 additions & 4 deletions src/adapters/IdeDetector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,24 @@ export class IdeDetector {
/**
* Returns the list of IDE adapters to use for the given workspace.
*
* Strategy:
* 1. If forceIde is set → only that adapter
* 2. If skillTargets is set → use BOTH detected IDEs AND targeted IDEs (union)
* This ensures skills that explicitly target an IDE get installed even if
* the IDE config directory doesn't exist yet in the workspace.
* 3. If neither → auto-detect from workspace, fallback to all
*
* @param workspaceRoot - Absolute path to the workspace root directory
* @param forceIde - If provided, only return the adapter matching this IDE name (case-insensitive)
* @param forceIde - If provided, only return the adapter matching this IDE name
* @param skillTargets - If provided, also include adapters matching these targets
* @returns Array of applicable IDE adapters
* @throws SkillError(IDE_NOT_SUPPORTED) if forceIde is provided but not found
*/
async detectAll(workspaceRoot: string, forceIde?: string): Promise<IdeAdapter[]> {
async detectAll(
workspaceRoot: string,
forceIde?: string
): Promise<IdeAdapter[]> {
// Force specific IDE
if (forceIde !== undefined) {
const normalized = forceIde.toLowerCase();
const adapter = this.allAdapters.find((a) => a.name.toLowerCase() === normalized);
Expand All @@ -63,9 +75,15 @@ export class IdeDetector {
}
}

// Fallback: if none detected, return all adapters (install everywhere)
// Strict behavior: if no IDE config directories are found in the workspace,
// do not guess or fallback. Ask the user to explicitly specify.
if (detected.length === 0) {
return [...this.allAdapters];
throw new SkillError(
SkillErrorCode.IDE_NOT_SUPPORTED,
`No supported IDEs detected in the workspace.\n` +
`If you are in a fresh project, use the --ide flag to force installation for your IDE.\n` +
`Example: komerce-skill install <skill> --ide antigravity`
);
}

return detected;
Expand Down
6 changes: 5 additions & 1 deletion src/commands/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@ export async function installCommand(

if (successfulInstalls.length > 0) {
try {
const adapters = await context.ideDetector.detectAll(context.workspaceRoot, options.ide);
const adapters = await context.ideDetector.detectAll(
context.workspaceRoot,
options.ide
);

for (const adapter of adapters) {
for (const result of successfulInstalls) {
const skill = context.workspaceState.getSkill(result.namespace);
if (skill) {
try {
await adapter.install(skill, context.workspaceRoot);
console.log(` → ${adapter.name}: config generated`);
} catch (err) {
// Non-fatal: log warning but continue
const errorMessage = err instanceof Error ? err.message : String(err);
Expand Down
5 changes: 4 additions & 1 deletion src/core/Orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ export class Orchestrator {
const successful = results.filter((r) => r.success);
if (successful.length > 0) {
try {
const adapters = await this.ideDetector.detectAll(this.workspaceRoot, options.ide);
const adapters = await this.ideDetector.detectAll(
this.workspaceRoot,
options.ide
);

for (const adapter of adapters) {
for (const result of successful) {
Expand Down
Loading