claudepluginhub 0.12.0 → 0.12.1
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.
|
@@ -71,7 +71,9 @@ function componentsEqual(a, b) {
|
|
|
71
71
|
x.name !== y.name ||
|
|
72
72
|
x.description !== y.description ||
|
|
73
73
|
x.estimable !== y.estimable ||
|
|
74
|
-
x.
|
|
74
|
+
x.disableModelInvocation !== y.disableModelInvocation ||
|
|
75
|
+
x.listingChars !== y.listingChars ||
|
|
76
|
+
x.listingComplete !== y.listingComplete ||
|
|
75
77
|
x.bodyChars !== y.bodyChars ||
|
|
76
78
|
x.hash !== y.hash)
|
|
77
79
|
return false;
|
|
@@ -1,26 +1,11 @@
|
|
|
1
1
|
import type { ScanResult } from './report.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* Rule: tokens ≈ ceil(characters / 4), computed from local file contents.
|
|
6
|
-
* - Always-on = the plugin's listing text: each skill/command/agent's
|
|
7
|
-
* frontmatter name + description (mirrors the documented semantics of
|
|
8
|
-
* `claude plugin details`, which counts "listing text ... added to every
|
|
9
|
-
* session"). Hooks/MCP/LSP are NOT estimated.
|
|
10
|
-
* - On-invoke = a component's full body, paid when it fires.
|
|
11
|
-
*
|
|
12
|
-
* All values are estimates: render with a `~` prefix and say so. Components
|
|
13
|
-
* whose frontmatter the bounded reader could not understand are excluded and
|
|
14
|
-
* the plugin is flagged `estimated: false` (unestimated ≠ invalid).
|
|
15
|
-
* `claude plugin details` is the authoritative source; Doctor never parses
|
|
16
|
-
* its human output.
|
|
17
|
-
*/
|
|
18
|
-
export declare const CHARS_PER_TOKEN = 4;
|
|
19
|
-
export declare function estimateTokens(chars: number): number;
|
|
2
|
+
export declare function estimateListingTokens(listingChars: number): number;
|
|
3
|
+
export declare function estimateInvocationTokens(bodyChars: number): number;
|
|
20
4
|
export declare function formatApproxTokens(n: number): string;
|
|
21
5
|
export interface PluginEstimate {
|
|
22
6
|
alwaysOnTokens: number;
|
|
23
|
-
/** True when every skill/command/agent in the plugin was estimable
|
|
7
|
+
/** True when every skill/command/agent in the plugin was estimable and
|
|
8
|
+
* listing text was fully determined. */
|
|
24
9
|
estimated: boolean;
|
|
25
10
|
largestOnInvoke: {
|
|
26
11
|
path: string;
|
package/dist/doctor/estimate.js
CHANGED
|
@@ -2,26 +2,78 @@ import { compareBytes } from './report.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* THE context-estimate heuristic — centralized here, documented once.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
5
|
+
* Listing tokens ≈ ceil(listingChars / 4.5) + 5 per model-visible component.
|
|
6
|
+
* Invocation tokens ≈ ceil(bodyChars / 4.25), where bodyChars EXCLUDES frontmatter.
|
|
7
|
+
*
|
|
8
|
+
* The two ratios model different serialized content:
|
|
9
|
+
* - LISTING (4.5 chars/tok) — structured key/value listing with JSON separators;
|
|
10
|
+
* the +5 per-component overhead covers serialization framing.
|
|
11
|
+
* - INVOCATION (4.25 chars/tok) — raw Markdown body injected as-is; the lower
|
|
12
|
+
* ratio accounts for short-token-dense content in commands and structured
|
|
13
|
+
* Markdown that tokenizes less efficiently than prose.
|
|
14
|
+
*
|
|
15
|
+
* Calibrated against `claude plugin details` output (Claude values are supplied
|
|
16
|
+
* benchmark data, not commands executed in the implementation environment):
|
|
17
|
+
*
|
|
18
|
+
* Always-on listing:
|
|
19
|
+
* pr-review-toolkit (7 components): formula → ~1.5k, Claude → ~1,404
|
|
20
|
+
* commit-commands (3 commands): formula → ~75, Claude → ~76
|
|
21
|
+
* code-review (1 command): formula → ~14, Claude → ~19
|
|
22
|
+
* frontend-design (1 skill): formula → ~54, Claude → ~54
|
|
23
|
+
*
|
|
24
|
+
* Invocation body (all pr-review-toolkit agents + commands):
|
|
25
|
+
* silent-failure-hunter: 1,483 vs Claude ~1,400 (+6%)
|
|
26
|
+
* review-pr: 1,138 vs Claude ~1,100 (+3%)
|
|
27
|
+
* type-design-analyzer: 1,029 vs Claude ~990 (+4%)
|
|
28
|
+
* comment-analyzer: 1,026 vs Claude ~990 (+4%)
|
|
29
|
+
* pr-test-analyzer: 938 vs Claude ~900 (+4%)
|
|
30
|
+
* code-simplifier: 683 vs Claude ~660 (+3%)
|
|
31
|
+
* code-reviewer: 611 vs Claude ~590 (+4%)
|
|
32
|
+
* Invocation body (other plugins):
|
|
33
|
+
* code-review cmd: 1,688 vs Claude ~1,900 (-11%)
|
|
34
|
+
* frontend-design skill: 1,874 vs Claude ~1,700 (+10%)
|
|
35
|
+
* clean_gone: 397 vs Claude ~450 (-12%)
|
|
36
|
+
* commit-push-pr: 143 vs Claude ~160 (-11%)
|
|
37
|
+
* commit: 121 vs Claude ~140 (-14%)
|
|
38
|
+
* Worst-case error: ~14%. No claim of tokenizer parity.
|
|
39
|
+
*
|
|
40
|
+
* - Always-on = the plugin's listing text: each model-visible skill/command/
|
|
41
|
+
* agent's frontmatter listing fields (name + description; skills and legacy
|
|
42
|
+
* commands also include when_to_use, capped at 1,536 combined chars), plus
|
|
43
|
+
* per-component overhead. Skills and commands with
|
|
44
|
+
* `disable-model-invocation: true` are excluded (not listed for model
|
|
45
|
+
* selection); agents ignore this field. Hooks/MCP/LSP are NOT estimated.
|
|
46
|
+
* - On-invoke = a component's body (EXCLUDING frontmatter), paid when it fires.
|
|
47
|
+
*
|
|
48
|
+
* All values are estimates: render with `~`, `<`, or `0` prefix and say so.
|
|
49
|
+
* Components whose frontmatter the bounded reader could not understand are
|
|
50
|
+
* excluded and the plugin is flagged `estimated: false` (unestimated ≠ invalid).
|
|
15
51
|
* `claude plugin details` is the authoritative source; Doctor never parses
|
|
16
52
|
* its human output.
|
|
53
|
+
*
|
|
54
|
+
* Limitations:
|
|
55
|
+
* - Plugin skills are managed through `/plugin`, not `skillOverrides`.
|
|
56
|
+
* Configurable listing caps or token budgets may make Doctor differ from
|
|
57
|
+
* Claude's effective post-budget context.
|
|
58
|
+
* - Skills and commands without a frontmatter description may use a
|
|
59
|
+
* first-body-paragraph fallback that the bounded parser cannot determine;
|
|
60
|
+
* such components mark the listing estimate incomplete rather than silently
|
|
61
|
+
* undercounting.
|
|
17
62
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
63
|
+
const LISTING_CHARS_PER_TOKEN = 4.5;
|
|
64
|
+
const INVOCATION_CHARS_PER_TOKEN = 4.25;
|
|
65
|
+
const PER_COMPONENT_OVERHEAD = 5;
|
|
66
|
+
export function estimateListingTokens(listingChars) {
|
|
67
|
+
return Math.ceil(listingChars / LISTING_CHARS_PER_TOKEN) + PER_COMPONENT_OVERHEAD;
|
|
68
|
+
}
|
|
69
|
+
export function estimateInvocationTokens(bodyChars) {
|
|
70
|
+
return Math.ceil(bodyChars / INVOCATION_CHARS_PER_TOKEN);
|
|
21
71
|
}
|
|
22
72
|
export function formatApproxTokens(n) {
|
|
23
|
-
if (n
|
|
24
|
-
return
|
|
73
|
+
if (n === 0)
|
|
74
|
+
return '~0';
|
|
75
|
+
if (n < 20)
|
|
76
|
+
return '<20';
|
|
25
77
|
if (n < 1000)
|
|
26
78
|
return `~${Math.round(n / 10) * 10}`;
|
|
27
79
|
if (n < 10000) {
|
|
@@ -34,14 +86,18 @@ export function formatApproxTokens(n) {
|
|
|
34
86
|
export function estimatePlugin(scan) {
|
|
35
87
|
const relevant = scan.components.filter((c) => c.type === 'skill' || c.type === 'command' || c.type === 'agent');
|
|
36
88
|
const estimable = relevant.filter((c) => c.estimable);
|
|
37
|
-
|
|
89
|
+
// disable-model-invocation applies to skills and commands only.
|
|
90
|
+
// An agent carrying the field still contributes its normal listing.
|
|
91
|
+
const modelVisible = estimable.filter((c) => !(c.disableModelInvocation && (c.type === 'skill' || c.type === 'command')));
|
|
92
|
+
const alwaysOnTokens = modelVisible.reduce((sum, c) => sum + estimateListingTokens(c.listingChars), 0);
|
|
38
93
|
const largestOnInvoke = estimable
|
|
39
|
-
.map((c) => ({ path: c.relPath, tokens:
|
|
94
|
+
.map((c) => ({ path: c.relPath, tokens: estimateInvocationTokens(c.bodyChars) }))
|
|
40
95
|
.sort((a, b) => b.tokens - a.tokens || compareBytes(a.path, b.path))
|
|
41
96
|
.slice(0, 3);
|
|
97
|
+
const listingComplete = modelVisible.every((c) => c.listingComplete);
|
|
42
98
|
return {
|
|
43
99
|
alwaysOnTokens,
|
|
44
|
-
estimated: estimable.length === relevant.length && !scan.incomplete,
|
|
100
|
+
estimated: estimable.length === relevant.length && !scan.incomplete && listingComplete,
|
|
45
101
|
largestOnInvoke,
|
|
46
102
|
};
|
|
47
103
|
}
|
|
@@ -55,7 +55,13 @@ export declare function createScanner(overrides?: Partial<ScanLimits>): Scanner;
|
|
|
55
55
|
interface ParsedFrontmatter {
|
|
56
56
|
name: string | null;
|
|
57
57
|
description: string | null;
|
|
58
|
+
/** Skills and legacy commands: the documented `when_to_use` field. */
|
|
59
|
+
whenToUse: string | null;
|
|
58
60
|
understood: boolean;
|
|
61
|
+
/** Byte offset where the body begins (after closing `---\n`). 0 = no frontmatter. */
|
|
62
|
+
bodyStartOffset: number;
|
|
63
|
+
/** True only for the unquoted YAML boolean `true`. */
|
|
64
|
+
disableModelInvocation: boolean;
|
|
59
65
|
}
|
|
60
66
|
export declare function parseFrontmatter(content: string): ParsedFrontmatter;
|
|
61
67
|
export declare function hashComponentContent(content: string): string;
|
package/dist/doctor/inventory.js
CHANGED
|
@@ -23,6 +23,10 @@ export const TOOL_MATCHED_EVENTS = new Set([
|
|
|
23
23
|
const FRONTMATTER_MAX_LINES = 100;
|
|
24
24
|
const FRONTMATTER_MAX_BYTES = 16 * 1024;
|
|
25
25
|
const MAX_KEYS = 50;
|
|
26
|
+
/** Default cap on combined description + when_to_use listing text (chars).
|
|
27
|
+
* Configurable listing caps/budgets may cause Doctor to differ from Claude's
|
|
28
|
+
* effective post-budget context. */
|
|
29
|
+
const LISTING_DESC_CAP = 1536;
|
|
26
30
|
/**
|
|
27
31
|
* Aggregate cap on hook/MCP/LSP/monitor facts per plugin. Parse helpers stop
|
|
28
32
|
* producing at MAX_FACTS_PER_TYPE + 1 so the scanner can DETECT the overflow
|
|
@@ -515,28 +519,53 @@ function readBlockScalar(lines, startIndex, limit, indicator, chomping) {
|
|
|
515
519
|
return { value, nextIndex: i, truncated: false };
|
|
516
520
|
}
|
|
517
521
|
export function parseFrontmatter(content) {
|
|
522
|
+
const empty = {
|
|
523
|
+
name: null, description: null, whenToUse: null,
|
|
524
|
+
understood: true, bodyStartOffset: 0, disableModelInvocation: false,
|
|
525
|
+
};
|
|
518
526
|
if (!content.startsWith('---'))
|
|
519
|
-
return
|
|
527
|
+
return empty;
|
|
520
528
|
const slice = content.slice(0, FRONTMATTER_MAX_BYTES);
|
|
521
529
|
const lines = slice.split('\n');
|
|
522
530
|
let name = null;
|
|
523
531
|
let description = null;
|
|
532
|
+
let whenToUse = null;
|
|
524
533
|
let closed = false;
|
|
534
|
+
let disableModelInvocation = false;
|
|
525
535
|
const lineLimit = Math.min(lines.length, FRONTMATTER_MAX_LINES);
|
|
536
|
+
let offset = lines[0].length + 1; // skip opening '---\n'
|
|
526
537
|
for (let i = 1; i < lineLimit; i += 1) {
|
|
527
538
|
const line = lines[i];
|
|
528
539
|
if (/^---\s*$/.test(line) && !line.startsWith(' ') && !line.startsWith('\t')) {
|
|
529
540
|
closed = true;
|
|
541
|
+
offset += line.length + 1;
|
|
530
542
|
break;
|
|
531
543
|
}
|
|
532
|
-
const
|
|
533
|
-
if (
|
|
544
|
+
const dmiMatch = line.match(/^disable-model-invocation\s*:\s*(.*)$/);
|
|
545
|
+
if (dmiMatch) {
|
|
546
|
+
// Only unquoted YAML boolean `true` disables. Quoted "true", 'true',
|
|
547
|
+
// yes, 1, and malformed values must NOT silently disable.
|
|
548
|
+
disableModelInvocation = dmiMatch[1].trim() === 'true';
|
|
549
|
+
offset += line.length + 1;
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
// Only the documented `when_to_use` spelling is recognized.
|
|
553
|
+
// `when-to-use` (hyphen) has no official compatibility contract and must
|
|
554
|
+
// not silently change estimates.
|
|
555
|
+
const match = line.match(/^(name|description|when_to_use)\s*:\s*(.*)$/);
|
|
556
|
+
if (!match) {
|
|
557
|
+
offset += line.length + 1;
|
|
534
558
|
continue;
|
|
559
|
+
}
|
|
560
|
+
const key = match[1];
|
|
535
561
|
const value = match[2].trim();
|
|
536
562
|
// Explicit indent indicators (|2, >2, >+1, etc.) are uncommon and complex —
|
|
537
563
|
// mark as not understood rather than risk a wrong parse.
|
|
538
564
|
if (BLOCK_SCALAR_EXPLICIT_INDENT_RE.test(value)) {
|
|
539
|
-
return {
|
|
565
|
+
return {
|
|
566
|
+
name, description, whenToUse,
|
|
567
|
+
understood: false, bodyStartOffset: content.length, disableModelInvocation,
|
|
568
|
+
};
|
|
540
569
|
}
|
|
541
570
|
const blockMatch = value.match(BLOCK_SCALAR_RE);
|
|
542
571
|
if (blockMatch) {
|
|
@@ -544,24 +573,42 @@ export function parseFrontmatter(content) {
|
|
|
544
573
|
const chomping = blockMatch[2];
|
|
545
574
|
const result = readBlockScalar(lines, i + 1, lineLimit, indicator, chomping);
|
|
546
575
|
if (result.truncated) {
|
|
547
|
-
return {
|
|
576
|
+
return {
|
|
577
|
+
name, description, whenToUse,
|
|
578
|
+
understood: false, bodyStartOffset: content.length, disableModelInvocation,
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
// Advance offset for the key line and all block-scalar lines consumed
|
|
582
|
+
for (let j = i; j < result.nextIndex; j++) {
|
|
583
|
+
offset += lines[j].length + 1;
|
|
548
584
|
}
|
|
549
585
|
i = result.nextIndex - 1;
|
|
550
|
-
if (
|
|
586
|
+
if (key === 'name')
|
|
551
587
|
name = result.value;
|
|
552
|
-
else
|
|
588
|
+
else if (key === 'description')
|
|
553
589
|
description = result.value;
|
|
590
|
+
else
|
|
591
|
+
whenToUse = result.value;
|
|
554
592
|
continue;
|
|
555
593
|
}
|
|
556
|
-
if (value === '')
|
|
594
|
+
if (value === '') {
|
|
595
|
+
offset += line.length + 1;
|
|
557
596
|
continue;
|
|
597
|
+
}
|
|
558
598
|
const unquoted = value.replace(/^["']/, '').replace(/["']$/, '');
|
|
559
|
-
if (
|
|
599
|
+
if (key === 'name')
|
|
560
600
|
name = unquoted;
|
|
561
|
-
else
|
|
601
|
+
else if (key === 'description')
|
|
562
602
|
description = unquoted;
|
|
603
|
+
else
|
|
604
|
+
whenToUse = unquoted;
|
|
605
|
+
offset += line.length + 1;
|
|
563
606
|
}
|
|
564
|
-
|
|
607
|
+
const bodyStartOffset = closed ? Math.min(offset, content.length) : content.length;
|
|
608
|
+
return {
|
|
609
|
+
name, description, whenToUse,
|
|
610
|
+
understood: closed, bodyStartOffset, disableModelInvocation,
|
|
611
|
+
};
|
|
565
612
|
}
|
|
566
613
|
function normalizeForHash(content) {
|
|
567
614
|
return content.replace(/\r\n/g, '\n').replace(/\s+$/, '');
|
|
@@ -582,7 +629,9 @@ function buildComponent(type, relPath, content) {
|
|
|
582
629
|
name: type === 'skill' ? basename(relPath) : fileStem(relPath),
|
|
583
630
|
description: null,
|
|
584
631
|
estimable: false,
|
|
585
|
-
|
|
632
|
+
disableModelInvocation: false,
|
|
633
|
+
listingChars: 0,
|
|
634
|
+
listingComplete: true,
|
|
586
635
|
bodyChars: 0,
|
|
587
636
|
hash: null,
|
|
588
637
|
};
|
|
@@ -590,14 +639,32 @@ function buildComponent(type, relPath, content) {
|
|
|
590
639
|
const frontmatter = parseFrontmatter(content);
|
|
591
640
|
const fallbackName = type === 'skill' ? basename(relPath.replace(/\/SKILL\.md$/, '')) : fileStem(relPath);
|
|
592
641
|
const name = frontmatter.name ?? (fallbackName === 'SKILL.md' ? 'skill' : fallbackName);
|
|
642
|
+
// Skills and legacy commands list name + description + whenToUse (capped at
|
|
643
|
+
// 1,536 chars for description+whenToUse combined); agents list name + description.
|
|
644
|
+
// The component name is outside that cap.
|
|
645
|
+
const isSkillOrCommand = type === 'skill' || type === 'command';
|
|
646
|
+
const descLen = frontmatter.description?.length ?? 0;
|
|
647
|
+
const wtuLen = isSkillOrCommand ? (frontmatter.whenToUse?.length ?? 0) : 0;
|
|
648
|
+
const cappedDescWtu = isSkillOrCommand
|
|
649
|
+
? Math.min(descLen + wtuLen, LISTING_DESC_CAP)
|
|
650
|
+
: descLen;
|
|
651
|
+
const listingChars = name.length + cappedDescWtu;
|
|
652
|
+
// Skills/commands without a description may use a first-body-paragraph
|
|
653
|
+
// fallback that the bounded parser cannot safely determine — mark listing
|
|
654
|
+
// incomplete. Agents use only name+description semantics.
|
|
655
|
+
const listingComplete = isSkillOrCommand
|
|
656
|
+
? frontmatter.description !== null
|
|
657
|
+
: true;
|
|
593
658
|
return {
|
|
594
659
|
type,
|
|
595
660
|
relPath,
|
|
596
661
|
name,
|
|
597
662
|
description: frontmatter.description,
|
|
598
663
|
estimable: frontmatter.understood,
|
|
599
|
-
|
|
600
|
-
|
|
664
|
+
disableModelInvocation: frontmatter.disableModelInvocation,
|
|
665
|
+
listingChars,
|
|
666
|
+
listingComplete,
|
|
667
|
+
bodyChars: content.length - frontmatter.bodyStartOffset,
|
|
601
668
|
hash: type === 'outputStyle' ? null : hashComponentContent(content),
|
|
602
669
|
};
|
|
603
670
|
}
|
package/dist/doctor/report.d.ts
CHANGED
|
@@ -79,7 +79,13 @@ export interface ComponentInfo {
|
|
|
79
79
|
description: string | null;
|
|
80
80
|
/** False when the bounded frontmatter reader could not understand the file. */
|
|
81
81
|
estimable: boolean;
|
|
82
|
-
|
|
82
|
+
/** True only for unquoted YAML boolean `true` in frontmatter. */
|
|
83
|
+
disableModelInvocation: boolean;
|
|
84
|
+
/** Characters contributing to the session listing: name + description + whenToUse (skills). */
|
|
85
|
+
listingChars: number;
|
|
86
|
+
/** False when the bounded parser could not determine all listing text (e.g. skill
|
|
87
|
+
* with no description may use a first-body-paragraph fallback we cannot safely parse). */
|
|
88
|
+
listingComplete: boolean;
|
|
83
89
|
bodyChars: number;
|
|
84
90
|
/** Normalized content hash — only for skill/command/agent. */
|
|
85
91
|
hash: string | null;
|