clud-bug 0.6.34 → 0.7.0-rc.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.
Files changed (95) hide show
  1. package/bin/clud-bug.js +10 -1353
  2. package/dist/cli/agents-md.d.ts +16 -0
  3. package/dist/cli/agents-md.d.ts.map +1 -0
  4. package/dist/cli/agents-md.js +226 -0
  5. package/dist/cli/agents-md.js.map +1 -0
  6. package/dist/cli/audit.d.ts +13 -0
  7. package/dist/cli/audit.d.ts.map +1 -0
  8. package/dist/cli/audit.js +90 -0
  9. package/dist/cli/audit.js.map +1 -0
  10. package/dist/cli/branch-protection.d.ts +57 -0
  11. package/dist/cli/branch-protection.d.ts.map +1 -0
  12. package/dist/cli/branch-protection.js +118 -0
  13. package/dist/cli/branch-protection.js.map +1 -0
  14. package/dist/cli/edit-workflow.d.ts +18 -0
  15. package/dist/cli/edit-workflow.d.ts.map +1 -0
  16. package/dist/cli/edit-workflow.js +43 -0
  17. package/dist/cli/edit-workflow.js.map +1 -0
  18. package/dist/cli/index.d.ts +8 -0
  19. package/dist/cli/index.d.ts.map +1 -0
  20. package/dist/cli/index.js +18 -0
  21. package/dist/cli/index.js.map +1 -0
  22. package/dist/cli/main.d.ts +3 -0
  23. package/dist/cli/main.d.ts.map +1 -0
  24. package/dist/cli/main.js +1336 -0
  25. package/dist/cli/main.js.map +1 -0
  26. package/dist/cli/skill-usage.d.ts +109 -0
  27. package/dist/cli/skill-usage.d.ts.map +1 -0
  28. package/dist/cli/skill-usage.js +380 -0
  29. package/dist/cli/skill-usage.js.map +1 -0
  30. package/dist/cli/skills.d.ts +56 -0
  31. package/dist/cli/skills.d.ts.map +1 -0
  32. package/dist/cli/skills.js +292 -0
  33. package/dist/cli/skills.js.map +1 -0
  34. package/dist/cli/update.d.ts +29 -0
  35. package/dist/cli/update.d.ts.map +1 -0
  36. package/dist/cli/update.js +186 -0
  37. package/dist/cli/update.js.map +1 -0
  38. package/dist/cli/usage.d.ts +142 -0
  39. package/dist/cli/usage.d.ts.map +1 -0
  40. package/dist/cli/usage.js +348 -0
  41. package/dist/cli/usage.js.map +1 -0
  42. package/dist/core/audit.d.ts +8 -0
  43. package/dist/core/audit.d.ts.map +1 -0
  44. package/dist/core/audit.js +47 -0
  45. package/dist/core/audit.js.map +1 -0
  46. package/dist/core/detect.d.ts +77 -0
  47. package/dist/core/detect.d.ts.map +1 -0
  48. package/dist/core/detect.js +262 -0
  49. package/dist/core/detect.js.map +1 -0
  50. package/dist/core/index.d.ts +8 -0
  51. package/dist/core/index.d.ts.map +1 -0
  52. package/dist/core/index.js +14 -0
  53. package/dist/core/index.js.map +1 -0
  54. package/dist/core/prompts.d.ts +9 -0
  55. package/dist/core/prompts.d.ts.map +1 -0
  56. package/dist/core/prompts.js +401 -0
  57. package/dist/core/prompts.js.map +1 -0
  58. package/dist/core/render-review.d.ts +6 -0
  59. package/dist/core/render-review.d.ts.map +1 -0
  60. package/dist/core/render-review.js +219 -0
  61. package/dist/core/render-review.js.map +1 -0
  62. package/dist/core/render.d.ts +13 -0
  63. package/dist/core/render.d.ts.map +1 -0
  64. package/dist/core/render.js +80 -0
  65. package/dist/core/render.js.map +1 -0
  66. package/dist/core/review-schema.d.ts +42 -0
  67. package/dist/core/review-schema.d.ts.map +1 -0
  68. package/dist/core/review-schema.js +156 -0
  69. package/dist/core/review-schema.js.map +1 -0
  70. package/dist/core/skills.d.ts +80 -0
  71. package/dist/core/skills.d.ts.map +1 -0
  72. package/dist/core/skills.js +510 -0
  73. package/dist/core/skills.js.map +1 -0
  74. package/package.json +27 -4
  75. package/{lib/agents-md.js → src/cli/agents-md.ts} +25 -14
  76. package/{lib/audit.js → src/cli/audit.ts} +37 -44
  77. package/{lib/branch-protection.js → src/cli/branch-protection.ts} +75 -11
  78. package/{lib/edit-workflow.js → src/cli/edit-workflow.ts} +32 -11
  79. package/src/cli/index.ts +101 -0
  80. package/src/cli/main.ts +1376 -0
  81. package/{lib/skill-usage.js → src/cli/skill-usage.ts} +168 -94
  82. package/src/cli/skills.ts +386 -0
  83. package/{lib/update.js → src/cli/update.ts} +68 -27
  84. package/{lib/usage.js → src/cli/usage.ts} +167 -76
  85. package/src/core/audit.ts +53 -0
  86. package/{lib/detect.js → src/core/detect.ts} +100 -47
  87. package/src/core/index.ts +70 -0
  88. package/{lib/prompts.js → src/core/prompts.ts} +16 -2
  89. package/{lib/render-review.js → src/core/render-review.ts} +57 -25
  90. package/{lib/render.js → src/core/render.ts} +36 -10
  91. package/{lib/review-schema.js → src/core/review-schema.ts} +68 -5
  92. package/{lib/skills.js → src/core/skills.ts} +172 -343
  93. package/templates/workflow-py.yml.tmpl +2 -2
  94. package/templates/workflow-ts.yml.tmpl +2 -2
  95. package/templates/workflow.yml.tmpl +17 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/core/render.ts"],"names":[],"mappings":"AA8BA,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;CACvB;AAWD,eAAO,MAAM,QAAQ,EAAE,cAItB,CAAC;AAOF,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAM3E,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,CAkBjE;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAGhF;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,CAQxD;AAKD,MAAM,MAAM,gBAAgB,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;AAEvD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,CAInE"}
@@ -0,0 +1,80 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { readFileSync } from 'node:fs';
3
+ import { fileURLToPath } from 'node:url';
4
+ import { dirname, join } from 'node:path';
5
+ import { serializedReviewSchema } from './review-schema.js';
6
+ const PLACEHOLDER_RE = /\{\{([A-Z_]+)\}\}/g;
7
+ // CLUD_BUG_VERSION (0.0.O / v0.6.22) — read from this package's
8
+ // package.json at module-load time. The rendered workflow uses
9
+ // `npx --yes clud-bug@<CLUD_BUG_VERSION>` in the post-step that renders
10
+ // structured output to markdown. Pinning to the version that ran
11
+ // `clud-bug init` guarantees the renderer's output shape matches the
12
+ // prompt's expectations.
13
+ //
14
+ // IMPORTANT (v0.7.0 TS migration): the JS source lived at lib/render.js,
15
+ // so `join(__dirname, '..', 'package.json')` reached the package root
16
+ // from one level up. The TS port compiles to dist/core/render.js, which
17
+ // is TWO levels deep (dist/core/) — so we walk up TWO levels to find
18
+ // package.json. Without this adjustment, module-load would throw at
19
+ // runtime with "ENOENT dist/package.json". Verify on rebuild via:
20
+ // node -e "import('./dist/core/render.js').then(m => console.log(m.DEFAULTS.CLUD_BUG_VERSION))"
21
+ const __dirname = dirname(fileURLToPath(import.meta.url));
22
+ const PKG_VERSION = JSON.parse(readFileSync(join(__dirname, '..', '..', 'package.json'), 'utf8')).version;
23
+ // Default values for substitution tokens that every template uses.
24
+ // Callers can override per-render by passing the same key in `vars`.
25
+ //
26
+ // CCA_VERSION pins `anthropics/claude-code-action` to a specific tag in
27
+ // every shipped workflow. Without this, templates resolved `@v1` (the
28
+ // floating major), so upstream changes could silently land in installed
29
+ // workflows mid-cycle. Bumping the pin requires a clud-bug release, which
30
+ // makes the upgrade visible + lets users opt out by pinning a different
31
+ // version in their own forked workflow.
32
+ export const DEFAULTS = {
33
+ CCA_VERSION: 'v1.0.133',
34
+ CLUD_BUG_VERSION: PKG_VERSION,
35
+ REVIEW_SCHEMA: serializedReviewSchema(),
36
+ };
37
+ // Multi-line value substitution preserves YAML/Markdown indentation by
38
+ // applying the placeholder line's leading whitespace to every
39
+ // continuation line. Single-line values pass through unchanged so
40
+ // existing tokens (CCA_VERSION, PROJECT_DESCRIPTION) keep current behavior.
41
+ export function render(template, vars) {
42
+ const merged = { ...DEFAULTS, ...vars };
43
+ return template.replace(PLACEHOLDER_RE, (_match, key, offset) => {
44
+ if (!(key in merged)) {
45
+ throw new Error(`Missing template variable: ${key}`);
46
+ }
47
+ const value = String(merged[key]);
48
+ if (!value.includes('\n')) {
49
+ return value;
50
+ }
51
+ const lineStart = template.lastIndexOf('\n', offset - 1) + 1;
52
+ const leadingWhitespaceMatch = template.slice(lineStart, offset).match(/^(\s*)/);
53
+ const indent = leadingWhitespaceMatch ? (leadingWhitespaceMatch[1] ?? '') : '';
54
+ return value
55
+ .split('\n')
56
+ .map((line, i) => (i === 0 || line === '' ? line : indent + line))
57
+ .join('\n');
58
+ });
59
+ }
60
+ export async function renderFile(path, vars) {
61
+ const tmpl = await readFile(path, 'utf8');
62
+ return render(tmpl, vars);
63
+ }
64
+ export function pickTemplate(languages) {
65
+ if (languages.includes('typescript') || languages.includes('javascript')) {
66
+ return 'workflow-ts.yml.tmpl';
67
+ }
68
+ if (languages.includes('python')) {
69
+ return 'workflow-py.yml.tmpl';
70
+ }
71
+ return 'workflow.yml.tmpl';
72
+ }
73
+ export function templateLanguage(tmplName) {
74
+ if (tmplName === 'workflow-ts.yml.tmpl')
75
+ return 'ts';
76
+ if (tmplName === 'workflow-py.yml.tmpl')
77
+ return 'py';
78
+ return 'generic';
79
+ }
80
+ //# sourceMappingURL=render.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.js","sourceRoot":"","sources":["../../src/core/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,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O,sBAAsB,CAAC;IAChC,CAAC;IACD,IAAI,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACjC,OAAO,sBAAsB,CAAC;IAChC,CAAC;IACD,OAAO,mBAAmB,CAAC;AAC7B,CAAC;AAOD,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,IAAI,QAAQ,KAAK,sBAAsB;QAAE,OAAO,IAAI,CAAC;IACrD,IAAI,QAAQ,KAAK,sBAAsB;QAAE,OAAO,IAAI,CAAC;IACrD,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,42 @@
1
+ type JSONSchemaObject = Record<string, unknown>;
2
+ export declare const REVIEW_SCHEMA: JSONSchemaObject;
3
+ export declare function serializedReviewSchema(): string;
4
+ export type FindingSeverity = 'critical' | 'minor' | 'preexisting';
5
+ export interface ReviewFinding {
6
+ skill: string;
7
+ summary: string;
8
+ file?: string;
9
+ line?: number;
10
+ reasoning?: string;
11
+ }
12
+ export interface PerSkillScanItem {
13
+ skill: string;
14
+ outcome: string;
15
+ }
16
+ export interface DedicatedSection {
17
+ section_name: string;
18
+ skill: string;
19
+ findings: ReviewFinding[];
20
+ }
21
+ export interface ReviewSummaryCounts {
22
+ critical: number;
23
+ minor: number;
24
+ preexisting: number;
25
+ resolved_from_prior: number;
26
+ still_open: number;
27
+ }
28
+ export type ReviewStatusHeader = 'critical findings' | 'clean' | 'bare';
29
+ export interface ReviewData {
30
+ status_header: ReviewStatusHeader | string;
31
+ summary_counts: ReviewSummaryCounts;
32
+ per_skill_scan: PerSkillScanItem[];
33
+ critical_findings: ReviewFinding[];
34
+ minor_findings: ReviewFinding[];
35
+ preexisting_findings: ReviewFinding[];
36
+ skills_referenced: string[];
37
+ last_reviewed_sha: string;
38
+ dedicated_sections?: DedicatedSection[];
39
+ diagnostics?: string[];
40
+ }
41
+ export {};
42
+ //# sourceMappingURL=review-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-schema.d.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AAE,CAAC;IAC5B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACxC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB"}
@@ -0,0 +1,156 @@
1
+ // JSON Schema for clud-bug review structured output (0.0.O / v0.6.22).
2
+ //
3
+ // Passed to claude-code-action via `claude_args: --json-schema '<JSON>'`.
4
+ // The Agent SDK validates the LLM's emitted JSON against this schema and
5
+ // re-prompts on mismatch (internal retry; not a clud-bug-level loop).
6
+ //
7
+ // Schema design choices:
8
+ // - Flat top-level — composite-action outputs are a single string, so we
9
+ // fromJSON() once and pluck fields. No deep nesting that would force
10
+ // extra path traversal in the post-step shell.
11
+ // - Word/char caps in `description:` — the SDK doc names these as the
12
+ // primary lever for keeping output cheap. They're advisory (the SDK
13
+ // does not enforce numeric caps; the LLM treats them as instruction).
14
+ // 0.0.X already lives in the prompt, so the schema description here is
15
+ // a complementary belt-and-suspenders signal.
16
+ // - Required minimum — only the fields a renderer absolutely needs to
17
+ // produce a valid summary comment. Counts are always required (the
18
+ // stats header + status block depend on them); finding arrays are
19
+ // required but may be empty (a clean review has 0 findings, not
20
+ // missing arrays).
21
+ // - `additionalProperties: false` on every object — schema-strict mode.
22
+ // Anthropic's structured-outputs doc explicitly recommends this to
23
+ // keep the model from inventing fields.
24
+ //
25
+ // Bumped via deliberate edit; not derived from a TypeScript type. The
26
+ // rendering side (./render-review.ts) treats unknown fields permissively
27
+ // — schema and renderer can drift up to one minor version safely.
28
+ const FINDING_ITEM = {
29
+ type: 'object',
30
+ additionalProperties: false,
31
+ properties: {
32
+ skill: {
33
+ type: 'string',
34
+ description: 'The skill name in brackets, e.g. "critical-issues-only". Must match a loaded skill or "(none)".',
35
+ },
36
+ file: {
37
+ type: 'string',
38
+ description: 'Path of the affected file relative to repo root. Optional when the finding is cross-cutting.',
39
+ },
40
+ line: {
41
+ type: 'integer',
42
+ minimum: 1,
43
+ description: 'Line number in the affected file. Required when `file` is set.',
44
+ },
45
+ summary: {
46
+ type: 'string',
47
+ description: 'One sentence stating the claim. Max ~20 words; no trailing period (the renderer adds one).',
48
+ },
49
+ reasoning: {
50
+ type: 'string',
51
+ description: 'Evidence anchor + suggested fix. Max ~80 words. Rendered inside <details> block; can be omitted for self-evident findings.',
52
+ },
53
+ },
54
+ required: ['skill', 'summary'],
55
+ };
56
+ const PER_SKILL_SCAN_ITEM = {
57
+ type: 'object',
58
+ additionalProperties: false,
59
+ properties: {
60
+ skill: { type: 'string' },
61
+ outcome: {
62
+ type: 'string',
63
+ description: 'One sentence describing what the skill found. Max ~15 words. Examples: "scanned all paths. 2 critical findings below.", "0 findings.", "not applicable to this diff."',
64
+ },
65
+ },
66
+ required: ['skill', 'outcome'],
67
+ };
68
+ export const REVIEW_SCHEMA = {
69
+ type: 'object',
70
+ additionalProperties: false,
71
+ properties: {
72
+ status_header: {
73
+ type: 'string',
74
+ enum: ['critical findings', 'clean', 'bare'],
75
+ description: 'Strict-mode opt-in repos: `critical findings` when ANY 🔴 finding exists, otherwise `clean`. Non-strict-mode repos (the default): emit `bare` — the renderer produces a `## 🐛 Clud Bug review` H2 with no suffix, matching the v0.6.21- behaviour. Check .claude/skills/.clud-bug.json for `strictMode: true` to pick critical/clean vs bare.',
76
+ },
77
+ summary_counts: {
78
+ type: 'object',
79
+ additionalProperties: false,
80
+ properties: {
81
+ critical: { type: 'integer', minimum: 0 },
82
+ minor: { type: 'integer', minimum: 0 },
83
+ preexisting: { type: 'integer', minimum: 0 },
84
+ resolved_from_prior: { type: 'integer', minimum: 0 },
85
+ still_open: { type: 'integer', minimum: 0 },
86
+ },
87
+ required: ['critical', 'minor', 'preexisting', 'resolved_from_prior', 'still_open'],
88
+ },
89
+ per_skill_scan: {
90
+ type: 'array',
91
+ description: 'One entry per LOADED skill — even silent ones. Empty when no skills are installed.',
92
+ items: PER_SKILL_SCAN_ITEM,
93
+ },
94
+ critical_findings: {
95
+ type: 'array',
96
+ description: 'NEW 🔴 findings (bugs, security, perf, missing test coverage). May be empty.',
97
+ items: FINDING_ITEM,
98
+ },
99
+ minor_findings: {
100
+ type: 'array',
101
+ description: 'NEW 🟡 findings (nits, style, observations). May be empty.',
102
+ items: FINDING_ITEM,
103
+ },
104
+ preexisting_findings: {
105
+ type: 'array',
106
+ description: 'NEW 🟣 findings (issues that pre-date this PR). May be empty.',
107
+ items: FINDING_ITEM,
108
+ },
109
+ dedicated_sections: {
110
+ type: 'array',
111
+ description: 'Per-dedicated-mode-skill section blocks. Each item carries the section header text and its findings.',
112
+ items: {
113
+ type: 'object',
114
+ additionalProperties: false,
115
+ properties: {
116
+ section_name: { type: 'string', description: 'Human-readable section title, e.g. "Brand voice".' },
117
+ skill: { type: 'string', description: 'The dedicated skill name.' },
118
+ findings: { type: 'array', items: FINDING_ITEM },
119
+ },
120
+ required: ['section_name', 'skill', 'findings'],
121
+ },
122
+ },
123
+ diagnostics: {
124
+ type: 'array',
125
+ description: '0.0.T tee-hint diagnostics. One line per `head -c` cap that fired during fetch. Empty when no truncation occurred.',
126
+ items: { type: 'string' },
127
+ },
128
+ skills_referenced: {
129
+ type: 'array',
130
+ description: 'Names of every skill cited in any finding. Empty list (or ["(none)"]) when no skill applied.',
131
+ items: { type: 'string' },
132
+ },
133
+ last_reviewed_sha: {
134
+ type: 'string',
135
+ description: 'The HEAD SHA at review time, used by the incremental-diff handshake. Set to the literal value of the workflow env var $HEAD_SHA.',
136
+ },
137
+ },
138
+ required: [
139
+ 'status_header',
140
+ 'summary_counts',
141
+ 'per_skill_scan',
142
+ 'critical_findings',
143
+ 'minor_findings',
144
+ 'preexisting_findings',
145
+ 'skills_referenced',
146
+ 'last_reviewed_sha',
147
+ ],
148
+ };
149
+ // Serialize the schema for inclusion in workflow templates as the
150
+ // `--json-schema '<JSON>'` argument. Single-line (the workflow YAML uses
151
+ // the pipe block; single-quoted JSON inside that needs to stay flat to
152
+ // avoid YAML parser surprises with embedded newlines).
153
+ export function serializedReviewSchema() {
154
+ return JSON.stringify(REVIEW_SCHEMA);
155
+ }
156
+ //# sourceMappingURL=review-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-schema.js","sourceRoot":"","sources":["../../src/core/review-schema.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,EAAE;AACF,0EAA0E;AAC1E,yEAAyE;AACzE,sEAAsE;AACtE,EAAE;AACF,yBAAyB;AACzB,2EAA2E;AAC3E,yEAAyE;AACzE,mDAAmD;AACnD,wEAAwE;AACxE,wEAAwE;AACxE,0EAA0E;AAC1E,2EAA2E;AAC3E,kDAAkD;AAClD,wEAAwE;AACxE,uEAAuE;AACvE,sEAAsE;AACtE,oEAAoE;AACpE,uBAAuB;AACvB,0EAA0E;AAC1E,uEAAuE;AACvE,4CAA4C;AAC5C,EAAE;AACF,sEAAsE;AACtE,yEAAyE;AACzE,kEAAkE;AAalE,MAAM,YAAY,GAAqB;IACrC,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,iGAAiG;SAC/G;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,8FAA8F;SAC5G;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,gEAAgE;SAC9E;QACD,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,4FAA4F;SAC1G;QACD,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,4HAA4H;SAC1I;KACF;IACD,QAAQ,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC;CAC/B,CAAC;AAEF,MAAM,mBAAmB,GAAqB;IAC5C,IAAI,EAAE,QAAQ;IACd,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,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 export declare const API_BASE = "https://skills.sh/api/v1";
2
+ export declare const MAX_SKILLS = 8;
3
+ export interface SkillDescriptor {
4
+ source: string;
5
+ name: string;
6
+ description: string;
7
+ installs: number;
8
+ kind?: string;
9
+ content?: string;
10
+ }
11
+ type RawSkillItem = {
12
+ source?: string;
13
+ repo?: string;
14
+ name?: string;
15
+ slug?: string;
16
+ description?: string;
17
+ summary?: string;
18
+ installs?: number;
19
+ installCount?: number;
20
+ };
21
+ type RawSkillListResponse = RawSkillItem[] | {
22
+ skills?: RawSkillItem[];
23
+ results?: RawSkillItem[];
24
+ } | unknown;
25
+ export declare function normalizeList(data: RawSkillListResponse): SkillDescriptor[];
26
+ interface SkillsClientOptions {
27
+ fetch?: typeof globalThis.fetch;
28
+ base?: string;
29
+ userAgent?: string;
30
+ }
31
+ export declare class SkillsClient {
32
+ #private;
33
+ private readonly fetch;
34
+ private readonly base;
35
+ private readonly userAgent;
36
+ constructor({ fetch, base, userAgent }?: SkillsClientOptions);
37
+ search(terms: string[]): Promise<SkillDescriptor[]>;
38
+ curated(): Promise<SkillDescriptor[]>;
39
+ getContent(source: string, name: string): Promise<string>;
40
+ }
41
+ export interface RankableSkill extends SkillDescriptor {
42
+ kind?: string;
43
+ }
44
+ export declare function rankAndCap(curated: RankableSkill[], searched: RankableSkill[], baseline: RankableSkill[], cap?: number): RankableSkill[];
45
+ export declare function readReviewMode(skillContent: unknown): 'shared' | 'dedicated';
46
+ export interface AppliesToRule {
47
+ paths: string[];
48
+ extensions: string[];
49
+ }
50
+ export declare function readAppliesTo(skillContent: unknown): AppliesToRule | null;
51
+ export declare function appliesToPr(skillContent: unknown, prPaths: unknown): boolean;
52
+ export interface SkillWithOptionalContent {
53
+ content?: unknown;
54
+ [key: string]: unknown;
55
+ }
56
+ export declare function partitionByReviewMode<T extends SkillWithOptionalContent>(skills: T[]): {
57
+ shared: T[];
58
+ dedicated: T[];
59
+ };
60
+ export declare function extractPerSkillLine(comment: unknown, skillName: unknown): string | null;
61
+ export interface PrComment {
62
+ body?: unknown;
63
+ user?: {
64
+ login?: unknown;
65
+ };
66
+ created_at?: unknown;
67
+ }
68
+ export declare function selectReviewHeader(comments: unknown, botLogin: unknown): string | null;
69
+ export declare function extractFirstReviewHeaderLine(body: unknown): string | null;
70
+ export declare function selectReviewBody(comments: unknown, botLogin: unknown): string | null;
71
+ export interface ReviewStatsHeader {
72
+ important: number;
73
+ nit: number;
74
+ preExisting: number;
75
+ }
76
+ export declare function extractStatsHeader(comment: unknown): ReviewStatsHeader | null;
77
+ export declare function isCriticalReviewHeader(headerLine: unknown): boolean;
78
+ export declare function classifyPerSkillOutcome(outcomeLine: unknown): 'failure' | 'success';
79
+ export {};
80
+ //# sourceMappingURL=skills.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/core/skills.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,QAAQ,6BAA6B,CAAC;AACnD,eAAO,MAAM,UAAU,IAAI,CAAC;AAO5B,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,KAAK,YAAY,GAAG;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,KAAK,oBAAoB,GACrB,YAAY,EAAE,GACd;IAAE,MAAM,CAAC,EA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