skilljit 0.1.0 → 0.1.2
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/README.md +43 -6
- package/dist/bin.js +36 -4
- package/dist/bin.js.map +1 -1
- package/dist/commands/sync.d.ts +22 -4
- package/dist/commands/sync.js +24 -7
- package/dist/commands/sync.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -90,26 +90,63 @@ skilljit — never mutates the original), `skilljit adopt <configPath>` (apply i
|
|
|
90
90
|
`skilljit doctor [configPath]` (verify upstreams still work), `skilljit restore
|
|
91
91
|
<configPath>` (undo `adopt`).
|
|
92
92
|
|
|
93
|
-
##
|
|
93
|
+
## Adding your own skills to `sync`
|
|
94
|
+
|
|
95
|
+
By default `sync` only pulls from a small curated list of public repos. To add your
|
|
96
|
+
own:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
# Another public (or your-token-authenticated private) GitHub repo:
|
|
100
|
+
skilljit sync --repo your-org/internal-skills --token "$SKILLJIT_GITHUB_TOKEN"
|
|
101
|
+
|
|
102
|
+
# Any git remote at all — self-hosted, GitLab, Bitbucket, or a private repo
|
|
103
|
+
# reached over SSH — using whatever git credentials are already set up on
|
|
104
|
+
# this machine. No GitHub API token needed for this path.
|
|
105
|
+
skilljit sync --git git@git.internal.example.com:team/skills.git
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Both flags are repeatable. `--git` sources are ingested via a bare mirror clone plus
|
|
109
|
+
`git worktree` rather than the GitHub API: the first sync pays for a full clone, every
|
|
110
|
+
sync after that is a cheap `git fetch` + worktree checkout — no rate limit, no token,
|
|
111
|
+
works against anything `git` itself can reach.
|
|
112
|
+
|
|
113
|
+
## The six tools
|
|
94
114
|
|
|
95
115
|
skilljit exposes a fixed surface — it never grows or shrinks at runtime.
|
|
96
116
|
|
|
97
117
|
| Tool | Returns |
|
|
98
118
|
|---|---|
|
|
99
119
|
| `skill_find(query, limit=8)` | Cheap candidates: id, source, one-line description, install count, audit status. |
|
|
100
|
-
| `skill_load(name)` | Full SKILL.md body for one skill by id. The
|
|
120
|
+
| `skill_load(name)` | Full SKILL.md body for one skill by id, plus a list of any bundled file paths (not their content). The main point a skill's content enters context. |
|
|
121
|
+
| `skill_read_file(name, path)` | One bundled reference doc or helper script's content, by a path `skill_load` listed. |
|
|
101
122
|
| `tool_find(query, limit=8)` | Matching upstream MCP tools' full JSON Schema, across every connected server. |
|
|
102
123
|
| `tool_call(server, tool, args)` | Generic dispatcher to the matched upstream server and tool. |
|
|
103
|
-
| `skilljit_stats()` | Tokens saved this session
|
|
124
|
+
| `skilljit_stats()` | Tokens saved this session, and cumulatively across every skilljit session/tab that's ever used this catalog — see below. |
|
|
104
125
|
|
|
105
|
-
`skill_find` → `skill_load` is progressive disclosure rebuilt as
|
|
106
|
-
always-loaded cost stops scaling with catalog size
|
|
126
|
+
`skill_find` → `skill_load` → `skill_read_file` is progressive disclosure rebuilt as
|
|
127
|
+
a **pull**, all the way down: the always-loaded cost stops scaling with catalog size,
|
|
128
|
+
and a skill's bundled reference docs/scripts stay out of context until named by path,
|
|
129
|
+
even after the skill itself has been loaded.
|
|
107
130
|
|
|
108
131
|
`tool_find` and `tool_call` only appear once you've configured upstream MCP servers
|
|
109
|
-
via `skilljit adopt` (see below) — run skills-only and the surface is
|
|
132
|
+
via `skilljit adopt` (see below) — run skills-only and the surface is 4 tools, not 6.
|
|
110
133
|
This is what makes the skills half independently shippable and testable from the
|
|
111
134
|
proxy half.
|
|
112
135
|
|
|
136
|
+
## Multiple tabs / parallel sessions
|
|
137
|
+
|
|
138
|
+
Running several Claude Code tabs at once for different tasks is exactly where the
|
|
139
|
+
"every tab pays for every installed skill" cost multiplies — N tabs open means that
|
|
140
|
+
per-turn overhead is being paid N times simultaneously. skilljit already collapses
|
|
141
|
+
that per-tab cost to a fixed few tools regardless of catalog size, but `skilljit_stats()`
|
|
142
|
+
goes further: every session's baseline/actual numbers are also written into the shared
|
|
143
|
+
`catalog.db` (the same file every tab's `skilljit serve` process already points at), so
|
|
144
|
+
the reported totals are cumulative across every tab you've had open, not just the one
|
|
145
|
+
you're asking from — and losing a tab doesn't lose that number, since it was already
|
|
146
|
+
durably written, not held only in that tab's memory. This does not recover a lost tab's
|
|
147
|
+
conversation itself — that's a Claude Code session feature (`claude --resume`), unrelated
|
|
148
|
+
to skilljit.
|
|
149
|
+
|
|
113
150
|
## MCP proxy — routing your other MCP servers
|
|
114
151
|
|
|
115
152
|
Passing `skilljit serve --config <path>` (the config path you previously ran
|
package/dist/bin.js
CHANGED
|
@@ -1,28 +1,60 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import path from "node:path";
|
|
2
5
|
import { Command } from "commander";
|
|
3
|
-
import { Catalog, defaultCatalogPath } from "@skilljit/core";
|
|
6
|
+
import { Catalog, defaultCatalogPath, DEFAULT_GITHUB_SOURCES } from "@skilljit/core";
|
|
4
7
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
8
|
import { createServer } from "@skilljit/mcp";
|
|
6
9
|
import { latestAdoption, resolveManagedUpstreams } from "@skilljit/proxy";
|
|
7
10
|
import { runSync } from "./commands/sync.js";
|
|
8
11
|
import { runSearch, formatSearchResults } from "./commands/search.js";
|
|
9
12
|
import { defaultStateDir, cmdInit, cmdAdopt, cmdRestore, cmdDoctor } from "./commands/proxy.js";
|
|
13
|
+
// Read the real version from this package's own package.json rather than
|
|
14
|
+
// hardcoding a string here that silently drifts from every release.
|
|
15
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
const { version: packageVersion } = JSON.parse(readFileSync(path.join(__dirname, "..", "package.json"), "utf8"));
|
|
10
17
|
const program = new Command();
|
|
11
18
|
program
|
|
12
19
|
.name("skilljit")
|
|
13
20
|
.description("Just-in-time skill and MCP tool routing for Claude. " +
|
|
14
21
|
"Install thousands of skills at the token cost of one — nothing loads " +
|
|
15
22
|
"into context until a task actually needs it.")
|
|
16
|
-
.version(
|
|
23
|
+
.version(packageVersion);
|
|
24
|
+
function parseRepoSlug(value, previous) {
|
|
25
|
+
const slash = value.indexOf("/");
|
|
26
|
+
if (slash <= 0 || slash === value.length - 1) {
|
|
27
|
+
throw new Error(`--repo expects "owner/repo", got "${value}"`);
|
|
28
|
+
}
|
|
29
|
+
return [...previous, { owner: value.slice(0, slash), repo: value.slice(slash + 1) }];
|
|
30
|
+
}
|
|
31
|
+
function collect(value, previous) {
|
|
32
|
+
return [...previous, value];
|
|
33
|
+
}
|
|
17
34
|
program
|
|
18
35
|
.command("sync")
|
|
19
36
|
.description("Refresh the local skill catalog from configured GitHub sources")
|
|
20
37
|
.option("--db <path>", "catalog db path", defaultCatalogPath())
|
|
38
|
+
.option("--repo <owner/repo>", "additional GitHub repo to sync, on top of the built-in defaults (repeatable)", parseRepoSlug, [])
|
|
39
|
+
.option("--git <url>", "arbitrary git remote to sync via clone + worktree — self-hosted, GitLab, or an " +
|
|
40
|
+
"SSH-authenticated private repo, using whatever git credentials are already set up " +
|
|
41
|
+
"on this machine (repeatable, no GitHub API token needed)", collect, [])
|
|
42
|
+
.option("--token <token>", "GitHub token for --repo sources (or set SKILLJIT_GITHUB_TOKEN)")
|
|
21
43
|
.action(async (options) => {
|
|
22
|
-
const
|
|
44
|
+
const sources = [...DEFAULT_GITHUB_SOURCES, ...options.repo];
|
|
45
|
+
const result = await runSync({
|
|
46
|
+
dbPath: options.db,
|
|
47
|
+
sources,
|
|
48
|
+
gitSources: options.git,
|
|
49
|
+
token: options.token,
|
|
50
|
+
log: (l) => console.log(l),
|
|
51
|
+
});
|
|
23
52
|
console.log(`\nDone. ${result.total} skill(s) in catalog.`);
|
|
24
53
|
if (result.failedSources.length > 0) {
|
|
25
|
-
console.log(`${result.failedSources.length} source(s) failed to sync (see above).`);
|
|
54
|
+
console.log(`${result.failedSources.length} GitHub source(s) failed to sync (see above).`);
|
|
55
|
+
}
|
|
56
|
+
if (result.failedGitSources.length > 0) {
|
|
57
|
+
console.log(`${result.failedGitSources.length} git source(s) failed to sync (see above).`);
|
|
26
58
|
}
|
|
27
59
|
});
|
|
28
60
|
program
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhG,yEAAyE;AACzE,oEAAoE;AACpE,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,C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B,CAAC;KAC/B,WAAW,CAAC,6DAA6D,CAAC;KAC1E,MAAM,CAAC,KAAK,EAAE,UAAkB,EAAE,EAAE;IACnC,MAAM,UAAU,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACjE,CAAC,CAAC,CAAC;AAEL,OAAO;KACJ,OAAO,CAAC,qBAAqB,CAAC;KAC9B,WAAW,CAAC,oGAAoG,CAAC;KACjH,MAAM,CAAC,KAAK,EAAE,UAAmB,EAAE,EAAE;IACpC,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,CAAC,GAAG,CAAC,wFAAwF,CAAC,CAAC;QACtG,OAAO;IACT,CAAC;IACD,MAAM,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IAC7C,OAAO,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACxD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
|
package/dist/commands/sync.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
+
import type { ExecFileFn } from "@skilljit/core";
|
|
1
2
|
export interface SyncOptions {
|
|
2
3
|
dbPath: string;
|
|
3
4
|
sources?: {
|
|
4
5
|
owner: string;
|
|
5
6
|
repo: string;
|
|
6
7
|
}[];
|
|
8
|
+
/** Arbitrary git remotes (self-hosted, GitLab, SSH-authenticated private
|
|
9
|
+
* repos, ...), ingested via clone + git worktree instead of the GitHub API. */
|
|
10
|
+
gitSources?: string[];
|
|
11
|
+
/** Where gitSources' bare mirror clones are cached. Defaults to
|
|
12
|
+
* ~/.skilljit/git-cache. */
|
|
13
|
+
gitCacheDir?: string;
|
|
14
|
+
/** GitHub token for the sources above (or set SKILLJIT_GITHUB_TOKEN). */
|
|
15
|
+
token?: string;
|
|
7
16
|
fetchImpl?: typeof fetch;
|
|
17
|
+
execFileImpl?: ExecFileFn;
|
|
8
18
|
log?: (line: string) => void;
|
|
9
19
|
}
|
|
10
20
|
export interface SyncResult {
|
|
@@ -18,11 +28,19 @@ export interface SyncResult {
|
|
|
18
28
|
owner: string;
|
|
19
29
|
repo: string;
|
|
20
30
|
}[];
|
|
31
|
+
perGitSource: {
|
|
32
|
+
url: string;
|
|
33
|
+
count: number;
|
|
34
|
+
}[];
|
|
35
|
+
failedGitSources: {
|
|
36
|
+
url: string;
|
|
37
|
+
}[];
|
|
21
38
|
}
|
|
22
39
|
/**
|
|
23
|
-
* Ingest every configured GitHub source into the local
|
|
24
|
-
* One source failing (network error, rate limit, repo renamed
|
|
25
|
-
* abort the rest — skilljit's catalog should
|
|
26
|
-
* die because one upstream repo is briefly
|
|
40
|
+
* Ingest every configured GitHub source and git remote into the local
|
|
41
|
+
* catalog db. One source failing (network error, rate limit, repo renamed,
|
|
42
|
+
* bad SSH auth) does not abort the rest — skilljit's catalog should
|
|
43
|
+
* degrade gracefully, not die because one upstream repo is briefly
|
|
44
|
+
* unavailable.
|
|
27
45
|
*/
|
|
28
46
|
export declare function runSync(opts: SyncOptions): Promise<SyncResult>;
|
package/dist/commands/sync.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import { Catalog, ingestGithubRepo, DEFAULT_GITHUB_SOURCES } from "@skilljit/core";
|
|
1
|
+
import { Catalog, ingestGithubRepo, ingestLocalGitRepo, DEFAULT_GITHUB_SOURCES } from "@skilljit/core";
|
|
2
2
|
/**
|
|
3
|
-
* Ingest every configured GitHub source into the local
|
|
4
|
-
* One source failing (network error, rate limit, repo renamed
|
|
5
|
-
* abort the rest — skilljit's catalog should
|
|
6
|
-
* die because one upstream repo is briefly
|
|
3
|
+
* Ingest every configured GitHub source and git remote into the local
|
|
4
|
+
* catalog db. One source failing (network error, rate limit, repo renamed,
|
|
5
|
+
* bad SSH auth) does not abort the rest — skilljit's catalog should
|
|
6
|
+
* degrade gracefully, not die because one upstream repo is briefly
|
|
7
|
+
* unavailable.
|
|
7
8
|
*/
|
|
8
9
|
export async function runSync(opts) {
|
|
9
10
|
const log = opts.log ?? (() => { });
|
|
10
11
|
const sources = opts.sources ?? DEFAULT_GITHUB_SOURCES;
|
|
12
|
+
const gitSources = opts.gitSources ?? [];
|
|
11
13
|
const catalog = new Catalog(opts.dbPath);
|
|
12
14
|
const perSource = [];
|
|
13
15
|
const failedSources = [];
|
|
16
|
+
const perGitSource = [];
|
|
17
|
+
const failedGitSources = [];
|
|
14
18
|
try {
|
|
15
19
|
for (const { owner, repo } of sources) {
|
|
16
20
|
log(`syncing github:${owner}/${repo} ...`);
|
|
17
21
|
try {
|
|
18
|
-
const skills = await ingestGithubRepo(owner, repo, { fetchImpl: opts.fetchImpl });
|
|
22
|
+
const skills = await ingestGithubRepo(owner, repo, { fetchImpl: opts.fetchImpl, token: opts.token });
|
|
19
23
|
catalog.upsertSkills(skills);
|
|
20
24
|
perSource.push({ owner, repo, count: skills.length });
|
|
21
25
|
log(` ${skills.length} skill(s) found`);
|
|
@@ -25,7 +29,20 @@ export async function runSync(opts) {
|
|
|
25
29
|
log(` failed: ${err.message}`);
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
|
-
|
|
32
|
+
for (const url of gitSources) {
|
|
33
|
+
log(`syncing ${url} (git worktree) ...`);
|
|
34
|
+
try {
|
|
35
|
+
const skills = await ingestLocalGitRepo(url, { execFileImpl: opts.execFileImpl, cacheDir: opts.gitCacheDir });
|
|
36
|
+
catalog.upsertSkills(skills);
|
|
37
|
+
perGitSource.push({ url, count: skills.length });
|
|
38
|
+
log(` ${skills.length} skill(s) found`);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
failedGitSources.push({ url });
|
|
42
|
+
log(` failed: ${err.message}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { total: catalog.count(), perSource, failedSources, perGitSource, failedGitSources };
|
|
29
46
|
}
|
|
30
47
|
finally {
|
|
31
48
|
catalog.close();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AA2BvG;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAiB;IAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACnC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,sBAAsB,CAAC;IACvD,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC;IACzC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,SAAS,GAA4B,EAAE,CAAC;IAC9C,MAAM,aAAa,GAAgC,EAAE,CAAC;IACtD,MAAM,YAAY,GAA+B,EAAE,CAAC;IACpD,MAAM,gBAAgB,GAAmC,EAAE,CAAC;IAE5D,IAAI,CAAC;QACH,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,OAAO,EAAE,CAAC;YACtC,GAAG,CAAC,kBAAkB,KAAK,IAAI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