@aexol/spectral 0.9.230 → 0.9.234
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.
- package/CHANGELOG.md +2 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +89 -14
- package/dist/backend/generated-images.d.ts +1 -1
- package/dist/backend/generated-images.d.ts.map +1 -1
- package/dist/commands/serve.d.ts.map +1 -1
- package/dist/commands/serve.js +12 -1
- package/dist/designer/data/skills/blog-post.d.ts +3 -0
- package/dist/designer/data/skills/blog-post.d.ts.map +1 -0
- package/dist/designer/data/skills/blog-post.js +84 -0
- package/dist/designer/data/skills/blog-post.ts +87 -0
- package/dist/designer/data/skills/critique.d.ts +3 -0
- package/dist/designer/data/skills/critique.d.ts.map +1 -0
- package/dist/designer/data/skills/critique.js +109 -0
- package/dist/designer/data/skills/critique.ts +112 -0
- package/dist/designer/data/skills/dashboard.d.ts +3 -0
- package/dist/designer/data/skills/dashboard.d.ts.map +1 -0
- package/dist/designer/data/skills/dashboard.js +165 -0
- package/dist/designer/data/skills/dashboard.ts +168 -0
- package/dist/designer/data/skills/design-brief.d.ts +3 -0
- package/dist/designer/data/skills/design-brief.d.ts.map +1 -0
- package/dist/designer/data/skills/design-brief.js +141 -0
- package/dist/designer/data/skills/design-brief.ts +144 -0
- package/dist/designer/data/skills/design-skill.d.ts +10 -0
- package/dist/designer/data/skills/design-skill.d.ts.map +1 -0
- package/dist/designer/data/skills/design-skill.js +1 -0
- package/dist/designer/data/skills/design-skill.ts +9 -0
- package/dist/designer/data/skills/docs-page.d.ts +3 -0
- package/dist/designer/data/skills/docs-page.d.ts.map +1 -0
- package/dist/designer/data/skills/docs-page.js +68 -0
- package/dist/designer/data/skills/docs-page.ts +71 -0
- package/dist/designer/data/skills/index.d.ts +3 -0
- package/dist/designer/data/skills/index.d.ts.map +1 -0
- package/dist/designer/data/skills/index.js +28 -0
- package/dist/designer/data/skills/index.ts +30 -0
- package/dist/designer/data/skills/magazine-poster.d.ts +3 -0
- package/dist/designer/data/skills/magazine-poster.d.ts.map +1 -0
- package/dist/designer/data/skills/magazine-poster.js +70 -0
- package/dist/designer/data/skills/magazine-poster.ts +73 -0
- package/dist/designer/data/skills/mobile-app.d.ts +3 -0
- package/dist/designer/data/skills/mobile-app.d.ts.map +1 -0
- package/dist/designer/data/skills/mobile-app.js +229 -0
- package/dist/designer/data/skills/mobile-app.ts +232 -0
- package/dist/designer/data/skills/motion-frames.d.ts +3 -0
- package/dist/designer/data/skills/motion-frames.d.ts.map +1 -0
- package/dist/designer/data/skills/motion-frames.js +121 -0
- package/dist/designer/data/skills/motion-frames.ts +124 -0
- package/dist/designer/data/skills/pricing-page.d.ts +3 -0
- package/dist/designer/data/skills/pricing-page.d.ts.map +1 -0
- package/dist/designer/data/skills/pricing-page.js +76 -0
- package/dist/designer/data/skills/pricing-page.ts +79 -0
- package/dist/designer/data/skills/saas-landing.d.ts +3 -0
- package/dist/designer/data/skills/saas-landing.d.ts.map +1 -0
- package/dist/designer/data/skills/saas-landing.js +71 -0
- package/dist/designer/data/skills/saas-landing.ts +74 -0
- package/dist/designer/data/skills/slide-deck.d.ts +3 -0
- package/dist/designer/data/skills/slide-deck.d.ts.map +1 -0
- package/dist/designer/data/skills/slide-deck.js +213 -0
- package/dist/designer/data/skills/slide-deck.ts +216 -0
- package/dist/designer/data/skills/social-carousel.d.ts +3 -0
- package/dist/designer/data/skills/social-carousel.d.ts.map +1 -0
- package/dist/designer/data/skills/social-carousel.js +135 -0
- package/dist/designer/data/skills/social-carousel.ts +138 -0
- package/dist/designer/data/skills/web-prototype.d.ts +3 -0
- package/dist/designer/data/skills/web-prototype.d.ts.map +1 -0
- package/dist/designer/data/skills/web-prototype.js +159 -0
- package/dist/designer/data/skills/web-prototype.ts +162 -0
- package/dist/designer/skills.d.ts +4 -10
- package/dist/designer/skills.d.ts.map +1 -1
- package/dist/designer/skills.js +2 -1643
- package/dist/extensions/logic-trace.d.ts +1 -1
- package/dist/extensions/logic-trace.d.ts.map +1 -1
- package/dist/extensions/logic-trace.js +199 -70
- package/dist/extensions/video-generation/index.d.ts +3 -0
- package/dist/extensions/video-generation/index.d.ts.map +1 -0
- package/dist/extensions/video-generation/index.js +299 -0
- package/dist/extensions/wizard/index.js +9 -1
- package/dist/generated/parser/ast/nodes.d.ts +115 -0
- package/dist/generated/parser/ast/nodes.d.ts.map +1 -0
- package/dist/generated/parser/ast/nodes.js +8 -0
- package/dist/generated/parser/lexer/lexer.d.ts +28 -0
- package/dist/generated/parser/lexer/lexer.d.ts.map +1 -0
- package/dist/generated/parser/{lexer.js → lexer/lexer.js} +1 -180
- package/dist/generated/parser/{lexer.d.ts → lexer/tokens.d.ts} +5 -24
- package/dist/generated/parser/lexer/tokens.d.ts.map +1 -0
- package/dist/generated/parser/lexer/tokens.js +187 -0
- package/dist/generated/parser/mod.d.ts +5 -7
- package/dist/generated/parser/mod.d.ts.map +1 -1
- package/dist/generated/parser/mod.js +2 -1
- package/dist/generated/parser/parser/cursor.d.ts +47 -0
- package/dist/generated/parser/parser/cursor.d.ts.map +1 -0
- package/dist/generated/parser/parser/cursor.js +12 -0
- package/dist/generated/parser/parser/definitions.d.ts +16 -0
- package/dist/generated/parser/parser/definitions.d.ts.map +1 -0
- package/dist/generated/parser/parser/definitions.js +353 -0
- package/dist/generated/parser/parser/expressions.d.ts +17 -0
- package/dist/generated/parser/parser/expressions.d.ts.map +1 -0
- package/dist/generated/parser/parser/expressions.js +165 -0
- package/dist/generated/parser/parser.d.ts +18 -133
- package/dist/generated/parser/parser.d.ts.map +1 -1
- package/dist/generated/parser/parser.js +9 -505
- package/dist/generated/parser/tokenizer.d.ts +1 -2
- package/dist/generated/parser/tokenizer.d.ts.map +1 -1
- package/dist/generated/parser/tokenizer.js +2 -1
- package/dist/generated/parser/validator.d.ts +1 -1
- package/dist/generated/parser/validator.d.ts.map +1 -1
- package/dist/generated/zeus/const.d.ts.map +1 -1
- package/dist/generated/zeus/const.js +30 -0
- package/dist/generated/zeus/index.d.ts +140 -0
- package/dist/generated/zeus/index.d.ts.map +1 -1
- package/dist/generated/zeus/index.js +5 -0
- package/dist/mcp/glimpse-ui.js +9 -1
- package/dist/relay/dispatcher.d.ts +23 -104
- package/dist/relay/dispatcher.d.ts.map +1 -1
- package/dist/relay/dispatcher.js +21 -1130
- package/dist/relay/rest.d.ts +31 -0
- package/dist/relay/rest.d.ts.map +1 -0
- package/dist/relay/rest.js +85 -0
- package/dist/relay/routing.d.ts +109 -0
- package/dist/relay/routing.d.ts.map +1 -0
- package/dist/relay/routing.js +669 -0
- package/dist/relay/wizard-login.d.ts +17 -0
- package/dist/relay/wizard-login.d.ts.map +1 -0
- package/dist/relay/wizard-login.js +419 -0
- package/dist/sdk/agent-core/agent-loop.d.ts +2 -9
- package/dist/sdk/agent-core/agent-loop.d.ts.map +1 -1
- package/dist/sdk/agent-core/agent-loop.js +17 -291
- package/dist/sdk/agent-core/agent.d.ts +11 -4
- package/dist/sdk/agent-core/agent.d.ts.map +1 -1
- package/dist/sdk/agent-core/agent.js +16 -4
- package/dist/sdk/agent-core/tool-call-registry.d.ts +75 -0
- package/dist/sdk/agent-core/tool-call-registry.d.ts.map +1 -0
- package/dist/sdk/agent-core/tool-call-registry.js +131 -0
- package/dist/sdk/agent-core/tool-execution.d.ts +33 -0
- package/dist/sdk/agent-core/tool-execution.d.ts.map +1 -0
- package/dist/sdk/agent-core/tool-execution.js +399 -0
- package/dist/sdk/agent-core/types.d.ts +15 -4
- package/dist/sdk/agent-core/types.d.ts.map +1 -1
- package/dist/sdk/ai/env-api-keys.js +9 -1
- package/dist/sdk/ai/index.d.ts +3 -0
- package/dist/sdk/ai/index.d.ts.map +1 -1
- package/dist/sdk/ai/index.js +3 -0
- package/dist/sdk/ai/providers/faux.d.ts.map +1 -1
- package/dist/sdk/ai/providers/faux.js +3 -0
- package/dist/sdk/ai/providers/leaked-tool-call-parser.d.ts +39 -6
- package/dist/sdk/ai/providers/leaked-tool-call-parser.d.ts.map +1 -1
- package/dist/sdk/ai/providers/leaked-tool-call-parser.js +159 -18
- package/dist/sdk/ai/providers/openai/reasoning-replay.d.ts +48 -0
- package/dist/sdk/ai/providers/openai/reasoning-replay.d.ts.map +1 -0
- package/dist/sdk/ai/providers/openai/reasoning-replay.js +209 -0
- package/dist/sdk/ai/providers/openai-completions.d.ts.map +1 -1
- package/dist/sdk/ai/providers/openai-completions.js +23 -211
- package/dist/sdk/ai/providers/openrouter-videos.d.ts +3 -0
- package/dist/sdk/ai/providers/openrouter-videos.d.ts.map +1 -0
- package/dist/sdk/ai/providers/openrouter-videos.js +412 -0
- package/dist/sdk/ai/providers/register-builtins.d.ts.map +1 -1
- package/dist/sdk/ai/providers/register-builtins.js +6 -0
- package/dist/sdk/ai/providers/simple-options.d.ts +1 -6
- package/dist/sdk/ai/providers/simple-options.d.ts.map +1 -1
- package/dist/sdk/ai/providers/simple-options.js +0 -22
- package/dist/sdk/ai/providers/transform-messages.d.ts.map +1 -1
- package/dist/sdk/ai/providers/transform-messages.js +52 -1
- package/dist/sdk/ai/types.d.ts +91 -10
- package/dist/sdk/ai/types.d.ts.map +1 -1
- package/dist/sdk/ai/video-models.d.ts +10 -0
- package/dist/sdk/ai/video-models.d.ts.map +1 -0
- package/dist/sdk/ai/video-models.generated.d.ts +440 -0
- package/dist/sdk/ai/video-models.generated.d.ts.map +1 -0
- package/dist/sdk/ai/video-models.generated.js +441 -0
- package/dist/sdk/ai/video-models.js +22 -0
- package/dist/sdk/ai/videos-api-registry.d.ts +14 -0
- package/dist/sdk/ai/videos-api-registry.d.ts.map +1 -0
- package/dist/sdk/ai/videos-api-registry.js +21 -0
- package/dist/sdk/ai/videos.d.ts +4 -0
- package/dist/sdk/ai/videos.d.ts.map +1 -0
- package/dist/sdk/ai/videos.js +13 -0
- package/dist/sdk/coding-agent/core/agent-session.d.ts +8 -0
- package/dist/sdk/coding-agent/core/agent-session.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/agent-session.js +11 -0
- package/dist/sdk/coding-agent/core/compaction/compaction.d.ts +6 -118
- package/dist/sdk/coding-agent/core/compaction/compaction.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/compaction/compaction.js +11 -733
- package/dist/sdk/coding-agent/core/compaction/cut-points.d.ts +58 -0
- package/dist/sdk/coding-agent/core/compaction/cut-points.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/compaction/cut-points.js +191 -0
- package/dist/sdk/coding-agent/core/compaction/dedupe.d.ts +28 -0
- package/dist/sdk/coding-agent/core/compaction/dedupe.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/compaction/dedupe.js +156 -0
- package/dist/sdk/coding-agent/core/compaction/summarize.d.ts +21 -0
- package/dist/sdk/coding-agent/core/compaction/summarize.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/compaction/summarize.js +181 -0
- package/dist/sdk/coding-agent/core/compaction/tokens.d.ts +47 -0
- package/dist/sdk/coding-agent/core/compaction/tokens.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/compaction/tokens.js +224 -0
- package/dist/sdk/coding-agent/core/extensions/loader.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/extensions/loader.js +14 -0
- package/dist/sdk/coding-agent/core/extensions/native-extensions.d.ts +26 -0
- package/dist/sdk/coding-agent/core/extensions/native-extensions.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/extensions/native-extensions.js +23 -0
- package/dist/sdk/coding-agent/core/extensions/session-events.d.ts +157 -0
- package/dist/sdk/coding-agent/core/extensions/session-events.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/extensions/session-events.js +13 -0
- package/dist/sdk/coding-agent/core/extensions/types.d.ts +10 -367
- package/dist/sdk/coding-agent/core/extensions/types.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/extensions/types.js +2 -10
- package/dist/sdk/coding-agent/core/extensions/ui-types.d.ts +219 -0
- package/dist/sdk/coding-agent/core/extensions/ui-types.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/extensions/ui-types.js +4 -0
- package/dist/sdk/coding-agent/core/messages.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/messages.js +42 -2
- package/dist/sdk/coding-agent/core/package/default-package-manager.d.ts +115 -0
- package/dist/sdk/coding-agent/core/package/default-package-manager.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/package/default-package-manager.js +1184 -0
- package/dist/sdk/coding-agent/core/package/discovery.d.ts +20 -0
- package/dist/sdk/coding-agent/core/package/discovery.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/package/discovery.js +283 -0
- package/dist/sdk/coding-agent/core/package/ignore.d.ts +29 -0
- package/dist/sdk/coding-agent/core/package/ignore.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/package/ignore.js +235 -0
- package/dist/sdk/coding-agent/core/package/types.d.ts +128 -0
- package/dist/sdk/coding-agent/core/package/types.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/package/types.js +18 -0
- package/dist/sdk/coding-agent/core/package/update-check.d.ts +43 -0
- package/dist/sdk/coding-agent/core/package/update-check.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/package/update-check.js +253 -0
- package/dist/sdk/coding-agent/core/package-manager.d.ts +2 -188
- package/dist/sdk/coding-agent/core/package-manager.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/package-manager.js +1 -1940
- package/dist/sdk/coding-agent/core/resource-loader.d.ts +11 -0
- package/dist/sdk/coding-agent/core/resource-loader.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/resource-loader.js +23 -6
- package/dist/sdk/coding-agent/core/sdk.d.ts +24 -2
- package/dist/sdk/coding-agent/core/sdk.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/sdk.js +15 -3
- package/dist/sdk/coding-agent/core/session/migrate.d.ts +18 -0
- package/dist/sdk/coding-agent/core/session/migrate.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/session/migrate.js +78 -0
- package/dist/sdk/coding-agent/core/session/types.d.ts +165 -0
- package/dist/sdk/coding-agent/core/session/types.d.ts.map +1 -0
- package/dist/sdk/coding-agent/core/session/types.js +4 -0
- package/dist/sdk/coding-agent/core/session-manager.d.ts +3 -161
- package/dist/sdk/coding-agent/core/session-manager.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/session-manager.js +4 -72
- package/dist/sdk/coding-agent/core/settings-manager.d.ts +0 -8
- package/dist/sdk/coding-agent/core/settings-manager.d.ts.map +1 -1
- package/dist/sdk/coding-agent/core/settings-manager.js +3 -3
- package/dist/sdk/coding-agent/index.d.ts +2 -2
- package/dist/sdk/coding-agent/index.d.ts.map +1 -1
- package/dist/sdk/coding-agent/index.js +1 -1
- package/dist/sdk-public.d.ts +96 -0
- package/dist/sdk-public.d.ts.map +1 -0
- package/dist/sdk-public.js +109 -0
- package/dist/server/agent-bridge/rehydrate.d.ts +2 -2
- package/dist/server/agent-bridge/rehydrate.d.ts.map +1 -1
- package/dist/server/agent-bridge/rehydrate.js +14 -0
- package/dist/server/agent-bridge.d.ts +8 -2
- package/dist/server/agent-bridge.d.ts.map +1 -1
- package/dist/server/agent-bridge.js +25 -2
- package/dist/server/session-stream.d.ts +19 -0
- package/dist/server/session-stream.d.ts.map +1 -1
- package/dist/server/session-stream.js +35 -0
- package/dist/server/wire.d.ts +13 -0
- package/dist/server/wire.d.ts.map +1 -1
- package/package.json +8 -2
- package/dist/generated/parser/lexer.d.ts.map +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type IgnoreMatcher } from "./ignore.js";
|
|
2
|
+
import type { ResourceType, SpectralManifest } from "./types.js";
|
|
3
|
+
export declare const RESOURCE_TYPES: ResourceType[];
|
|
4
|
+
export declare const FILE_PATTERNS: Record<ResourceType, RegExp>;
|
|
5
|
+
export type SkillDiscoveryMode = "spectral" | "agents";
|
|
6
|
+
export declare function collectSkillEntries(dir: string, mode: SkillDiscoveryMode, ignoreMatcher?: IgnoreMatcher, rootDir?: string): string[];
|
|
7
|
+
export declare function collectAutoSkillEntries(dir: string, mode: SkillDiscoveryMode): string[];
|
|
8
|
+
export declare function findGitRepoRoot(startDir: string): string | null;
|
|
9
|
+
export declare function collectAncestorAgentsSkillDirs(startDir: string): string[];
|
|
10
|
+
export declare function collectAutoPromptEntries(dir: string): string[];
|
|
11
|
+
export declare function collectAutoThemeEntries(dir: string): string[];
|
|
12
|
+
export declare function readSpectralManifestFile(packageJsonPath: string): SpectralManifest | null;
|
|
13
|
+
export declare function resolveExtensionEntries(dir: string): string[] | null;
|
|
14
|
+
export declare function collectAutoExtensionEntries(dir: string): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Collect resource files from a directory based on resource type.
|
|
17
|
+
* Extensions use smart discovery (index.ts in subdirs), others use recursive collection.
|
|
18
|
+
*/
|
|
19
|
+
export declare function collectResourceFiles(dir: string, resourceType: ResourceType): string[];
|
|
20
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../../../src/sdk/coding-agent/core/package/discovery.ts"],"names":[],"mappings":"AAGA,OAAO,EAA6C,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEjE,eAAO,MAAM,cAAc,EAAE,YAAY,EAAkD,CAAC;AAE5F,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAKtD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEvD,wBAAgB,mBAAmB,CAClC,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,kBAAkB,EACxB,aAAa,CAAC,EAAE,aAAa,EAC7B,OAAO,CAAC,EAAE,MAAM,GACd,MAAM,EAAE,CAmEV;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,MAAM,EAAE,CAEvF;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAY/D;AAED,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBzE;AAED,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAmC9D;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAmC7D;AAED,wBAAgB,wBAAwB,CAAC,eAAe,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAQzF;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CA4BpE;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAoDjE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,MAAM,EAAE,CAQtF"}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
3
|
+
import ignore from "ignore";
|
|
4
|
+
import { addIgnoreRules, collectFiles, toPosixPath } from "./ignore.js";
|
|
5
|
+
export const RESOURCE_TYPES = ["extensions", "skills", "prompts", "themes"];
|
|
6
|
+
export const FILE_PATTERNS = {
|
|
7
|
+
extensions: /\.(ts|js)$/,
|
|
8
|
+
skills: /\.md$/,
|
|
9
|
+
prompts: /\.md$/,
|
|
10
|
+
themes: /\.json$/,
|
|
11
|
+
};
|
|
12
|
+
export function collectSkillEntries(dir, mode, ignoreMatcher, rootDir) {
|
|
13
|
+
const entries = [];
|
|
14
|
+
if (!existsSync(dir))
|
|
15
|
+
return entries;
|
|
16
|
+
const root = rootDir ?? dir;
|
|
17
|
+
const ig = ignoreMatcher ?? ignore();
|
|
18
|
+
addIgnoreRules(ig, dir, root);
|
|
19
|
+
try {
|
|
20
|
+
const dirEntries = readdirSync(dir, { withFileTypes: true });
|
|
21
|
+
for (const entry of dirEntries) {
|
|
22
|
+
if (entry.name !== "SKILL.md") {
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const fullPath = join(dir, entry.name);
|
|
26
|
+
let isFile = entry.isFile();
|
|
27
|
+
if (entry.isSymbolicLink()) {
|
|
28
|
+
try {
|
|
29
|
+
isFile = statSync(fullPath).isFile();
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const relPath = toPosixPath(relative(root, fullPath));
|
|
36
|
+
if (isFile && !ig.ignores(relPath)) {
|
|
37
|
+
entries.push(fullPath);
|
|
38
|
+
return entries;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
for (const entry of dirEntries) {
|
|
42
|
+
if (entry.name.startsWith("."))
|
|
43
|
+
continue;
|
|
44
|
+
if (entry.name === "node_modules")
|
|
45
|
+
continue;
|
|
46
|
+
const fullPath = join(dir, entry.name);
|
|
47
|
+
let isDir = entry.isDirectory();
|
|
48
|
+
let isFile = entry.isFile();
|
|
49
|
+
if (entry.isSymbolicLink()) {
|
|
50
|
+
try {
|
|
51
|
+
const stats = statSync(fullPath);
|
|
52
|
+
isDir = stats.isDirectory();
|
|
53
|
+
isFile = stats.isFile();
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const relPath = toPosixPath(relative(root, fullPath));
|
|
60
|
+
if (mode === "spectral" && dir === root && isFile && entry.name.endsWith(".md") && !ig.ignores(relPath)) {
|
|
61
|
+
entries.push(fullPath);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (!isDir)
|
|
65
|
+
continue;
|
|
66
|
+
if (ig.ignores(`${relPath}/`))
|
|
67
|
+
continue;
|
|
68
|
+
entries.push(...collectSkillEntries(fullPath, mode, ig, root));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// Ignore errors
|
|
73
|
+
}
|
|
74
|
+
return entries;
|
|
75
|
+
}
|
|
76
|
+
export function collectAutoSkillEntries(dir, mode) {
|
|
77
|
+
return collectSkillEntries(dir, mode);
|
|
78
|
+
}
|
|
79
|
+
export function findGitRepoRoot(startDir) {
|
|
80
|
+
let dir = resolve(startDir);
|
|
81
|
+
while (true) {
|
|
82
|
+
if (existsSync(join(dir, ".git"))) {
|
|
83
|
+
return dir;
|
|
84
|
+
}
|
|
85
|
+
const parent = dirname(dir);
|
|
86
|
+
if (parent === dir) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
dir = parent;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
export function collectAncestorAgentsSkillDirs(startDir) {
|
|
93
|
+
const skillDirs = [];
|
|
94
|
+
const resolvedStartDir = resolve(startDir);
|
|
95
|
+
const gitRepoRoot = findGitRepoRoot(resolvedStartDir);
|
|
96
|
+
let dir = resolvedStartDir;
|
|
97
|
+
while (true) {
|
|
98
|
+
skillDirs.push(join(dir, ".agents", "skills"));
|
|
99
|
+
if (gitRepoRoot && dir === gitRepoRoot) {
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
const parent = dirname(dir);
|
|
103
|
+
if (parent === dir) {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
dir = parent;
|
|
107
|
+
}
|
|
108
|
+
return skillDirs;
|
|
109
|
+
}
|
|
110
|
+
export function collectAutoPromptEntries(dir) {
|
|
111
|
+
const entries = [];
|
|
112
|
+
if (!existsSync(dir))
|
|
113
|
+
return entries;
|
|
114
|
+
const ig = ignore();
|
|
115
|
+
addIgnoreRules(ig, dir, dir);
|
|
116
|
+
try {
|
|
117
|
+
const dirEntries = readdirSync(dir, { withFileTypes: true });
|
|
118
|
+
for (const entry of dirEntries) {
|
|
119
|
+
if (entry.name.startsWith("."))
|
|
120
|
+
continue;
|
|
121
|
+
if (entry.name === "node_modules")
|
|
122
|
+
continue;
|
|
123
|
+
const fullPath = join(dir, entry.name);
|
|
124
|
+
let isFile = entry.isFile();
|
|
125
|
+
if (entry.isSymbolicLink()) {
|
|
126
|
+
try {
|
|
127
|
+
isFile = statSync(fullPath).isFile();
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const relPath = toPosixPath(relative(dir, fullPath));
|
|
134
|
+
if (ig.ignores(relPath))
|
|
135
|
+
continue;
|
|
136
|
+
if (isFile && entry.name.endsWith(".md")) {
|
|
137
|
+
entries.push(fullPath);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
// Ignore errors
|
|
143
|
+
}
|
|
144
|
+
return entries;
|
|
145
|
+
}
|
|
146
|
+
export function collectAutoThemeEntries(dir) {
|
|
147
|
+
const entries = [];
|
|
148
|
+
if (!existsSync(dir))
|
|
149
|
+
return entries;
|
|
150
|
+
const ig = ignore();
|
|
151
|
+
addIgnoreRules(ig, dir, dir);
|
|
152
|
+
try {
|
|
153
|
+
const dirEntries = readdirSync(dir, { withFileTypes: true });
|
|
154
|
+
for (const entry of dirEntries) {
|
|
155
|
+
if (entry.name.startsWith("."))
|
|
156
|
+
continue;
|
|
157
|
+
if (entry.name === "node_modules")
|
|
158
|
+
continue;
|
|
159
|
+
const fullPath = join(dir, entry.name);
|
|
160
|
+
let isFile = entry.isFile();
|
|
161
|
+
if (entry.isSymbolicLink()) {
|
|
162
|
+
try {
|
|
163
|
+
isFile = statSync(fullPath).isFile();
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const relPath = toPosixPath(relative(dir, fullPath));
|
|
170
|
+
if (ig.ignores(relPath))
|
|
171
|
+
continue;
|
|
172
|
+
if (isFile && entry.name.endsWith(".json")) {
|
|
173
|
+
entries.push(fullPath);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
// Ignore errors
|
|
179
|
+
}
|
|
180
|
+
return entries;
|
|
181
|
+
}
|
|
182
|
+
export function readSpectralManifestFile(packageJsonPath) {
|
|
183
|
+
try {
|
|
184
|
+
const content = readFileSync(packageJsonPath, "utf-8");
|
|
185
|
+
const pkg = JSON.parse(content);
|
|
186
|
+
return pkg.spectral ?? null;
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
export function resolveExtensionEntries(dir) {
|
|
193
|
+
const packageJsonPath = join(dir, "package.json");
|
|
194
|
+
if (existsSync(packageJsonPath)) {
|
|
195
|
+
const manifest = readSpectralManifestFile(packageJsonPath);
|
|
196
|
+
if (manifest?.extensions?.length) {
|
|
197
|
+
const entries = [];
|
|
198
|
+
for (const extPath of manifest.extensions) {
|
|
199
|
+
const resolvedExtPath = resolve(dir, extPath);
|
|
200
|
+
if (existsSync(resolvedExtPath)) {
|
|
201
|
+
entries.push(resolvedExtPath);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (entries.length > 0) {
|
|
205
|
+
return entries;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
const indexTs = join(dir, "index.ts");
|
|
210
|
+
const indexJs = join(dir, "index.js");
|
|
211
|
+
if (existsSync(indexTs)) {
|
|
212
|
+
return [indexTs];
|
|
213
|
+
}
|
|
214
|
+
if (existsSync(indexJs)) {
|
|
215
|
+
return [indexJs];
|
|
216
|
+
}
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
export function collectAutoExtensionEntries(dir) {
|
|
220
|
+
const entries = [];
|
|
221
|
+
if (!existsSync(dir))
|
|
222
|
+
return entries;
|
|
223
|
+
// First check if this directory itself has explicit extension entries (package.json or index)
|
|
224
|
+
const rootEntries = resolveExtensionEntries(dir);
|
|
225
|
+
if (rootEntries) {
|
|
226
|
+
return rootEntries;
|
|
227
|
+
}
|
|
228
|
+
// Otherwise, discover extensions from directory contents
|
|
229
|
+
const ig = ignore();
|
|
230
|
+
addIgnoreRules(ig, dir, dir);
|
|
231
|
+
try {
|
|
232
|
+
const dirEntries = readdirSync(dir, { withFileTypes: true });
|
|
233
|
+
for (const entry of dirEntries) {
|
|
234
|
+
if (entry.name.startsWith("."))
|
|
235
|
+
continue;
|
|
236
|
+
if (entry.name === "node_modules")
|
|
237
|
+
continue;
|
|
238
|
+
const fullPath = join(dir, entry.name);
|
|
239
|
+
let isDir = entry.isDirectory();
|
|
240
|
+
let isFile = entry.isFile();
|
|
241
|
+
if (entry.isSymbolicLink()) {
|
|
242
|
+
try {
|
|
243
|
+
const stats = statSync(fullPath);
|
|
244
|
+
isDir = stats.isDirectory();
|
|
245
|
+
isFile = stats.isFile();
|
|
246
|
+
}
|
|
247
|
+
catch {
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const relPath = toPosixPath(relative(dir, fullPath));
|
|
252
|
+
const ignorePath = isDir ? `${relPath}/` : relPath;
|
|
253
|
+
if (ig.ignores(ignorePath))
|
|
254
|
+
continue;
|
|
255
|
+
if (isFile && (entry.name.endsWith(".ts") || entry.name.endsWith(".js"))) {
|
|
256
|
+
entries.push(fullPath);
|
|
257
|
+
}
|
|
258
|
+
else if (isDir) {
|
|
259
|
+
const resolvedEntries = resolveExtensionEntries(fullPath);
|
|
260
|
+
if (resolvedEntries) {
|
|
261
|
+
entries.push(...resolvedEntries);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
// Ignore errors
|
|
268
|
+
}
|
|
269
|
+
return entries;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Collect resource files from a directory based on resource type.
|
|
273
|
+
* Extensions use smart discovery (index.ts in subdirs), others use recursive collection.
|
|
274
|
+
*/
|
|
275
|
+
export function collectResourceFiles(dir, resourceType) {
|
|
276
|
+
if (resourceType === "skills") {
|
|
277
|
+
return collectSkillEntries(dir, "spectral");
|
|
278
|
+
}
|
|
279
|
+
if (resourceType === "extensions") {
|
|
280
|
+
return collectAutoExtensionEntries(dir);
|
|
281
|
+
}
|
|
282
|
+
return collectFiles(dir, FILE_PATTERNS[resourceType]);
|
|
283
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import ignore from "ignore";
|
|
2
|
+
export declare const IGNORE_FILE_NAMES: string[];
|
|
3
|
+
export type IgnoreMatcher = ReturnType<typeof ignore>;
|
|
4
|
+
export declare function toPosixPath(p: string): string;
|
|
5
|
+
export declare function prefixIgnorePattern(line: string, prefix: string): string | null;
|
|
6
|
+
export declare function addIgnoreRules(ig: IgnoreMatcher, dir: string, rootDir: string): void;
|
|
7
|
+
export declare function isPattern(s: string): boolean;
|
|
8
|
+
export declare function isOverridePattern(s: string): boolean;
|
|
9
|
+
export declare function hasGlobPattern(s: string): boolean;
|
|
10
|
+
export declare function splitPatterns(entries: string[]): {
|
|
11
|
+
plain: string[];
|
|
12
|
+
patterns: string[];
|
|
13
|
+
};
|
|
14
|
+
export declare function collectFiles(dir: string, filePattern: RegExp, skipNodeModules?: boolean, ignoreMatcher?: IgnoreMatcher, rootDir?: string): string[];
|
|
15
|
+
export declare function matchesAnyPattern(filePath: string, patterns: string[], baseDir: string): boolean;
|
|
16
|
+
export declare function normalizeExactPattern(pattern: string): string;
|
|
17
|
+
export declare function matchesAnyExactPattern(filePath: string, patterns: string[], baseDir: string): boolean;
|
|
18
|
+
export declare function getOverridePatterns(entries: string[]): string[];
|
|
19
|
+
export declare function isEnabledByOverrides(filePath: string, patterns: string[], baseDir: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Apply patterns to paths and return a Set of enabled paths.
|
|
22
|
+
* Pattern types:
|
|
23
|
+
* - Plain patterns: include matching paths
|
|
24
|
+
* - `!pattern`: exclude matching paths
|
|
25
|
+
* - `+path`: force-include exact path (overrides exclusions)
|
|
26
|
+
* - `-path`: force-exclude exact path (overrides force-includes)
|
|
27
|
+
*/
|
|
28
|
+
export declare function applyPatterns(allPaths: string[], patterns: string[], baseDir: string): Set<string>;
|
|
29
|
+
//# sourceMappingURL=ignore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ignore.d.ts","sourceRoot":"","sources":["../../../../../src/sdk/coding-agent/core/package/ignore.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,eAAO,MAAM,iBAAiB,UAAyC,CAAC;AAExE,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AAEtD,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAqB/E;AAED,wBAAgB,cAAc,CAAC,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAkBpF;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAE5C;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAWxF;AAED,wBAAgB,YAAY,CAC3B,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,eAAe,UAAO,EACtB,aAAa,CAAC,EAAE,aAAa,EAC7B,OAAO,CAAC,EAAE,MAAM,GACd,MAAM,EAAE,CA2CV;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CA0BhG;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAG7D;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAkBrG;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAE/D;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAiBnG;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CA8ClG"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
|
+
import { basename, dirname, join, relative, sep } from "node:path";
|
|
3
|
+
import ignore from "ignore";
|
|
4
|
+
import { minimatch } from "minimatch";
|
|
5
|
+
export const IGNORE_FILE_NAMES = [".gitignore", ".ignore", ".fdignore"];
|
|
6
|
+
export function toPosixPath(p) {
|
|
7
|
+
return p.split(sep).join("/");
|
|
8
|
+
}
|
|
9
|
+
export function prefixIgnorePattern(line, prefix) {
|
|
10
|
+
const trimmed = line.trim();
|
|
11
|
+
if (!trimmed)
|
|
12
|
+
return null;
|
|
13
|
+
if (trimmed.startsWith("#") && !trimmed.startsWith("\\#"))
|
|
14
|
+
return null;
|
|
15
|
+
let pattern = line;
|
|
16
|
+
let negated = false;
|
|
17
|
+
if (pattern.startsWith("!")) {
|
|
18
|
+
negated = true;
|
|
19
|
+
pattern = pattern.slice(1);
|
|
20
|
+
}
|
|
21
|
+
else if (pattern.startsWith("\\!")) {
|
|
22
|
+
pattern = pattern.slice(1);
|
|
23
|
+
}
|
|
24
|
+
if (pattern.startsWith("/")) {
|
|
25
|
+
pattern = pattern.slice(1);
|
|
26
|
+
}
|
|
27
|
+
const prefixed = prefix ? `${prefix}${pattern}` : pattern;
|
|
28
|
+
return negated ? `!${prefixed}` : prefixed;
|
|
29
|
+
}
|
|
30
|
+
export function addIgnoreRules(ig, dir, rootDir) {
|
|
31
|
+
const relativeDir = relative(rootDir, dir);
|
|
32
|
+
const prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : "";
|
|
33
|
+
for (const filename of IGNORE_FILE_NAMES) {
|
|
34
|
+
const ignorePath = join(dir, filename);
|
|
35
|
+
if (!existsSync(ignorePath))
|
|
36
|
+
continue;
|
|
37
|
+
try {
|
|
38
|
+
const content = readFileSync(ignorePath, "utf-8");
|
|
39
|
+
const patterns = content
|
|
40
|
+
.split(/\r?\n/)
|
|
41
|
+
.map((line) => prefixIgnorePattern(line, prefix))
|
|
42
|
+
.filter((line) => Boolean(line));
|
|
43
|
+
if (patterns.length > 0) {
|
|
44
|
+
ig.add(patterns);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch { }
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export function isPattern(s) {
|
|
51
|
+
return s.startsWith("!") || s.startsWith("+") || s.startsWith("-") || s.includes("*") || s.includes("?");
|
|
52
|
+
}
|
|
53
|
+
export function isOverridePattern(s) {
|
|
54
|
+
return s.startsWith("!") || s.startsWith("+") || s.startsWith("-");
|
|
55
|
+
}
|
|
56
|
+
export function hasGlobPattern(s) {
|
|
57
|
+
return s.includes("*") || s.includes("?");
|
|
58
|
+
}
|
|
59
|
+
export function splitPatterns(entries) {
|
|
60
|
+
const plain = [];
|
|
61
|
+
const patterns = [];
|
|
62
|
+
for (const entry of entries) {
|
|
63
|
+
if (isPattern(entry)) {
|
|
64
|
+
patterns.push(entry);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
plain.push(entry);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return { plain, patterns };
|
|
71
|
+
}
|
|
72
|
+
export function collectFiles(dir, filePattern, skipNodeModules = true, ignoreMatcher, rootDir) {
|
|
73
|
+
const files = [];
|
|
74
|
+
if (!existsSync(dir))
|
|
75
|
+
return files;
|
|
76
|
+
const root = rootDir ?? dir;
|
|
77
|
+
const ig = ignoreMatcher ?? ignore();
|
|
78
|
+
addIgnoreRules(ig, dir, root);
|
|
79
|
+
try {
|
|
80
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
81
|
+
for (const entry of entries) {
|
|
82
|
+
if (entry.name.startsWith("."))
|
|
83
|
+
continue;
|
|
84
|
+
if (skipNodeModules && entry.name === "node_modules")
|
|
85
|
+
continue;
|
|
86
|
+
const fullPath = join(dir, entry.name);
|
|
87
|
+
let isDir = entry.isDirectory();
|
|
88
|
+
let isFile = entry.isFile();
|
|
89
|
+
if (entry.isSymbolicLink()) {
|
|
90
|
+
try {
|
|
91
|
+
const stats = statSync(fullPath);
|
|
92
|
+
isDir = stats.isDirectory();
|
|
93
|
+
isFile = stats.isFile();
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const relPath = toPosixPath(relative(root, fullPath));
|
|
100
|
+
const ignorePath = isDir ? `${relPath}/` : relPath;
|
|
101
|
+
if (ig.ignores(ignorePath))
|
|
102
|
+
continue;
|
|
103
|
+
if (isDir) {
|
|
104
|
+
files.push(...collectFiles(fullPath, filePattern, skipNodeModules, ig, root));
|
|
105
|
+
}
|
|
106
|
+
else if (isFile && filePattern.test(entry.name)) {
|
|
107
|
+
files.push(fullPath);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
// Ignore errors
|
|
113
|
+
}
|
|
114
|
+
return files;
|
|
115
|
+
}
|
|
116
|
+
export function matchesAnyPattern(filePath, patterns, baseDir) {
|
|
117
|
+
const rel = toPosixPath(relative(baseDir, filePath));
|
|
118
|
+
const name = basename(filePath);
|
|
119
|
+
const filePathPosix = toPosixPath(filePath);
|
|
120
|
+
const isSkillFile = name === "SKILL.md";
|
|
121
|
+
const parentDir = isSkillFile ? dirname(filePath) : undefined;
|
|
122
|
+
const parentRel = isSkillFile ? toPosixPath(relative(baseDir, parentDir)) : undefined;
|
|
123
|
+
const parentName = isSkillFile ? basename(parentDir) : undefined;
|
|
124
|
+
const parentDirPosix = isSkillFile ? toPosixPath(parentDir) : undefined;
|
|
125
|
+
return patterns.some((pattern) => {
|
|
126
|
+
const normalizedPattern = toPosixPath(pattern);
|
|
127
|
+
if (minimatch(rel, normalizedPattern) ||
|
|
128
|
+
minimatch(name, normalizedPattern) ||
|
|
129
|
+
minimatch(filePathPosix, normalizedPattern)) {
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
if (!isSkillFile)
|
|
133
|
+
return false;
|
|
134
|
+
return (minimatch(parentRel, normalizedPattern) ||
|
|
135
|
+
minimatch(parentName, normalizedPattern) ||
|
|
136
|
+
minimatch(parentDirPosix, normalizedPattern));
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
export function normalizeExactPattern(pattern) {
|
|
140
|
+
const normalized = pattern.startsWith("./") || pattern.startsWith(".\\") ? pattern.slice(2) : pattern;
|
|
141
|
+
return toPosixPath(normalized);
|
|
142
|
+
}
|
|
143
|
+
export function matchesAnyExactPattern(filePath, patterns, baseDir) {
|
|
144
|
+
if (patterns.length === 0)
|
|
145
|
+
return false;
|
|
146
|
+
const rel = toPosixPath(relative(baseDir, filePath));
|
|
147
|
+
const name = basename(filePath);
|
|
148
|
+
const filePathPosix = toPosixPath(filePath);
|
|
149
|
+
const isSkillFile = name === "SKILL.md";
|
|
150
|
+
const parentDir = isSkillFile ? dirname(filePath) : undefined;
|
|
151
|
+
const parentRel = isSkillFile ? toPosixPath(relative(baseDir, parentDir)) : undefined;
|
|
152
|
+
const parentDirPosix = isSkillFile ? toPosixPath(parentDir) : undefined;
|
|
153
|
+
return patterns.some((pattern) => {
|
|
154
|
+
const normalized = normalizeExactPattern(pattern);
|
|
155
|
+
if (normalized === rel || normalized === filePathPosix) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
if (!isSkillFile)
|
|
159
|
+
return false;
|
|
160
|
+
return normalized === parentRel || normalized === parentDirPosix;
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
export function getOverridePatterns(entries) {
|
|
164
|
+
return entries.filter((pattern) => pattern.startsWith("!") || pattern.startsWith("+") || pattern.startsWith("-"));
|
|
165
|
+
}
|
|
166
|
+
export function isEnabledByOverrides(filePath, patterns, baseDir) {
|
|
167
|
+
const overrides = getOverridePatterns(patterns);
|
|
168
|
+
const excludes = overrides.filter((pattern) => pattern.startsWith("!")).map((pattern) => pattern.slice(1));
|
|
169
|
+
const forceIncludes = overrides.filter((pattern) => pattern.startsWith("+")).map((pattern) => pattern.slice(1));
|
|
170
|
+
const forceExcludes = overrides.filter((pattern) => pattern.startsWith("-")).map((pattern) => pattern.slice(1));
|
|
171
|
+
let enabled = true;
|
|
172
|
+
if (excludes.length > 0 && matchesAnyPattern(filePath, excludes, baseDir)) {
|
|
173
|
+
enabled = false;
|
|
174
|
+
}
|
|
175
|
+
if (forceIncludes.length > 0 && matchesAnyExactPattern(filePath, forceIncludes, baseDir)) {
|
|
176
|
+
enabled = true;
|
|
177
|
+
}
|
|
178
|
+
if (forceExcludes.length > 0 && matchesAnyExactPattern(filePath, forceExcludes, baseDir)) {
|
|
179
|
+
enabled = false;
|
|
180
|
+
}
|
|
181
|
+
return enabled;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Apply patterns to paths and return a Set of enabled paths.
|
|
185
|
+
* Pattern types:
|
|
186
|
+
* - Plain patterns: include matching paths
|
|
187
|
+
* - `!pattern`: exclude matching paths
|
|
188
|
+
* - `+path`: force-include exact path (overrides exclusions)
|
|
189
|
+
* - `-path`: force-exclude exact path (overrides force-includes)
|
|
190
|
+
*/
|
|
191
|
+
export function applyPatterns(allPaths, patterns, baseDir) {
|
|
192
|
+
const includes = [];
|
|
193
|
+
const excludes = [];
|
|
194
|
+
const forceIncludes = [];
|
|
195
|
+
const forceExcludes = [];
|
|
196
|
+
for (const p of patterns) {
|
|
197
|
+
if (p.startsWith("+")) {
|
|
198
|
+
forceIncludes.push(p.slice(1));
|
|
199
|
+
}
|
|
200
|
+
else if (p.startsWith("-")) {
|
|
201
|
+
forceExcludes.push(p.slice(1));
|
|
202
|
+
}
|
|
203
|
+
else if (p.startsWith("!")) {
|
|
204
|
+
excludes.push(p.slice(1));
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
includes.push(p);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
// Step 1: Apply includes (or all if no includes)
|
|
211
|
+
let result;
|
|
212
|
+
if (includes.length === 0) {
|
|
213
|
+
result = [...allPaths];
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
result = allPaths.filter((filePath) => matchesAnyPattern(filePath, includes, baseDir));
|
|
217
|
+
}
|
|
218
|
+
// Step 2: Apply excludes
|
|
219
|
+
if (excludes.length > 0) {
|
|
220
|
+
result = result.filter((filePath) => !matchesAnyPattern(filePath, excludes, baseDir));
|
|
221
|
+
}
|
|
222
|
+
// Step 3: Force-include (add back from allPaths, overriding exclusions)
|
|
223
|
+
if (forceIncludes.length > 0) {
|
|
224
|
+
for (const filePath of allPaths) {
|
|
225
|
+
if (!result.includes(filePath) && matchesAnyExactPattern(filePath, forceIncludes, baseDir)) {
|
|
226
|
+
result.push(filePath);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
// Step 4: Force-exclude (remove even if included or force-included)
|
|
231
|
+
if (forceExcludes.length > 0) {
|
|
232
|
+
result = result.filter((filePath) => !matchesAnyExactPattern(filePath, forceExcludes, baseDir));
|
|
233
|
+
}
|
|
234
|
+
return new Set(result);
|
|
235
|
+
}
|