@shrkcrft/plugin-api 0.1.0-alpha.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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/dist/ai-provider-plugin.d.ts +9 -0
  4. package/dist/ai-provider-plugin.d.ts.map +1 -0
  5. package/dist/ai-provider-plugin.js +1 -0
  6. package/dist/command-plugin.d.ts +11 -0
  7. package/dist/command-plugin.d.ts.map +1 -0
  8. package/dist/command-plugin.js +1 -0
  9. package/dist/construct.d.ts +57 -0
  10. package/dist/construct.d.ts.map +1 -0
  11. package/dist/construct.js +18 -0
  12. package/dist/convention.d.ts +77 -0
  13. package/dist/convention.d.ts.map +1 -0
  14. package/dist/convention.js +50 -0
  15. package/dist/generator-plugin.d.ts +6 -0
  16. package/dist/generator-plugin.d.ts.map +1 -0
  17. package/dist/generator-plugin.js +1 -0
  18. package/dist/index.d.ts +20 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +19 -0
  21. package/dist/knowledge-plugin.d.ts +15 -0
  22. package/dist/knowledge-plugin.d.ts.map +1 -0
  23. package/dist/knowledge-plugin.js +1 -0
  24. package/dist/mcp-tool-plugin.d.ts +9 -0
  25. package/dist/mcp-tool-plugin.d.ts.map +1 -0
  26. package/dist/mcp-tool-plugin.js +1 -0
  27. package/dist/pack-helper.d.ts +63 -0
  28. package/dist/pack-helper.d.ts.map +1 -0
  29. package/dist/pack-helper.js +40 -0
  30. package/dist/pack-manifest.d.ts +138 -0
  31. package/dist/pack-manifest.d.ts.map +1 -0
  32. package/dist/pack-manifest.js +96 -0
  33. package/dist/pack-signing.d.ts +50 -0
  34. package/dist/pack-signing.d.ts.map +1 -0
  35. package/dist/pack-signing.js +114 -0
  36. package/dist/playbook.d.ts +43 -0
  37. package/dist/playbook.d.ts.map +1 -0
  38. package/dist/playbook.js +13 -0
  39. package/dist/plugin-lifecycle-profile.d.ts +98 -0
  40. package/dist/plugin-lifecycle-profile.d.ts.map +1 -0
  41. package/dist/plugin-lifecycle-profile.js +119 -0
  42. package/dist/policy-check.d.ts +28 -0
  43. package/dist/policy-check.d.ts.map +1 -0
  44. package/dist/policy-check.js +3 -0
  45. package/dist/registration-hint.d.ts +96 -0
  46. package/dist/registration-hint.d.ts.map +1 -0
  47. package/dist/registration-hint.js +47 -0
  48. package/dist/scaffold-pattern.d.ts +56 -0
  49. package/dist/scaffold-pattern.d.ts.map +1 -0
  50. package/dist/scaffold-pattern.js +32 -0
  51. package/dist/search-tuning.d.ts +33 -0
  52. package/dist/search-tuning.d.ts.map +1 -0
  53. package/dist/search-tuning.js +3 -0
  54. package/dist/sharkcraft-plugin.d.ts +13 -0
  55. package/dist/sharkcraft-plugin.d.ts.map +1 -0
  56. package/dist/sharkcraft-plugin.js +1 -0
  57. package/dist/task-routing-hint.d.ts +49 -0
  58. package/dist/task-routing-hint.d.ts.map +1 -0
  59. package/dist/task-routing-hint.js +29 -0
  60. package/dist/template-plugin.d.ts +10 -0
  61. package/dist/template-plugin.d.ts.map +1 -0
  62. package/dist/template-plugin.js +1 -0
  63. package/package.json +49 -0
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Registration hint.
3
+ *
4
+ * A registration hint describes a downstream registration step that a
5
+ * generated construct typically needs (e.g. "register the new plugin in the
6
+ * composer", "wire the new event into the route table"). Packs contribute
7
+ * hints; the engine ships none.
8
+ *
9
+ * Hints are read-only data. The engine never auto-applies them — it can
10
+ * preview them via `shrk registrations preview <hintId>` and link them
11
+ * to templates via `template.metadata.registrationHintIds`.
12
+ *
13
+ * Discovery rules:
14
+ * - `discovery.targetFile` is a fixed relative path the hint applies to
15
+ * when present. If absent, `discovery.targetGlobs` lists candidate paths.
16
+ * - When more than one candidate matches, the hint MUST report
17
+ * `requiresHumanReview: true` and emit a conflict instead of guessing.
18
+ */
19
+ export interface IRegistrationHintDiscovery {
20
+ /** Fixed relative path inside the project root, when known. */
21
+ readonly targetFile?: string;
22
+ /** Glob patterns (relative paths). Used when the target file varies. */
23
+ readonly targetGlobs?: readonly string[];
24
+ /** Convention id(s) the target must satisfy (used as filter). */
25
+ readonly conventionIds?: readonly string[];
26
+ /** Profile ids the hint applies to (e.g. lifecycle profile). */
27
+ readonly profileIds?: readonly string[];
28
+ }
29
+ export type RegistrationHintOpKind = 'ensure-import' | 'insert-enum-entry' | 'insert-object-entry' | 'insert-before-closing-brace' | 'insert-between-anchors' | 'insert-after' | 'insert-before' | 'append' | 'export';
30
+ export interface IRegistrationHintOperation {
31
+ readonly kind: RegistrationHintOpKind;
32
+ /** Anchor literal used by anchor-based ops. */
33
+ readonly anchor?: string;
34
+ /** Begin anchor for insert-between-anchors. */
35
+ readonly beginAnchor?: string;
36
+ /** End anchor for insert-between-anchors. */
37
+ readonly endAnchor?: string;
38
+ /** Container name (interface / class / enum / object literal) for body ops. */
39
+ readonly containerName?: string;
40
+ /** Enum identifier for insert-enum-entry. */
41
+ readonly enumName?: string;
42
+ /** Object literal identifier for insert-object-entry. */
43
+ readonly objectName?: string;
44
+ /** Snippet body. May contain `{{var}}` placeholders. */
45
+ readonly snippet?: string;
46
+ /** Idempotency marker. */
47
+ readonly ifMissing?: string;
48
+ /** Find text (replace op). */
49
+ readonly find?: string;
50
+ /** Replace text (replace op). */
51
+ readonly replaceWith?: string;
52
+ /** Symbols (ensure-import / export). */
53
+ readonly symbols?: readonly string[];
54
+ /** Module specifier (ensure-import / export). */
55
+ readonly from?: string;
56
+ }
57
+ export interface IRegistrationHint {
58
+ readonly id: string;
59
+ readonly title: string;
60
+ readonly description?: string;
61
+ /**
62
+ * Variables the hint snippet references (templated via `{{var}}`). When a
63
+ * `preview` is requested, the engine substitutes these values.
64
+ */
65
+ readonly variables?: ReadonlyArray<{
66
+ readonly name: string;
67
+ readonly required: boolean;
68
+ readonly description?: string;
69
+ readonly defaultValue?: string;
70
+ }>;
71
+ readonly discovery: IRegistrationHintDiscovery;
72
+ /**
73
+ * The operations that the hint would perform if applied. Today the engine
74
+ * surfaces these as a *preview* only.
75
+ */
76
+ readonly operations: ReadonlyArray<IRegistrationHintOperation>;
77
+ /** When true, the preview must include a "requires human review" badge. */
78
+ readonly requiresHumanReview?: boolean;
79
+ /** Validation commands recommended after the human applies the hint. */
80
+ readonly validationCommands?: readonly string[];
81
+ /** Optional explanatory text shown alongside the preview. */
82
+ readonly explanation?: string;
83
+ /** Safety notes shown before any preview. */
84
+ readonly safetyNotes?: readonly string[];
85
+ readonly tags?: readonly string[];
86
+ }
87
+ export interface IRegistrationHintValidationIssue {
88
+ readonly field: string;
89
+ readonly message: string;
90
+ }
91
+ export interface IRegistrationHintValidationResult {
92
+ readonly valid: boolean;
93
+ readonly issues: readonly IRegistrationHintValidationIssue[];
94
+ }
95
+ export declare function validateRegistrationHint(value: unknown): IRegistrationHintValidationResult;
96
+ //# sourceMappingURL=registration-hint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registration-hint.d.ts","sourceRoot":"","sources":["../src/registration-hint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,0BAA0B;IACzC,+DAA+D;IAC/D,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,wEAAwE;IACxE,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,iEAAiE;IACjE,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,gEAAgE;IAChE,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC;AAED,MAAM,MAAM,sBAAsB,GAC9B,eAAe,GACf,mBAAmB,GACnB,qBAAqB,GACrB,6BAA6B,GAC7B,wBAAwB,GACxB,cAAc,GACd,eAAe,GACf,QAAQ,GACR,QAAQ,CAAC;AAEb,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;IAC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ACH,QAAQ,CAAC,SAAS,EAAE,0BAA0B,CAAC;IAC/C;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,0BAA0B,CAAC,CAAC;IAC/D,2EAA2E;IAC3E,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IACvC,wEAAwE;IACxE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChD,6DAA6D;IAC7D,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,6CAA6C;IAC7C,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,iCAAiC;IAChD,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,gCAAgC,EAAE,CAAC;CAC9D;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,iCAAiC,CAyB1F"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Registration hint.
3
+ *
4
+ * A registration hint describes a downstream registration step that a
5
+ * generated construct typically needs (e.g. "register the new plugin in the
6
+ * composer", "wire the new event into the route table"). Packs contribute
7
+ * hints; the engine ships none.
8
+ *
9
+ * Hints are read-only data. The engine never auto-applies them — it can
10
+ * preview them via `shrk registrations preview <hintId>` and link them
11
+ * to templates via `template.metadata.registrationHintIds`.
12
+ *
13
+ * Discovery rules:
14
+ * - `discovery.targetFile` is a fixed relative path the hint applies to
15
+ * when present. If absent, `discovery.targetGlobs` lists candidate paths.
16
+ * - When more than one candidate matches, the hint MUST report
17
+ * `requiresHumanReview: true` and emit a conflict instead of guessing.
18
+ */
19
+ export function validateRegistrationHint(value) {
20
+ const issues = [];
21
+ if (!value || typeof value !== 'object') {
22
+ return { valid: false, issues: [{ field: '<root>', message: 'hint must be an object' }] };
23
+ }
24
+ const o = value;
25
+ if (typeof o.id !== 'string' || o.id.length === 0)
26
+ issues.push({ field: 'id', message: 'id required' });
27
+ if (typeof o.title !== 'string' || o.title.length === 0)
28
+ issues.push({ field: 'title', message: 'title required' });
29
+ if (!o.discovery || typeof o.discovery !== 'object') {
30
+ issues.push({ field: 'discovery', message: 'discovery required' });
31
+ }
32
+ else {
33
+ const d = o.discovery;
34
+ const hasFixed = typeof d.targetFile === 'string' && d.targetFile.length > 0;
35
+ const hasGlobs = Array.isArray(d.targetGlobs) && d.targetGlobs.length > 0;
36
+ if (!hasFixed && !hasGlobs) {
37
+ issues.push({
38
+ field: 'discovery',
39
+ message: 'discovery requires either targetFile or targetGlobs[]',
40
+ });
41
+ }
42
+ }
43
+ if (!Array.isArray(o.operations) || o.operations.length === 0) {
44
+ issues.push({ field: 'operations', message: 'operations[] must be non-empty' });
45
+ }
46
+ return { valid: issues.length === 0, issues };
47
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Scaffold patterns let a pack express "if you see a file matching these
3
+ * paths, suggest this template id with these variables." Inference uses them
4
+ * to seed `infer templates` / `onboard --scaffold-templates` with high-
5
+ * confidence candidates without re-implementing pattern matching locally.
6
+ *
7
+ * Scaffold patterns are read-only data — they cannot execute code, shell
8
+ * commands, or run any pack-provided functions. The match step happens in
9
+ * the inspector layer.
10
+ */
11
+ /** A single variable extraction strategy. Values are recognized strings. */
12
+ export type ScaffoldExtractionStrategy = 'filename.kebab' | 'filename.pascal' | 'className' | `className.stripPrefix:${string}` | 'functionName' | 'directoryName' | 'nearestPackageName';
13
+ export interface IScaffoldPatternVariable {
14
+ /** Variable name as exposed to the template renderer (e.g. "name"). */
15
+ name: string;
16
+ /** Where the value should come from. */
17
+ from: ScaffoldExtractionStrategy;
18
+ /** Optional human description of what this variable represents. */
19
+ description?: string;
20
+ }
21
+ export interface IScaffoldPattern {
22
+ /** Stable id, e.g. "myproj.plugin-contract-pattern". */
23
+ id: string;
24
+ /** Short human-readable title. */
25
+ title: string;
26
+ /** What this pattern detects and where it points. */
27
+ description: string;
28
+ /** Glob-like include patterns relative to the project root. */
29
+ matchPaths: readonly string[];
30
+ /** Optional exclude patterns. */
31
+ excludePaths?: readonly string[];
32
+ /** Template id this pattern suggests when matched. */
33
+ templateId: string;
34
+ /** Variable extraction strategies. */
35
+ variables: readonly IScaffoldPatternVariable[];
36
+ /** Lifecycle hooks where this pattern is consulted. */
37
+ appliesWhen: readonly ('onboard' | 'infer-template' | 'create-plugin' | string)[];
38
+ /** Confidence floor when matched. */
39
+ confidence: 'high' | 'medium' | 'low';
40
+ /** Free-form tags for grouping. */
41
+ tags?: readonly string[];
42
+ /** Optional notes shown in pack doctor / scaffolds list. */
43
+ notes?: readonly string[];
44
+ /**
45
+ * Optional evidence the inspector should check before accepting the match
46
+ * (e.g. "the file exports an interface starting with I"). Strings only —
47
+ * the actual checks are inspector-side.
48
+ */
49
+ requiredEvidence?: readonly string[];
50
+ }
51
+ export declare function defineScaffoldPattern(pattern: IScaffoldPattern): IScaffoldPattern;
52
+ /** Helper used by pack authors to ship an array of scaffold patterns. */
53
+ export declare function defineScaffoldPatterns(patterns: readonly IScaffoldPattern[]): readonly IScaffoldPattern[];
54
+ export declare const RECOGNIZED_SCAFFOLD_STRATEGIES: ReadonlySet<string>;
55
+ export declare function isRecognizedScaffoldStrategy(s: string): boolean;
56
+ //# sourceMappingURL=scaffold-pattern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scaffold-pattern.d.ts","sourceRoot":"","sources":["../src/scaffold-pattern.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,4EAA4E;AAC5E,MAAM,MAAM,0BAA0B,GAClC,gBAAgB,GAChB,iBAAiB,GACjB,WAAW,GACX,yBAAyB,MAAM,EAAE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,4BAA4B,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAI/D"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Scaffold patterns let a pack express "if you see a file matching these
3
+ * paths, suggest this template id with these variables." Inference uses them
4
+ * to seed `infer templates` / `onboard --scaffold-templates` with high-
5
+ * confidence candidates without re-implementing pattern matching locally.
6
+ *
7
+ * Scaffold patterns are read-only data — they cannot execute code, shell
8
+ * commands, or run any pack-provided functions. The match step happens in
9
+ * the inspector layer.
10
+ */
11
+ export function defineScaffoldPattern(pattern) {
12
+ return pattern;
13
+ }
14
+ /** Helper used by pack authors to ship an array of scaffold patterns. */
15
+ export function defineScaffoldPatterns(patterns) {
16
+ return patterns;
17
+ }
18
+ export const RECOGNIZED_SCAFFOLD_STRATEGIES = new Set([
19
+ 'filename.kebab',
20
+ 'filename.pascal',
21
+ 'className',
22
+ 'functionName',
23
+ 'directoryName',
24
+ 'nearestPackageName',
25
+ ]);
26
+ export function isRecognizedScaffoldStrategy(s) {
27
+ if (RECOGNIZED_SCAFFOLD_STRATEGIES.has(s))
28
+ return true;
29
+ if (s.startsWith('className.stripPrefix:'))
30
+ return true;
31
+ return false;
32
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Search tuning lets packs/local config bias SharkCraft's deterministic search
3
+ * ranker. It NEVER filters results — only nudges scores. Boosts are capped to
4
+ * keep tuning from dominating the natural signal.
5
+ */
6
+ export interface ISearchTaskHint {
7
+ /** Token list (lowercase) that must appear in the query for the hint to apply. */
8
+ whenTokens?: readonly string[];
9
+ boostTags?: Record<string, number>;
10
+ boostKinds?: Record<string, number>;
11
+ boostIds?: Record<string, number>;
12
+ }
13
+ export type SearchTuningMergeStrategy = 'sum' | 'max';
14
+ export interface ISearchTuning {
15
+ id: string;
16
+ /** When set, the tuning only applies to results in these kinds. */
17
+ appliesToKinds?: readonly string[];
18
+ /**
19
+ * How this tuning composes with other tunings touching the same boost key.
20
+ * - `sum` (default): each tuning's boost adds, then the global cap clips.
21
+ * - `max`: when any tuning contributing to the key declares `max`, the
22
+ * combined boost is the strongest single contributor (by absolute value).
23
+ * Useful when packs ship overlapping bias rules and the user wants the
24
+ * single most-relevant one to win rather than stacking.
25
+ */
26
+ mergeStrategy?: SearchTuningMergeStrategy;
27
+ boostTags?: Record<string, number>;
28
+ boostIds?: Record<string, number>;
29
+ boostSources?: Record<string, number>;
30
+ taskHints?: readonly ISearchTaskHint[];
31
+ }
32
+ export declare function defineSearchTuning(input: ISearchTuning): ISearchTuning;
33
+ //# sourceMappingURL=search-tuning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-tuning.d.ts","sourceRoot":"","sources":["../src/search-tuning.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,kFAAkF;IAClF,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,MAAM,MAAM,yBAAyB,GAAG,KAAK,GAAG,KAAK,CAAC;AAEtD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,mEAAmE;IACnE,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,yBAAyB,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,SAAS,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;CACxC;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,CAEtE"}
@@ -0,0 +1,3 @@
1
+ export function defineSearchTuning(input) {
2
+ return input;
3
+ }
@@ -0,0 +1,13 @@
1
+ export interface ISharkCraftPluginContext {
2
+ readonly cwd: string;
3
+ readonly projectRoot: string;
4
+ /** Free-form bag for cross-plugin data — do not abuse. */
5
+ readonly bag: Map<string, unknown>;
6
+ }
7
+ export interface ISharkCraftPlugin {
8
+ readonly id: string;
9
+ readonly name: string;
10
+ readonly version?: string;
11
+ init?(context: ISharkCraftPluginContext): void | Promise<void>;
12
+ }
13
+ //# sourceMappingURL=sharkcraft-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharkcraft-plugin.d.ts","sourceRoot":"","sources":["../src/sharkcraft-plugin.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,0DAA0D;IAC1D,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,IAAI,CAAC,CAAC,OAAO,EAAE,wBAAwB,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChE"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Task routing hint. Packs and local config contribute hints that bias
3
+ * the engine's recommendations (`shrk task`, `shrk context`, `shrk recommend`,
4
+ * `shrk coverage scaffolds`, `shrk why`) toward their playbooks / templates /
5
+ * helpers / profiles / conventions without the engine hardcoding any
6
+ * project-specific tokens.
7
+ *
8
+ * Static data only — no executable code.
9
+ */
10
+ export interface ITaskRoutingMatch {
11
+ readonly keywords?: readonly string[];
12
+ readonly phrases?: readonly string[];
13
+ readonly regexes?: readonly string[];
14
+ readonly languages?: readonly string[];
15
+ readonly fileGlobs?: readonly string[];
16
+ readonly constructKinds?: readonly string[];
17
+ }
18
+ export interface ITaskRoutingRecommends {
19
+ readonly commands?: readonly string[];
20
+ readonly templates?: readonly string[];
21
+ readonly playbooks?: readonly string[];
22
+ readonly helpers?: readonly string[];
23
+ readonly profiles?: readonly string[];
24
+ readonly conventions?: readonly string[];
25
+ readonly knowledge?: readonly string[];
26
+ readonly policies?: readonly string[];
27
+ }
28
+ export interface ITaskRoutingHint {
29
+ readonly id: string;
30
+ readonly title: string;
31
+ readonly description?: string;
32
+ readonly match: ITaskRoutingMatch;
33
+ readonly recommends: ITaskRoutingRecommends;
34
+ /** Tag-/id-level confidence boost (0..5). */
35
+ readonly confidenceBoost?: number;
36
+ readonly explanation?: string;
37
+ readonly safetyNotes?: readonly string[];
38
+ readonly tags?: readonly string[];
39
+ }
40
+ export interface ITaskRoutingHintValidationIssue {
41
+ readonly field: string;
42
+ readonly message: string;
43
+ }
44
+ export interface ITaskRoutingHintValidationResult {
45
+ readonly valid: boolean;
46
+ readonly issues: readonly ITaskRoutingHintValidationIssue[];
47
+ }
48
+ export declare function validateTaskRoutingHint(value: unknown): ITaskRoutingHintValidationResult;
49
+ //# sourceMappingURL=task-routing-hint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-routing-hint.d.ts","sourceRoot":"","sources":["../src/task-routing-hint.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAA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CACnC;AAED,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,+BAA+B,EAAE,CAAC;CAC7D;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,gCAAgC,CAmBxF"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Task routing hint. Packs and local config contribute hints that bias
3
+ * the engine's recommendations (`shrk task`, `shrk context`, `shrk recommend`,
4
+ * `shrk coverage scaffolds`, `shrk why`) toward their playbooks / templates /
5
+ * helpers / profiles / conventions without the engine hardcoding any
6
+ * project-specific tokens.
7
+ *
8
+ * Static data only — no executable code.
9
+ */
10
+ export function validateTaskRoutingHint(value) {
11
+ const issues = [];
12
+ if (!value || typeof value !== 'object') {
13
+ return { valid: false, issues: [{ field: '<root>', message: 'hint must be an object' }] };
14
+ }
15
+ const o = value;
16
+ if (typeof o.id !== 'string' || o.id.length === 0) {
17
+ issues.push({ field: 'id', message: 'id required' });
18
+ }
19
+ if (typeof o.title !== 'string' || o.title.length === 0) {
20
+ issues.push({ field: 'title', message: 'title required' });
21
+ }
22
+ if (!o.match || typeof o.match !== 'object') {
23
+ issues.push({ field: 'match', message: 'match required' });
24
+ }
25
+ if (!o.recommends || typeof o.recommends !== 'object') {
26
+ issues.push({ field: 'recommends', message: 'recommends required' });
27
+ }
28
+ return { valid: issues.length === 0, issues };
29
+ }
@@ -0,0 +1,10 @@
1
+ import type { ISharkCraftPlugin } from './sharkcraft-plugin.js';
2
+ export interface ITemplatePluginTemplate {
3
+ id: string;
4
+ name: string;
5
+ description: string;
6
+ }
7
+ export interface ITemplatePlugin extends ISharkCraftPlugin {
8
+ readonly templates: readonly ITemplatePluginTemplate[];
9
+ }
10
+ //# sourceMappingURL=template-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-plugin.d.ts","sourceRoot":"","sources":["../src/template-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,MAAM,WAAW,uBAAuB;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACxD,QAAQ,CAAC,SAAS,EAAE,SAAS,uBAAuB,EAAE,CAAC;CACxD"}
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@shrkcrft/plugin-api",
3
+ "version": "0.1.0-alpha.2",
4
+ "description": "SharkCraft plugin API: extension points for commands, knowledge, templates, MCP tools.",
5
+ "license": "MIT",
6
+ "author": "SharkCraft contributors",
7
+ "type": "module",
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "bun": "./src/index.ts",
14
+ "import": "./dist/index.js",
15
+ "default": "./dist/index.js"
16
+ }
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md",
21
+ "LICENSE"
22
+ ],
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/shrkcrft/sharkcraft.git",
26
+ "directory": "packages/plugin-api"
27
+ },
28
+ "homepage": "https://github.com/shrkcrft/sharkcraft",
29
+ "bugs": {
30
+ "url": "https://github.com/shrkcrft/sharkcraft/issues"
31
+ },
32
+ "keywords": [
33
+ "sharkcraft",
34
+ "plugin-api"
35
+ ],
36
+ "engines": {
37
+ "bun": ">=1.1.0",
38
+ "node": ">=18"
39
+ },
40
+ "scripts": {
41
+ "typecheck": "tsc --noEmit -p tsconfig.json"
42
+ },
43
+ "dependencies": {
44
+ "@shrkcrft/core": "^0.1.0-alpha.2"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public"
48
+ }
49
+ }