@dsh-cc/skill-loader 0.5.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.
- package/LICENSE +201 -0
- package/README.i18n.yaml +6 -0
- package/README.md +75 -0
- package/README.zh.md +75 -0
- package/lib/bundled/batch.d.ts +15 -0
- package/lib/bundled/batch.d.ts.map +1 -0
- package/lib/bundled/batch.js +97 -0
- package/lib/bundled/batch.js.map +1 -0
- package/lib/bundled/debug.d.ts +14 -0
- package/lib/bundled/debug.d.ts.map +1 -0
- package/lib/bundled/debug.js +51 -0
- package/lib/bundled/debug.js.map +1 -0
- package/lib/bundled/index.d.ts +36 -0
- package/lib/bundled/index.d.ts.map +1 -0
- package/lib/bundled/index.js +47 -0
- package/lib/bundled/index.js.map +1 -0
- package/lib/bundled/simplify.d.ts +12 -0
- package/lib/bundled/simplify.d.ts.map +1 -0
- package/lib/bundled/simplify.js +67 -0
- package/lib/bundled/simplify.js.map +1 -0
- package/lib/discovery.d.ts +70 -0
- package/lib/discovery.d.ts.map +1 -0
- package/lib/discovery.js +165 -0
- package/lib/discovery.js.map +1 -0
- package/lib/frontmatter.d.ts +72 -0
- package/lib/frontmatter.d.ts.map +1 -0
- package/lib/frontmatter.js +200 -0
- package/lib/frontmatter.js.map +1 -0
- package/lib/index.d.ts +100 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +343 -0
- package/lib/index.js.map +1 -0
- package/lib/invariant.d.ts +16 -0
- package/lib/invariant.d.ts.map +1 -0
- package/lib/invariant.js +22 -0
- package/lib/invariant.js.map +1 -0
- package/lib/render.d.ts +111 -0
- package/lib/render.d.ts.map +1 -0
- package/lib/render.js +179 -0
- package/lib/render.js.map +1 -0
- package/lib/translate.d.ts +66 -0
- package/lib/translate.d.ts.map +1 -0
- package/lib/translate.js +134 -0
- package/lib/translate.js.map +1 -0
- package/lib/types.d.ts +46 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +8 -0
- package/lib/types.js.map +1 -0
- package/package.json +59 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundled skills shipped with this compatible provider.
|
|
3
|
+
*
|
|
4
|
+
* A portable subset of Claude Code's own bundled skills (`~/workspace/github.com/claude-code/skills/bundled/`),
|
|
5
|
+
* authored as `SKILL.md` documents and served directly from this package — no
|
|
6
|
+
* disk extraction. They are provided with `source: 'bundled'` and the registry's
|
|
7
|
+
* `BUNDLED_SKILL_RANK`, so any project, user, managed, or additional skill of the
|
|
8
|
+
* same name wins the name conflict — matching Claude Code's precedence where
|
|
9
|
+
* local skills override built-ins.
|
|
10
|
+
*
|
|
11
|
+
* Only self-contained, harness-portable skills are included; ant-only skills
|
|
12
|
+
* (`verify`, `stuck`) and claude.ai/vendor-bound skills are excluded.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
import { isSkillName } from '@deepseek-ai/dsh-skill';
|
|
17
|
+
import { parseCcFrontmatter, parseCcFrontmatterDocument, } from "../frontmatter.js";
|
|
18
|
+
import { SKILL_MD as BATCH_MD, name as batchName } from "./batch.js";
|
|
19
|
+
import { SKILL_MD as DEBUG_MD, name as debugName } from "./debug.js";
|
|
20
|
+
import { SKILL_MD as SIMPLIFY_MD, name as simplifyName } from "./simplify.js";
|
|
21
|
+
const ENTRIES = [
|
|
22
|
+
{ name: debugName, md: DEBUG_MD },
|
|
23
|
+
{ name: simplifyName, md: SIMPLIFY_MD },
|
|
24
|
+
{ name: batchName, md: BATCH_MD },
|
|
25
|
+
];
|
|
26
|
+
/** Parse the in-package bundled skill set once. Skills with missing or invalid names are skipped. */
|
|
27
|
+
export function discoverBundledSkills() {
|
|
28
|
+
const result = [];
|
|
29
|
+
for (const { name, md } of ENTRIES) {
|
|
30
|
+
const parsed = parseCcFrontmatter(md);
|
|
31
|
+
if (parsed === undefined || parsed.name === undefined || !isSkillName(parsed.name))
|
|
32
|
+
continue;
|
|
33
|
+
if (parsed.name !== name)
|
|
34
|
+
continue;
|
|
35
|
+
const body = parseCcFrontmatterDocument(md)?.body ?? '';
|
|
36
|
+
result.push({
|
|
37
|
+
kind: 'bundled',
|
|
38
|
+
name,
|
|
39
|
+
directory: `bundled:${name}`,
|
|
40
|
+
path: `bundled:${name}/SKILL.md`,
|
|
41
|
+
body,
|
|
42
|
+
parsed: { ...parsed, name },
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bundled/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EACL,kBAAkB,EAClB,0BAA0B,GAE3B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,QAAQ,IAAI,QAAQ,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAA;AACpE,OAAO,EAAE,QAAQ,IAAI,QAAQ,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAA;AACpE,OAAO,EAAE,QAAQ,IAAI,WAAW,EAAE,IAAI,IAAI,YAAY,EAAE,MAAM,eAAe,CAAA;AAkB7E,MAAM,OAAO,GAA8D;IACzE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE;IACjC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,WAAW,EAAE;IACvC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE;CAClC,CAAA;AAED,qGAAqG;AACrG,MAAM,UAAU,qBAAqB;IACnC,MAAM,MAAM,GAAuB,EAAE,CAAA;IACrC,KAAK,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,OAAO,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC,CAAA;QACrC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;YAAE,SAAQ;QAC5F,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI;YAAE,SAAQ;QAClC,MAAM,IAAI,GAAG,0BAA0B,CAAC,EAAE,CAAC,EAAE,IAAI,IAAI,EAAE,CAAA;QACvD,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,SAAS;YACf,IAAI;YACJ,SAAS,EAAE,WAAW,IAAI,EAAE;YAC5B,IAAI,EAAE,WAAW,IAAI,WAAW;YAChC,IAAI;YACJ,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,IAAI,EAAE;SAC5B,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ported Claude Code bundled `simplify` skill.
|
|
3
|
+
*
|
|
4
|
+
* Source: `~/workspace/github.com/claude-code/skills/bundled/simplify.ts`. The
|
|
5
|
+
* original author tool reference (`${AGENT_TOOL_NAME}`, the `Agent` tool) is
|
|
6
|
+
* kept as a literal template placeholder; the body is otherwise verbatim.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
export declare const name = "simplify";
|
|
11
|
+
export declare const SKILL_MD = "---\nname: simplify\ndescription: Review changed code for reuse, quality, and efficiency, then fix any issues found.\nuser-invocable: true\n---\n\n# Simplify: Code Review and Cleanup\n\nReview all changed files for reuse, quality, and efficiency. Fix any issues found.\n\n## Phase 1: Identify Changes\n\nRun `git diff` (or `git diff HEAD` if there are staged changes) to see what changed. If there are no git changes, review the most recently modified files that the user mentioned or that you edited earlier in this conversation.\n\n## Phase 2: Launch Three Review Agents in Parallel\n\nUse the ${AGENT_TOOL_NAME} tool to launch all three agents concurrently in a single message. Pass each agent the full diff so it has the complete context.\n\n### Agent 1: Code Reuse Review\n\nFor each change:\n\n1. **Search for existing utilities and helpers** that could replace newly written code. Look for similar patterns elsewhere in the codebase \u2014 common locations are utility directories, shared modules, and files adjacent to the changed ones.\n2. **Flag any new function that duplicates existing functionality.** Suggest the existing function to use instead.\n3. **Flag any inline logic that could use an existing utility** \u2014 hand-rolled string manipulation, manual path handling, custom environment checks, ad-hoc type guards, and similar patterns are common candidates.\n\n### Agent 2: Code Quality Review\n\nReview the same changes for hacky patterns:\n\n1. **Redundant state**: state that duplicates existing state, cached values that could be derived, observers/effects that could be direct calls\n2. **Parameter sprawl**: adding new parameters to a function instead of generalizing or restructuring existing ones\n3. **Copy-paste with slight variation**: near-duplicate code blocks that should be unified with a shared abstraction\n4. **Leaky abstractions**: exposing internal details that should be encapsulated, or breaking existing abstraction boundaries\n5. **Stringly-typed code**: using raw strings where constants, enums (string unions), or branded types already exist in the codebase\n6. **Unnecessary JSX nesting**: wrapper Boxes/elements that add no layout value \u2014 check if inner component props (flexShrink, alignItems, etc.) already provide the needed behavior\n7. **Unnecessary comments**: comments explaining WHAT the code does (well-named identifiers already do that), narrating the change, or referencing the task/caller \u2014 delete; keep only non-obvious WHY (hidden constraints, subtle invariants, workarounds)\n\n### Agent 3: Efficiency Review\n\nReview the same changes for efficiency:\n\n1. **Unnecessary work**: redundant computations, repeated file reads, duplicate network/API calls, N+1 patterns\n2. **Missed concurrency**: independent operations run sequentially when they could run in parallel\n3. **Hot-path bloat**: new blocking work added to startup or per-request/per-render hot paths\n4. **Recurring no-op updates**: state/store updates inside polling loops, intervals, or event handlers that fire unconditionally \u2014 add a change-detection guard so downstream consumers aren't notified when nothing changed. Also: if a wrapper function takes an updater/reducer callback, verify it honors same-reference returns (or whatever the \"no change\" signal is) \u2014 otherwise callers' early-return no-ops are silently defeated\n5. **Unnecessary existence checks**: pre-checking file/resource existence before operating (TOCTOU anti-pattern) \u2014 operate directly and handle the error\n6. **Memory**: unbounded data structures, missing cleanup, event listener leaks\n7. **Overly broad operations**: reading entire files when only a portion is needed, loading all items when filtering for one\n\n## Phase 3: Fix Issues\n\nWait for all three agents to complete. Aggregate their findings and fix each issue directly. If a finding is a false positive or not worth addressing, note it and move on \u2014 do not argue with the finding, just skip it.\n\nWhen done, briefly summarize what was fixed (or confirm the code was already clean).\n";
|
|
12
|
+
//# sourceMappingURL=simplify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simplify.d.ts","sourceRoot":"","sources":["../../src/bundled/simplify.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,IAAI,aAAa,CAAA;AAE9B,eAAO,MAAM,QAAQ,y/HAuDpB,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ported Claude Code bundled `simplify` skill.
|
|
3
|
+
*
|
|
4
|
+
* Source: `~/workspace/github.com/claude-code/skills/bundled/simplify.ts`. The
|
|
5
|
+
* original author tool reference (`${AGENT_TOOL_NAME}`, the `Agent` tool) is
|
|
6
|
+
* kept as a literal template placeholder; the body is otherwise verbatim.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
export const name = 'simplify';
|
|
11
|
+
export const SKILL_MD = `---
|
|
12
|
+
name: simplify
|
|
13
|
+
description: Review changed code for reuse, quality, and efficiency, then fix any issues found.
|
|
14
|
+
user-invocable: true
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Simplify: Code Review and Cleanup
|
|
18
|
+
|
|
19
|
+
Review all changed files for reuse, quality, and efficiency. Fix any issues found.
|
|
20
|
+
|
|
21
|
+
## Phase 1: Identify Changes
|
|
22
|
+
|
|
23
|
+
Run \`git diff\` (or \`git diff HEAD\` if there are staged changes) to see what changed. If there are no git changes, review the most recently modified files that the user mentioned or that you edited earlier in this conversation.
|
|
24
|
+
|
|
25
|
+
## Phase 2: Launch Three Review Agents in Parallel
|
|
26
|
+
|
|
27
|
+
Use the \${AGENT_TOOL_NAME} tool to launch all three agents concurrently in a single message. Pass each agent the full diff so it has the complete context.
|
|
28
|
+
|
|
29
|
+
### Agent 1: Code Reuse Review
|
|
30
|
+
|
|
31
|
+
For each change:
|
|
32
|
+
|
|
33
|
+
1. **Search for existing utilities and helpers** that could replace newly written code. Look for similar patterns elsewhere in the codebase — common locations are utility directories, shared modules, and files adjacent to the changed ones.
|
|
34
|
+
2. **Flag any new function that duplicates existing functionality.** Suggest the existing function to use instead.
|
|
35
|
+
3. **Flag any inline logic that could use an existing utility** — hand-rolled string manipulation, manual path handling, custom environment checks, ad-hoc type guards, and similar patterns are common candidates.
|
|
36
|
+
|
|
37
|
+
### Agent 2: Code Quality Review
|
|
38
|
+
|
|
39
|
+
Review the same changes for hacky patterns:
|
|
40
|
+
|
|
41
|
+
1. **Redundant state**: state that duplicates existing state, cached values that could be derived, observers/effects that could be direct calls
|
|
42
|
+
2. **Parameter sprawl**: adding new parameters to a function instead of generalizing or restructuring existing ones
|
|
43
|
+
3. **Copy-paste with slight variation**: near-duplicate code blocks that should be unified with a shared abstraction
|
|
44
|
+
4. **Leaky abstractions**: exposing internal details that should be encapsulated, or breaking existing abstraction boundaries
|
|
45
|
+
5. **Stringly-typed code**: using raw strings where constants, enums (string unions), or branded types already exist in the codebase
|
|
46
|
+
6. **Unnecessary JSX nesting**: wrapper Boxes/elements that add no layout value — check if inner component props (flexShrink, alignItems, etc.) already provide the needed behavior
|
|
47
|
+
7. **Unnecessary comments**: comments explaining WHAT the code does (well-named identifiers already do that), narrating the change, or referencing the task/caller — delete; keep only non-obvious WHY (hidden constraints, subtle invariants, workarounds)
|
|
48
|
+
|
|
49
|
+
### Agent 3: Efficiency Review
|
|
50
|
+
|
|
51
|
+
Review the same changes for efficiency:
|
|
52
|
+
|
|
53
|
+
1. **Unnecessary work**: redundant computations, repeated file reads, duplicate network/API calls, N+1 patterns
|
|
54
|
+
2. **Missed concurrency**: independent operations run sequentially when they could run in parallel
|
|
55
|
+
3. **Hot-path bloat**: new blocking work added to startup or per-request/per-render hot paths
|
|
56
|
+
4. **Recurring no-op updates**: state/store updates inside polling loops, intervals, or event handlers that fire unconditionally — add a change-detection guard so downstream consumers aren't notified when nothing changed. Also: if a wrapper function takes an updater/reducer callback, verify it honors same-reference returns (or whatever the "no change" signal is) — otherwise callers' early-return no-ops are silently defeated
|
|
57
|
+
5. **Unnecessary existence checks**: pre-checking file/resource existence before operating (TOCTOU anti-pattern) — operate directly and handle the error
|
|
58
|
+
6. **Memory**: unbounded data structures, missing cleanup, event listener leaks
|
|
59
|
+
7. **Overly broad operations**: reading entire files when only a portion is needed, loading all items when filtering for one
|
|
60
|
+
|
|
61
|
+
## Phase 3: Fix Issues
|
|
62
|
+
|
|
63
|
+
Wait for all three agents to complete. Aggregate their findings and fix each issue directly. If a finding is a false positive or not worth addressing, note it and move on — do not argue with the finding, just skip it.
|
|
64
|
+
|
|
65
|
+
When done, briefly summarize what was fixed (or confirm the code was already clean).
|
|
66
|
+
`;
|
|
67
|
+
//# sourceMappingURL=simplify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"simplify.js","sourceRoot":"","sources":["../../src/bundled/simplify.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,IAAI,GAAG,UAAU,CAAA;AAE9B,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuDvB,CAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code skill discovery: root ordering, directory walking, and realpath
|
|
3
|
+
* deduplication.
|
|
4
|
+
*
|
|
5
|
+
* This module finds `<name>/SKILL.md` skills across managed, project, user, and
|
|
6
|
+
* additional roots in that priority order, plus legacy `.claude/commands/*.md`
|
|
7
|
+
* files marked as deprecated sources. Discovery reads only frontmatter so the
|
|
8
|
+
* catalog stays cheap; bodies load on `get()`.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
/** Discovery source bucket for one Claude Code skill file. */
|
|
13
|
+
export type CcSkillSource = 'managed' | 'user' | 'project' | 'additional';
|
|
14
|
+
/** Precedence rank (lower wins) for a discovery root within the provider. */
|
|
15
|
+
export type CcRootRank = 100 | 200 | 300 | 400;
|
|
16
|
+
/** A discovered Claude Code skill file locator. */
|
|
17
|
+
export interface CcSkillFile {
|
|
18
|
+
/** Kebab-case skill name derived from its directory or file name. */
|
|
19
|
+
readonly name: string;
|
|
20
|
+
/** Absolute path to `SKILL.md` or a deprecated flat `.md`. */
|
|
21
|
+
readonly path: string;
|
|
22
|
+
/** Absolute base directory for relative resources in the body. */
|
|
23
|
+
readonly directory: string;
|
|
24
|
+
/** Discovery source bucket. */
|
|
25
|
+
readonly source: CcSkillSource;
|
|
26
|
+
/** Precedence rank (lower wins name conflicts). */
|
|
27
|
+
readonly rank: CcRootRank;
|
|
28
|
+
/** Whether this came from legacy `.claude/commands/*.md`. */
|
|
29
|
+
readonly deprecated: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** One candidate root scanned for skills, in discovery order. */
|
|
32
|
+
export interface CcRoot {
|
|
33
|
+
/** Absolute root path containing `<name>/SKILL.md` entries. */
|
|
34
|
+
readonly path: string;
|
|
35
|
+
/** Discovery source bucket. */
|
|
36
|
+
readonly source: CcSkillSource;
|
|
37
|
+
/** Precedence rank (lower wins). */
|
|
38
|
+
readonly rank: CcRootRank;
|
|
39
|
+
/** Legacy flat-`.md` directory (`.claude/commands`) when applicable. */
|
|
40
|
+
readonly legacyMdDir?: string;
|
|
41
|
+
}
|
|
42
|
+
/** Options for one discovery pass. */
|
|
43
|
+
export interface CcDiscoveryOptions {
|
|
44
|
+
/** Harness home which owns the managed and user skill roots. */
|
|
45
|
+
readonly dshHome: string;
|
|
46
|
+
/** Optional explicit managed policy root, scanned first when set. */
|
|
47
|
+
readonly managedDir?: string | undefined;
|
|
48
|
+
/** Workspace used to locate project `.claude/skills`. */
|
|
49
|
+
readonly projectCwd?: string | undefined;
|
|
50
|
+
/** Additional skill roots appended after the defaults. */
|
|
51
|
+
readonly additionalDirs: readonly string[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Compute the ordered discovery roots for a workspace. Scans managed, project,
|
|
55
|
+
* user, and additional roots; the list is already in precedence order so a
|
|
56
|
+
* first-wins realpath dedup below is deterministic.
|
|
57
|
+
* @param options - discovery inputs (home, managed dir, cwd, additional dirs).
|
|
58
|
+
* @returns the ordered roots to scan.
|
|
59
|
+
*/
|
|
60
|
+
export declare function discoverCcRoots(options: CcDiscoveryOptions): Promise<readonly CcRoot[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Discover every Claude Code skill file for a workspace, deduplicated by the
|
|
63
|
+
* resolved real path so symlinked or overlapping roots yield each file once.
|
|
64
|
+
* @param options - discovery inputs.
|
|
65
|
+
* @returns the deduplicated skill files in precedence order.
|
|
66
|
+
*/
|
|
67
|
+
export declare function discoverCcSkills(options: CcDiscoveryOptions): Promise<readonly CcSkillFile[]>;
|
|
68
|
+
/** Resolve the project root (nearest ancestor containing `.git`) for a cwd. */
|
|
69
|
+
export declare function findProjectRoot(cwd: string): Promise<string>;
|
|
70
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,8DAA8D;AAC9D,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,YAAY,CAAA;AAEzE,6EAA6E;AAC7E,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;AAE9C,mDAAmD;AACnD,MAAM,WAAW,WAAW;IAC1B,qEAAqE;IACrE,QAAQ,CAAC,IA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AAO,CAAC,MAAM,CAAC,CAQlE"}
|
package/lib/discovery.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code skill discovery: root ordering, directory walking, and realpath
|
|
3
|
+
* deduplication.
|
|
4
|
+
*
|
|
5
|
+
* This module finds `<name>/SKILL.md` skills across managed, project, user, and
|
|
6
|
+
* additional roots in that priority order, plus legacy `.claude/commands/*.md`
|
|
7
|
+
* files marked as deprecated sources. Discovery reads only frontmatter so the
|
|
8
|
+
* catalog stays cheap; bodies load on `get()`.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { access, readdir, realpath, stat } from 'node:fs/promises';
|
|
13
|
+
import { dirname, join, resolve } from 'node:path';
|
|
14
|
+
const MANAGED_RANK = 100;
|
|
15
|
+
const PROJECT_RANK = 200;
|
|
16
|
+
const USER_RANK = 300;
|
|
17
|
+
const ADDITIONAL_RANK = 400;
|
|
18
|
+
const LEGACY_COMMANDS = 'commands';
|
|
19
|
+
/**
|
|
20
|
+
* Compute the ordered discovery roots for a workspace. Scans managed, project,
|
|
21
|
+
* user, and additional roots; the list is already in precedence order so a
|
|
22
|
+
* first-wins realpath dedup below is deterministic.
|
|
23
|
+
* @param options - discovery inputs (home, managed dir, cwd, additional dirs).
|
|
24
|
+
* @returns the ordered roots to scan.
|
|
25
|
+
*/
|
|
26
|
+
export async function discoverCcRoots(options) {
|
|
27
|
+
const roots = [];
|
|
28
|
+
if (options.managedDir !== undefined) {
|
|
29
|
+
roots.push({ path: resolve(options.managedDir), source: 'managed', rank: MANAGED_RANK });
|
|
30
|
+
}
|
|
31
|
+
if (options.projectCwd !== undefined) {
|
|
32
|
+
const projectRoot = await findProjectRoot(resolve(options.projectCwd));
|
|
33
|
+
const skillsDir = join(projectRoot, '.claude', 'skills');
|
|
34
|
+
roots.push({
|
|
35
|
+
path: skillsDir,
|
|
36
|
+
source: 'project',
|
|
37
|
+
rank: PROJECT_RANK,
|
|
38
|
+
legacyMdDir: join(projectRoot, '.claude', LEGACY_COMMANDS),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
roots.push({ path: join(resolve(options.dshHome), 'skills'), source: 'user', rank: USER_RANK });
|
|
42
|
+
for (const dir of options.additionalDirs) {
|
|
43
|
+
roots.push({ path: resolve(dir), source: 'additional', rank: ADDITIONAL_RANK });
|
|
44
|
+
}
|
|
45
|
+
return roots;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Discover every Claude Code skill file for a workspace, deduplicated by the
|
|
49
|
+
* resolved real path so symlinked or overlapping roots yield each file once.
|
|
50
|
+
* @param options - discovery inputs.
|
|
51
|
+
* @returns the deduplicated skill files in precedence order.
|
|
52
|
+
*/
|
|
53
|
+
export async function discoverCcSkills(options) {
|
|
54
|
+
const roots = await discoverCcRoots(options);
|
|
55
|
+
const files = [];
|
|
56
|
+
for (const root of roots) {
|
|
57
|
+
files.push(...await scanDirectoryRoot(root));
|
|
58
|
+
if (root.legacyMdDir !== undefined) {
|
|
59
|
+
files.push(...await scanLegacyDirectory(root.legacyMdDir, root));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return deduplicateByRealpath(files);
|
|
63
|
+
}
|
|
64
|
+
async function scanDirectoryRoot(root) {
|
|
65
|
+
let entries;
|
|
66
|
+
try {
|
|
67
|
+
entries = await readdir(root.path, { withFileTypes: true, encoding: 'utf8' });
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// Absent or unreadable roots are valid empty state for discovery.
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
const found = [];
|
|
74
|
+
for (const entry of entries) {
|
|
75
|
+
if (!entry.isDirectory() && !entry.isSymbolicLink())
|
|
76
|
+
continue;
|
|
77
|
+
const dirPath = join(root.path, entry.name);
|
|
78
|
+
const skillPath = join(dirPath, 'SKILL.md');
|
|
79
|
+
if (!await isReadableFile(skillPath))
|
|
80
|
+
continue;
|
|
81
|
+
found.push({
|
|
82
|
+
name: entry.name,
|
|
83
|
+
path: skillPath,
|
|
84
|
+
directory: dirPath,
|
|
85
|
+
source: root.source,
|
|
86
|
+
rank: root.rank,
|
|
87
|
+
deprecated: false,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return found;
|
|
91
|
+
}
|
|
92
|
+
async function scanLegacyDirectory(dir, root) {
|
|
93
|
+
let entries;
|
|
94
|
+
try {
|
|
95
|
+
entries = await readdir(dir, { withFileTypes: true, encoding: 'utf8' });
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
const found = [];
|
|
101
|
+
for (const entry of entries) {
|
|
102
|
+
if (!entry.isFile() && !entry.isSymbolicLink())
|
|
103
|
+
continue;
|
|
104
|
+
if (!entry.name.endsWith('.md'))
|
|
105
|
+
continue;
|
|
106
|
+
const filePath = join(dir, entry.name);
|
|
107
|
+
const name = entry.name.replace(/\.md$/, '');
|
|
108
|
+
found.push({
|
|
109
|
+
name,
|
|
110
|
+
path: filePath,
|
|
111
|
+
directory: dir,
|
|
112
|
+
source: root.source,
|
|
113
|
+
rank: root.rank,
|
|
114
|
+
deprecated: true,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return found;
|
|
118
|
+
}
|
|
119
|
+
async function isReadableFile(path) {
|
|
120
|
+
try {
|
|
121
|
+
const info = await stat(path);
|
|
122
|
+
return info.isFile();
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/** Resolve the project root (nearest ancestor containing `.git`) for a cwd. */
|
|
129
|
+
export async function findProjectRoot(cwd) {
|
|
130
|
+
let current = cwd;
|
|
131
|
+
while (true) {
|
|
132
|
+
if (await pathExists(join(current, '.git')))
|
|
133
|
+
return current;
|
|
134
|
+
const parent = dirname(current);
|
|
135
|
+
if (parent === current)
|
|
136
|
+
return cwd;
|
|
137
|
+
current = parent;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
async function pathExists(path) {
|
|
141
|
+
try {
|
|
142
|
+
await access(path);
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async function deduplicateByRealpath(files) {
|
|
150
|
+
const seen = new Set();
|
|
151
|
+
const result = [];
|
|
152
|
+
for (const file of files) {
|
|
153
|
+
const identity = await realpath(file.path).catch(() => null);
|
|
154
|
+
if (identity === null) {
|
|
155
|
+
result.push(file);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (seen.has(identity))
|
|
159
|
+
continue;
|
|
160
|
+
seen.add(identity);
|
|
161
|
+
result.push(file);
|
|
162
|
+
}
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.js","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAClE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAgDlD,MAAM,YAAY,GAAG,GAAG,CAAA;AACxB,MAAM,YAAY,GAAG,GAAG,CAAA;AACxB,MAAM,SAAS,GAAG,GAAG,CAAA;AACrB,MAAM,eAAe,GAAG,GAAG,CAAA;AAC3B,MAAM,eAAe,GAAG,UAAU,CAAA;AAElC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAA2B;IAC/D,MAAM,KAAK,GAAa,EAAE,CAAA;IAC1B,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACrC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,C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the full Claude Code `SKILL.md` frontmatter spec: it reads
|
|
5
|
+
* every known field, tolerates unknown fields, and throws for known fields with
|
|
6
|
+
* invalid values. Parsing keeps frontmatter independent of body loading so
|
|
7
|
+
* discovery can estimate tokens and build summaries without reading the body.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/** Parsed named arguments from the `arguments` field. */
|
|
12
|
+
export type ParsedCcArguments = readonly string[];
|
|
13
|
+
/** A complete parse of Claude Code skill frontmatter into harness-facing fields. */
|
|
14
|
+
export interface ParsedCcFrontmatter {
|
|
15
|
+
/** Kebab-case skill name from `name`; validated by the provider against the registry grammar. */
|
|
16
|
+
readonly name: string | undefined;
|
|
17
|
+
/** Routing description from `description`. */
|
|
18
|
+
readonly description: string;
|
|
19
|
+
/** Optional routing guidance from `when_to_use`. */
|
|
20
|
+
readonly whenToUse: string | undefined;
|
|
21
|
+
/** Allowed tool allow-list from `allowed-tools`, as parsed names. */
|
|
22
|
+
readonly allowedTools: readonly string[];
|
|
23
|
+
/** Optional argument usage hint from `argument-hint`. */
|
|
24
|
+
readonly argumentHint: string | undefined;
|
|
25
|
+
/** Named argument placeholders from `arguments`. */
|
|
26
|
+
readonly arguments: ParsedCcArguments;
|
|
27
|
+
/** Optional semantic version from `version`. */
|
|
28
|
+
readonly version: string | undefined;
|
|
29
|
+
/** Resolved model from `model`; `inherit` yields undefined. */
|
|
30
|
+
readonly model: string | undefined;
|
|
31
|
+
/** Whether a human may invoke the skill from `user-invocable`. */
|
|
32
|
+
readonly userInvocable: boolean;
|
|
33
|
+
/** Whether the model catalog hides the skill from `disable-model-invocation`. */
|
|
34
|
+
readonly disableModelInvocation: boolean;
|
|
35
|
+
/** `context: fork` selects subagent execution; otherwise inline. */
|
|
36
|
+
readonly executionContext: 'fork' | undefined;
|
|
37
|
+
/** Optional target agent persona from `agent`. */
|
|
38
|
+
readonly agent: string | undefined;
|
|
39
|
+
/** Optional effort level from `effort`. */
|
|
40
|
+
readonly effort: string | undefined;
|
|
41
|
+
/** Inline-shell toggle from `shell` (false disables `` !`...` `` execution). */
|
|
42
|
+
readonly shell: boolean | undefined;
|
|
43
|
+
/** Raw validated hooks object from `hooks`, preserved verbatim. */
|
|
44
|
+
readonly hooks: unknown;
|
|
45
|
+
/** Gitignore-style activation paths from `paths`, or undefined when match-all. */
|
|
46
|
+
readonly paths: readonly string[] | undefined;
|
|
47
|
+
/** Any unrecognized keys, preserved for downstream tolerant consumers. */
|
|
48
|
+
readonly unknown: Readonly<Record<string, unknown>>;
|
|
49
|
+
}
|
|
50
|
+
/** A split frontmatter document: parsed data plus the Markdown body. */
|
|
51
|
+
export interface CcFrontmatterDocument {
|
|
52
|
+
/** Parsed frontmatter values, pre-validation. */
|
|
53
|
+
readonly data: Record<string, unknown>;
|
|
54
|
+
/** Markdown body after the closing `---`. */
|
|
55
|
+
readonly body: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Parse the complete Claude Code frontmatter from a raw `SKILL.md` document.
|
|
59
|
+
* Unknown keys are preserved in `unknown`; a known key with an invalid value
|
|
60
|
+
* throws so a malformed skill fails loudly instead of silently mis-activating.
|
|
61
|
+
* @param raw - the full `SKILL.md` text.
|
|
62
|
+
* @returns the parsed fields, or `undefined` when the document has no frontmatter.
|
|
63
|
+
*/
|
|
64
|
+
export declare function parseCcFrontmatter(raw: string): ParsedCcFrontmatter | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Split a raw `SKILL.md` into its frontmatter YAML payload and Markdown body.
|
|
67
|
+
* Returns `undefined` when the document does not begin with a `---` fence.
|
|
68
|
+
* @param raw - the full `SKILL.md` text.
|
|
69
|
+
* @returns the parsed YAML object and trailing body, or `undefined`.
|
|
70
|
+
*/
|
|
71
|
+
export declare function parseCcFrontmatterDocument(raw: string): CcFrontmatterDocument | undefined;
|
|
72
|
+
//# sourceMappingURL=frontmatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmat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