@skillit/core 1.5.0 → 2.1.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/dist/audit-formatter.d.ts +2 -0
- package/dist/audit-formatter.d.ts.map +1 -1
- package/dist/audit-formatter.js +2 -0
- package/dist/audit-formatter.js.map +1 -1
- package/dist/audit-score.d.ts.map +1 -1
- package/dist/audit-score.js +95 -4
- package/dist/audit-score.js.map +1 -1
- package/dist/audit-types.d.ts +1 -29
- package/dist/audit-types.d.ts.map +1 -1
- package/dist/audit.d.ts +6 -2
- package/dist/audit.d.ts.map +1 -1
- package/dist/audit.js +64 -32
- package/dist/audit.js.map +1 -1
- package/dist/config-extract.d.ts +48 -0
- package/dist/config-extract.d.ts.map +1 -0
- package/dist/config-extract.js +230 -0
- package/dist/config-extract.js.map +1 -0
- package/dist/config-renderer.d.ts +6 -2
- package/dist/config-renderer.d.ts.map +1 -1
- package/dist/config-renderer.js +14 -11
- package/dist/config-renderer.js.map +1 -1
- package/dist/docs-scanner.d.ts +3 -0
- package/dist/docs-scanner.d.ts.map +1 -1
- package/dist/docs-scanner.js +3 -0
- package/dist/docs-scanner.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/refine/ast-edit.d.ts +41 -0
- package/dist/refine/ast-edit.d.ts.map +1 -1
- package/dist/refine/ast-edit.js +187 -19
- package/dist/refine/ast-edit.js.map +1 -1
- package/dist/refine/config-source.d.ts +81 -0
- package/dist/refine/config-source.d.ts.map +1 -0
- package/dist/refine/config-source.js +283 -0
- package/dist/refine/config-source.js.map +1 -0
- package/dist/refine/dep-skills.d.ts +4 -0
- package/dist/refine/dep-skills.d.ts.map +1 -0
- package/dist/refine/dep-skills.js +98 -0
- package/dist/refine/dep-skills.js.map +1 -0
- package/dist/refine/index.d.ts +6 -1
- package/dist/refine/index.d.ts.map +1 -1
- package/dist/refine/index.js +4 -1
- package/dist/refine/index.js.map +1 -1
- package/dist/refine/jsdoc-edit.d.ts +8 -1
- package/dist/refine/jsdoc-edit.d.ts.map +1 -1
- package/dist/refine/jsdoc-edit.js +8 -1
- package/dist/refine/jsdoc-edit.js.map +1 -1
- package/dist/refine/loop.d.ts.map +1 -1
- package/dist/refine/loop.js +26 -5
- package/dist/refine/loop.js.map +1 -1
- package/dist/refine/package-metadata.d.ts +34 -0
- package/dist/refine/package-metadata.d.ts.map +1 -0
- package/dist/refine/package-metadata.js +77 -0
- package/dist/refine/package-metadata.js.map +1 -0
- package/dist/refine/select-targets.d.ts.map +1 -1
- package/dist/refine/select-targets.js +31 -6
- package/dist/refine/select-targets.js.map +1 -1
- package/dist/refine/types.d.ts +29 -2
- package/dist/refine/types.d.ts.map +1 -1
- package/dist/renderer.js +32 -10
- package/dist/renderer.js.map +1 -1
- package/dist/tokens.d.ts +2 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +2 -0
- package/dist/tokens.js.map +1 -1
- package/dist/types.d.ts +40 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
// packages/core/src/refine/config-source.ts
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { glob, readFile, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
5
|
+
import { extractConfigSurface } from '../config-extract.js';
|
|
6
|
+
import { truncateToTokenBudget } from '../tokens.js';
|
|
7
|
+
import { stripRefineTags, upsertPropertyJsDocTag } from './ast-edit.js';
|
|
8
|
+
import { readPackageMetadata } from './package-metadata.js';
|
|
9
|
+
/** Token cap for the implementation-reference grounding fed to the model. */
|
|
10
|
+
const GROUNDING_TOKEN_CAP = 8000;
|
|
11
|
+
const EXCLUDED_GROUNDING_DIRS = new Set(['node_modules', 'dist', 'build', '.git', 'coverage']);
|
|
12
|
+
/** Maximum directories to walk upward from the config file seeking package.json. */
|
|
13
|
+
const MAX_PACKAGE_LOOKUP_DEPTH = 8;
|
|
14
|
+
/**
|
|
15
|
+
* {@link RefineSource} for a TypeScript configuration surface.
|
|
16
|
+
*
|
|
17
|
+
* Reads the consumer's config type with {@link extractConfigSurface}, exposes it
|
|
18
|
+
* as a single `config` surface in an {@link ExtractedSkill}, and writes routing
|
|
19
|
+
* tags back as JSDoc onto the type's individual property declarations. Unlike
|
|
20
|
+
* the CLI source — whose routing lives at the command (surface) level — a config
|
|
21
|
+
* surface is documented per-OPTION: each fix targets one property by its
|
|
22
|
+
* dot-path `configKey` (e.g. `outDir`, `components.prefix`), routed through
|
|
23
|
+
* {@link upsertPropertyJsDocTag}.
|
|
24
|
+
*
|
|
25
|
+
* It also enriches the skill from the package.json nearest the config file (its
|
|
26
|
+
* description, keywords, repository) and a sibling README, supplying the audit
|
|
27
|
+
* context the metadata checks (F1/F2/F3/E5/W4/W5/W6) score against — without it
|
|
28
|
+
* a config skill forfeits those points even when the package already carries
|
|
29
|
+
* the data.
|
|
30
|
+
*/
|
|
31
|
+
export class ConfigRefineSource {
|
|
32
|
+
opts;
|
|
33
|
+
/** Cached metadata, populated by {@link extract} (which the loop runs first). */
|
|
34
|
+
metadata = {};
|
|
35
|
+
/** Cached surface, populated by {@link extract}; read by {@link guidance}. */
|
|
36
|
+
surface;
|
|
37
|
+
/** Cached implementation-reference grounding, populated by {@link extract}. */
|
|
38
|
+
grounding = '';
|
|
39
|
+
constructor(opts) {
|
|
40
|
+
this.opts = opts;
|
|
41
|
+
}
|
|
42
|
+
async extract() {
|
|
43
|
+
const source = await readFile(this.opts.configFile, 'utf8');
|
|
44
|
+
const surface = extractConfigSurface(source, this.opts.typeName);
|
|
45
|
+
if (!surface) {
|
|
46
|
+
throw new Error(`[skillit] config type '${this.opts.typeName}' not found in ${this.opts.configFile}`);
|
|
47
|
+
}
|
|
48
|
+
this.surface = surface;
|
|
49
|
+
this.grounding = await this.loadGrounding();
|
|
50
|
+
const meta = await this.loadMetadata();
|
|
51
|
+
// The render headline (`skill.description`) prefers a caller-supplied
|
|
52
|
+
// config-specific description so the skill body describes the config surface
|
|
53
|
+
// rather than the package. `skill.packageDescription` (set below) is kept as
|
|
54
|
+
// the LITERAL package.json description so the audit's F1 check validates the
|
|
55
|
+
// real published metadata — a config override must not mask a missing or
|
|
56
|
+
// too-short package.json description.
|
|
57
|
+
const description = this.opts.description ?? meta.packageDescription ?? '';
|
|
58
|
+
const skill = {
|
|
59
|
+
name: this.opts.name ?? meta.packageName ?? this.opts.typeName,
|
|
60
|
+
description,
|
|
61
|
+
functions: [],
|
|
62
|
+
classes: [],
|
|
63
|
+
types: [],
|
|
64
|
+
enums: [],
|
|
65
|
+
variables: [],
|
|
66
|
+
examples: [],
|
|
67
|
+
configSurfaces: [surface]
|
|
68
|
+
};
|
|
69
|
+
if (meta.keywords?.length)
|
|
70
|
+
skill.keywords = meta.keywords;
|
|
71
|
+
if (meta.repository)
|
|
72
|
+
skill.repository = meta.repository;
|
|
73
|
+
if (meta.packageDescription)
|
|
74
|
+
skill.packageDescription = meta.packageDescription;
|
|
75
|
+
if (meta.readme !== undefined)
|
|
76
|
+
skill.readme = meta.readme;
|
|
77
|
+
// A sibling `<config>.example.ts` (if present) is the skill's usage example
|
|
78
|
+
// — clears E4 and feeds the rendered Examples section. The refine loop
|
|
79
|
+
// drafts it once when absent; reading it back here surfaces it thereafter.
|
|
80
|
+
// Read directly and tolerate ENOENT (no existsSync precheck — that is a
|
|
81
|
+
// check-then-use race).
|
|
82
|
+
try {
|
|
83
|
+
const example = (await readFile(this.exampleFilePath(), 'utf8')).trim();
|
|
84
|
+
if (example)
|
|
85
|
+
skill.examples = [example];
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
// No/unreadable example — leave examples empty (E4 stays a gap).
|
|
89
|
+
}
|
|
90
|
+
return skill;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Map an improvement target to its on-disk location. Config targets carry the
|
|
94
|
+
* option's dot-path `configKey` as `name` (kind `config-option`); the config
|
|
95
|
+
* type holds them, so the file is always the config file and the declName is
|
|
96
|
+
* the type. A `config-example` target points at the same file with no path.
|
|
97
|
+
*/
|
|
98
|
+
resolveTargetLocation(target) {
|
|
99
|
+
if (target.kind === 'config-example') {
|
|
100
|
+
return { file: this.opts.configFile, declName: this.opts.typeName };
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
file: this.opts.configFile,
|
|
104
|
+
declName: this.opts.typeName,
|
|
105
|
+
propertyPath: target.name
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async applyFixes(fixes) {
|
|
109
|
+
// An `@example` fix is the drafted config-example FILE, not a JSDoc tag:
|
|
110
|
+
// write it to the sibling `<config>.example.ts` — but only if one does not
|
|
111
|
+
// already exist, so a hand-authored example is never clobbered.
|
|
112
|
+
const exampleFix = fixes.find((fix) => fix.tag === 'example');
|
|
113
|
+
if (exampleFix) {
|
|
114
|
+
// Write-if-absent atomically with the `wx` flag (create, fail if exists)
|
|
115
|
+
// rather than existsSync-then-write — the latter is a TOCTOU race, and the
|
|
116
|
+
// atomic flag enforces the no-clobber intent at the syscall.
|
|
117
|
+
try {
|
|
118
|
+
await writeFile(this.exampleFilePath(), normalizeExampleFile(exampleFix.value), {
|
|
119
|
+
encoding: 'utf8',
|
|
120
|
+
flag: 'wx'
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
// EEXIST = an example already exists; preserve it. Re-throw anything else.
|
|
125
|
+
if (error.code !== 'EEXIST')
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
let source = await readFile(this.opts.configFile, 'utf8');
|
|
130
|
+
let changed = false;
|
|
131
|
+
for (const fix of fixes) {
|
|
132
|
+
if (fix.tag === 'example')
|
|
133
|
+
continue; // handled above (separate file)
|
|
134
|
+
// `fix.toolName` is the option's dot-path configKey (set by the
|
|
135
|
+
// audit-score config-option target). Route it to the matching property.
|
|
136
|
+
const next = upsertPropertyJsDocTag(source, this.opts.typeName, fix.toolName, fix.tag, fix.value);
|
|
137
|
+
if (next !== source) {
|
|
138
|
+
source = next;
|
|
139
|
+
changed = true;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (changed) {
|
|
143
|
+
await writeFile(this.opts.configFile, source, 'utf8');
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Drafting conventions passed to the model each iteration. Scopes every
|
|
148
|
+
* routing tag to the single named option, constrains claims to what the type
|
|
149
|
+
* and provided context can support (the model sees the type, NOT the code that
|
|
150
|
+
* consumes the config, so unconstrained drafting invents wrong runtime
|
|
151
|
+
* semantics), and tells it how to draft the `@example` config file. Built from
|
|
152
|
+
* the cached surface that {@link extract} populates first.
|
|
153
|
+
*/
|
|
154
|
+
guidance() {
|
|
155
|
+
const optionList = (this.surface?.options ?? [])
|
|
156
|
+
.map((o) => `- \`${o.configKey ?? o.name}\`: ${o.type}`)
|
|
157
|
+
.join('\n');
|
|
158
|
+
const typeName = this.opts.typeName;
|
|
159
|
+
return [
|
|
160
|
+
`You are documenting the individual options of the TypeScript configuration object \`${typeName}\`.`,
|
|
161
|
+
`Each work item's "Tool" is ONE option, named by its dot-path key (e.g. \`outDir\`, \`components.prefix\`) — except an @example work item, whose "Tool" is the config type \`${typeName}\` itself.`,
|
|
162
|
+
`For @useWhen / @avoidWhen / @pitfalls: write guidance SPECIFIC to that single option — when to set it (and to what kind of value), when to leave it unset, and footguns unique to its value or interactions. Do NOT describe the configuration type as a whole, the annotate-vs-\`defineConfig()\` choice, or anything that applies to every option; never repeat the same point across options.`,
|
|
163
|
+
this.grounding
|
|
164
|
+
? `GROUND every runtime-behavior claim in the IMPLEMENTATION REFERENCE below (the actual code that consumes this config) and the option's type. State behavior the code actually exhibits — e.g. what an empty array/object means, whether an invalid value throws or is silently ignored, what a flag toggles, how options interact. Do NOT contradict the reference, and do NOT assert behavior absent from both the reference and the type; omit it instead. A confidently wrong "NEVER" is worse than no pitfall.`
|
|
165
|
+
: `GROUND every claim in the option's TYPE and the documentation provided to you. You can see the type, not the code that reads this config — so do NOT assert runtime behavior you cannot verify: whether an empty array/object means "all" or "none", whether an invalid value throws or is silently ignored, what a boolean flag actually toggles, or how two options interact at runtime. If a behavior is not evidenced by the type or the docs, omit it or phrase it as a type-level fact ("\`mode\` accepts 'submit' | 'auto-save'"). A confidently wrong "NEVER" is worse than no pitfall — prefer fewer, verifiable points over speculative ones.`,
|
|
166
|
+
`For @example: output a COMPLETE, type-correct example configuration FILE — import statements plus a default export — saved verbatim as a sibling \`*.config.example.ts\` that must compile. Import \`defineConfig\`/\`${typeName}\` from the package by its published name ONLY if the example lives outside that package; if it sits inside the package's own \`src\`, import from the local source entrypoint (a relative path) so the self-import does not resolve to an unbuilt \`dist\`. Use realistic values for required options and a few common optional ones. Output ONLY the file source: no prose, no markdown, no code fences.`,
|
|
167
|
+
`Options (key: type):\n${optionList}`,
|
|
168
|
+
...(this.grounding
|
|
169
|
+
? [
|
|
170
|
+
`IMPLEMENTATION REFERENCE (the code that consumes this config — ground runtime-behavior claims in it):\n${this.grounding}`
|
|
171
|
+
]
|
|
172
|
+
: [])
|
|
173
|
+
].join('\n\n');
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Discover and parse the package.json nearest the config file (walking up to
|
|
177
|
+
* {@link MAX_PACKAGE_LOOKUP_DEPTH} directories) plus a sibling README. Cached
|
|
178
|
+
* so repeated extract/score passes read the filesystem once. Never throws —
|
|
179
|
+
* unreadable or absent files just yield empty fields.
|
|
180
|
+
*/
|
|
181
|
+
async loadMetadata() {
|
|
182
|
+
const pkgDir = this.findPackageDir();
|
|
183
|
+
if (!pkgDir)
|
|
184
|
+
return this.metadata;
|
|
185
|
+
const meta = await readPackageMetadata(pkgDir);
|
|
186
|
+
this.metadata = {
|
|
187
|
+
...(meta.packageDescription !== undefined
|
|
188
|
+
? { packageDescription: meta.packageDescription }
|
|
189
|
+
: {}),
|
|
190
|
+
...(meta.keywords !== undefined ? { keywords: meta.keywords } : {}),
|
|
191
|
+
...(meta.repository !== undefined ? { repository: meta.repository } : {}),
|
|
192
|
+
...(meta.readme !== undefined ? { readme: meta.readme } : {})
|
|
193
|
+
};
|
|
194
|
+
return meta;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Sibling example path for the config file: same directory, the config file's
|
|
198
|
+
* base name with any `.ts`/`.tsx`/`.mts`/`.cts` extension replaced by
|
|
199
|
+
* `.example.ts` (e.g. `z2f.config.ts` → `z2f.config.example.ts`,
|
|
200
|
+
* `config.ts` → `config.example.ts`).
|
|
201
|
+
*/
|
|
202
|
+
exampleFilePath() {
|
|
203
|
+
const dir = dirname(this.opts.configFile);
|
|
204
|
+
const base = basename(this.opts.configFile).replace(/\.[cm]?tsx?$/, '');
|
|
205
|
+
return join(dir, `${base}.example.ts`);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Read the grounding globs into a single token-capped implementation
|
|
209
|
+
* reference. Prepends the config module's own declarations (refine tags
|
|
210
|
+
* stripped — see {@link stripRefineTags}) so preset tables/defaults/validation
|
|
211
|
+
* ground the model, then appends the matched glob files (skipping `.d.ts`,
|
|
212
|
+
* excluded dirs, and the already-included config file). Returns `''` when no
|
|
213
|
+
* globs are configured or nothing matches — never throws.
|
|
214
|
+
*/
|
|
215
|
+
async loadGrounding() {
|
|
216
|
+
const globs = this.opts.groundingGlobs;
|
|
217
|
+
if (!globs?.length)
|
|
218
|
+
return '';
|
|
219
|
+
const configAbs = resolve(this.opts.configFile);
|
|
220
|
+
const seen = new Set([configAbs]);
|
|
221
|
+
const parts = [];
|
|
222
|
+
// The config module itself often holds non-type declarations the model
|
|
223
|
+
// needs to be accurate — preset tables, defaults, `defineConfig`/validation
|
|
224
|
+
// (e.g. z2f's `SHADCN_OVERRIDES`). Include it, but strip ONLY the routing
|
|
225
|
+
// tags this source writes back across iterations (so our own accumulated
|
|
226
|
+
// annotations aren't fed back as "implementation"); hand-authored prose —
|
|
227
|
+
// the real runtime-behavior grounding — is preserved.
|
|
228
|
+
const configSource = await readFile(this.opts.configFile, 'utf8').catch(() => '');
|
|
229
|
+
const configDecls = stripRefineTags(configSource).trim();
|
|
230
|
+
if (configDecls)
|
|
231
|
+
parts.push(`// ${this.opts.configFile} (config module declarations)\n${configDecls}`);
|
|
232
|
+
for (const pattern of globs) {
|
|
233
|
+
let matches;
|
|
234
|
+
try {
|
|
235
|
+
matches = glob(pattern, {
|
|
236
|
+
exclude: (f) => f.endsWith('.d.ts') || f.split(/[\\/]/).some((seg) => EXCLUDED_GROUNDING_DIRS.has(seg))
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
continue; // bad pattern — skip
|
|
241
|
+
}
|
|
242
|
+
for await (const file of matches) {
|
|
243
|
+
const abs = resolve(file);
|
|
244
|
+
if (seen.has(abs))
|
|
245
|
+
continue; // config file is pre-seeded above
|
|
246
|
+
seen.add(abs);
|
|
247
|
+
const content = await readFile(file, 'utf8').catch(() => '');
|
|
248
|
+
if (content.trim())
|
|
249
|
+
parts.push(`// ${file}\n${content.trim()}`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (parts.length === 0)
|
|
253
|
+
return '';
|
|
254
|
+
return truncateToTokenBudget(parts.join('\n\n'), GROUNDING_TOKEN_CAP);
|
|
255
|
+
}
|
|
256
|
+
/** Nearest ancestor directory of the config file that holds a package.json. */
|
|
257
|
+
findPackageDir() {
|
|
258
|
+
let dir = dirname(this.opts.configFile);
|
|
259
|
+
for (let i = 0; i < MAX_PACKAGE_LOOKUP_DEPTH; i++) {
|
|
260
|
+
if (existsSync(join(dir, 'package.json')))
|
|
261
|
+
return dir;
|
|
262
|
+
const parent = dirname(dir);
|
|
263
|
+
if (parent === dir)
|
|
264
|
+
break;
|
|
265
|
+
dir = parent;
|
|
266
|
+
}
|
|
267
|
+
return undefined;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Normalize model-drafted example content into a clean source file: strip a
|
|
272
|
+
* surrounding markdown code fence if the model added one, and ensure a trailing
|
|
273
|
+
* newline. The draft is instructed to omit fences, but a chatty backend may add
|
|
274
|
+
* them anyway.
|
|
275
|
+
*/
|
|
276
|
+
function normalizeExampleFile(raw) {
|
|
277
|
+
let body = raw.trim();
|
|
278
|
+
const fenced = body.match(/^```[a-zA-Z]*\n([\s\S]*?)\n```$/);
|
|
279
|
+
if (fenced?.[1] !== undefined)
|
|
280
|
+
body = fenced[1].trim();
|
|
281
|
+
return `${body}\n`;
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=config-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-source.js","sourceRoot":"","sources":["../../src/refine/config-source.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAIrD,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAsB5D,6EAA6E;AAC7E,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAU/F,oFAAoF;AACpF,MAAM,wBAAwB,GAAG,CAAC,CAA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AqB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,EAAE,CAWnE;AAED,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAE9E"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
function extractFrontmatterField(content, field) {
|
|
4
|
+
const match = content.match(new RegExp(`^${field}:\\s*(.+?)\\s*$`, 'm'));
|
|
5
|
+
if (!match?.[1])
|
|
6
|
+
return undefined;
|
|
7
|
+
return match[1].replace(/^["']|["']$/g, '');
|
|
8
|
+
}
|
|
9
|
+
function parseSkillMd(skillMdPath) {
|
|
10
|
+
let content;
|
|
11
|
+
try {
|
|
12
|
+
content = readFileSync(skillMdPath, 'utf8');
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const name = extractFrontmatterField(content, 'name');
|
|
18
|
+
if (!name)
|
|
19
|
+
return undefined;
|
|
20
|
+
const description = extractFrontmatterField(content, 'description');
|
|
21
|
+
return { name, ...(description ? { description } : {}) };
|
|
22
|
+
}
|
|
23
|
+
function discoverForDep(pkgDir, depName) {
|
|
24
|
+
const depDir = join(pkgDir, 'node_modules', depName);
|
|
25
|
+
if (!existsSync(depDir))
|
|
26
|
+
return [];
|
|
27
|
+
const depPkgPath = join(depDir, 'package.json');
|
|
28
|
+
if (!existsSync(depPkgPath))
|
|
29
|
+
return [];
|
|
30
|
+
let depPkg = {};
|
|
31
|
+
try {
|
|
32
|
+
depPkg = JSON.parse(readFileSync(depPkgPath, 'utf8'));
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
const skillDirs = [];
|
|
38
|
+
const explicitSkills = depPkg.skillit?.skills;
|
|
39
|
+
if (Array.isArray(explicitSkills) && explicitSkills.length > 0) {
|
|
40
|
+
for (const relPath of explicitSkills) {
|
|
41
|
+
if (typeof relPath === 'string') {
|
|
42
|
+
const dir = join(depDir, relPath);
|
|
43
|
+
if (existsSync(join(dir, 'SKILL.md')))
|
|
44
|
+
skillDirs.push(dir);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
const skillsRoot = join(depDir, 'skills');
|
|
50
|
+
if (existsSync(skillsRoot)) {
|
|
51
|
+
let entries;
|
|
52
|
+
try {
|
|
53
|
+
entries = readdirSync(skillsRoot, { withFileTypes: true, encoding: 'utf8' });
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
for (const dirent of entries) {
|
|
59
|
+
if (!dirent.isDirectory())
|
|
60
|
+
continue;
|
|
61
|
+
const skillDir = join(skillsRoot, dirent.name);
|
|
62
|
+
if (existsSync(join(skillDir, 'SKILL.md')))
|
|
63
|
+
skillDirs.push(skillDir);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const refs = [];
|
|
68
|
+
for (const skillDir of skillDirs) {
|
|
69
|
+
const parsed = parseSkillMd(join(skillDir, 'SKILL.md'));
|
|
70
|
+
if (!parsed)
|
|
71
|
+
continue;
|
|
72
|
+
const relativePath = skillDir.slice(pkgDir.length + 1);
|
|
73
|
+
refs.push({
|
|
74
|
+
name: parsed.name,
|
|
75
|
+
path: relativePath,
|
|
76
|
+
...(parsed.description ? { description: parsed.description } : {})
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return refs;
|
|
80
|
+
}
|
|
81
|
+
export function discoverDepSkillsSync(pkgDir) {
|
|
82
|
+
let pkg = {};
|
|
83
|
+
try {
|
|
84
|
+
pkg = JSON.parse(readFileSync(join(pkgDir, 'package.json'), 'utf8'));
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
const depNames = Object.keys(pkg.dependencies ?? {});
|
|
90
|
+
const refs = [];
|
|
91
|
+
for (const depName of depNames)
|
|
92
|
+
refs.push(...discoverForDep(pkgDir, depName));
|
|
93
|
+
return refs;
|
|
94
|
+
}
|
|
95
|
+
export async function discoverDepSkills(pkgDir) {
|
|
96
|
+
return discoverDepSkillsSync(pkgDir);
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=dep-skills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dep-skills.js","sourceRoot":"","sources":["../../src/refine/dep-skills.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEhE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,SAAS,uBAAuB,CAC9B,OAAe,EACf,KAA6B;IAE7B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,KAAK,iBAAiB,EAAE,GAAG,CAAC,CAAC,CAAC;IACzE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAAE,OAAO,SAAS,CAAC;IAClC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,YAAY,CAAC,WAAmB;IACvC,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACH,OAAO,GAAG,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,IAAI,GAAG,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACtD,IAAI,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IAC5B,MAAM,WAAW,GAAG,uBAAuB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IACpE,OAAO,EAAE,IAAI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ClD,IAAI,GAAG,GAA8C,EAAE,CAAC;IACxD,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAe,CAAC;IACrF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;IACrD,MAAM,IAAI,GAAkB,EAAE,CAAC;IAC/B,KAAK,MAAM,OAAO,IAAI,QAAQ;QAAE,IAAI,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC9E,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,MAAc;IACpD,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;AACvC,CAAC"}
|
package/dist/refine/index.d.ts
CHANGED
|
@@ -3,5 +3,10 @@ export * from './select-targets.js';
|
|
|
3
3
|
export { refineSkill } from './loop.js';
|
|
4
4
|
export type { ScoreSkill } from './loop.js';
|
|
5
5
|
export { insertJsDocTag } from './jsdoc-edit.js';
|
|
6
|
-
export { upsertJsDocTag, readJsDocTags } from './ast-edit.js';
|
|
6
|
+
export { upsertJsDocTag, upsertPropertyJsDocTag, readJsDocTags } from './ast-edit.js';
|
|
7
|
+
export { ConfigRefineSource } from './config-source.js';
|
|
8
|
+
export type { ConfigRefineSourceOptions } from './config-source.js';
|
|
9
|
+
export { stripScope, findNearestPackageDir, readPackageMetadata } from './package-metadata.js';
|
|
10
|
+
export type { PackageMetadata } from './package-metadata.js';
|
|
11
|
+
export { discoverDepSkills, discoverDepSkillsSync } from './dep-skills.js';
|
|
7
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/refine/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/refine/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC/F,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/refine/index.js
CHANGED
|
@@ -2,5 +2,8 @@ export * from './types.js';
|
|
|
2
2
|
export * from './select-targets.js';
|
|
3
3
|
export { refineSkill } from './loop.js';
|
|
4
4
|
export { insertJsDocTag } from './jsdoc-edit.js';
|
|
5
|
-
export { upsertJsDocTag, readJsDocTags } from './ast-edit.js';
|
|
5
|
+
export { upsertJsDocTag, upsertPropertyJsDocTag, readJsDocTags } from './ast-edit.js';
|
|
6
|
+
export { ConfigRefineSource } from './config-source.js';
|
|
7
|
+
export { stripScope, findNearestPackageDir, readPackageMetadata } from './package-metadata.js';
|
|
8
|
+
export { discoverDepSkills, discoverDepSkillsSync } from './dep-skills.js';
|
|
6
9
|
//# sourceMappingURL=index.js.map
|
package/dist/refine/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/refine/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/refine/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE/F,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { RefineTag } from './types.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated internal alias — use {@link upsertJsDocTag}. Kept for callers/tests.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* A thin pass-through to {@link upsertJsDocTag} with identical parameters and
|
|
7
|
+
* behaviour; retained only so existing callers and tests that import the old
|
|
8
|
+
* name keep compiling. New code should call {@link upsertJsDocTag} directly.
|
|
9
|
+
*/
|
|
3
10
|
export declare function insertJsDocTag(source: string, exportName: string, tag: RefineTag, content: string): string;
|
|
4
11
|
//# sourceMappingURL=jsdoc-edit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsdoc-edit.d.ts","sourceRoot":"","sources":["../../src/refine/jsdoc-edit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C
|
|
1
|
+
{"version":3,"file":"jsdoc-edit.d.ts","sourceRoot":"","sources":["../../src/refine/jsdoc-edit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG5C;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,MAAM,GACd,MAAM,CAER"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { upsertJsDocTag } from './ast-edit.js';
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated internal alias — use {@link upsertJsDocTag}. Kept for callers/tests.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* A thin pass-through to {@link upsertJsDocTag} with identical parameters and
|
|
7
|
+
* behaviour; retained only so existing callers and tests that import the old
|
|
8
|
+
* name keep compiling. New code should call {@link upsertJsDocTag} directly.
|
|
9
|
+
*/
|
|
3
10
|
export function insertJsDocTag(source, exportName, tag, content) {
|
|
4
11
|
return upsertJsDocTag(source, exportName, tag, content);
|
|
5
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsdoc-edit.js","sourceRoot":"","sources":["../../src/refine/jsdoc-edit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C
|
|
1
|
+
{"version":3,"file":"jsdoc-edit.js","sourceRoot":"","sources":["../../src/refine/jsdoc-edit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAc,EACd,UAAkB,EAClB,GAAc,EACd,OAAe;IAEf,OAAO,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/refine/loop.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,KAAK,EAGV,aAAa,EACb,YAAY,EAEb,MAAM,YAAY,CAAC;AAEpB,iFAAiF;AACjF,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,cAAc,KAAK,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/refine/loop.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,KAAK,EAGV,aAAa,EACb,YAAY,EAEb,MAAM,YAAY,CAAC;AAEpB,iFAAiF;AACjF,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,cAAc,KAAK,kBAAkB,CAAC;AAwBvE,wBAAsB,WAAW,CAC/B,IAAI,EAAE,aAAa,GAAG;IAAE,UAAU,CAAC,EAAE,UAAU,CAAA;CAAE,GAChD,OAAO,CAAC,YAAY,CAAC,CAuGvB"}
|
package/dist/refine/loop.js
CHANGED
|
@@ -5,14 +5,24 @@ import { selectWorkItems } from './select-targets.js';
|
|
|
5
5
|
const DEFAULT_PASSING_GRADES = ['A'];
|
|
6
6
|
const DEFAULT_MAX_ITERATIONS = 5;
|
|
7
7
|
const DEFAULT_ITEMS_PER_ITERATION = 5;
|
|
8
|
-
function defaultScore(
|
|
8
|
+
function defaultScore() {
|
|
9
9
|
return (skill) => {
|
|
10
|
-
const audit = auditSkill(skill
|
|
10
|
+
const audit = auditSkill(skill);
|
|
11
11
|
return estimateSkillJudgeScore(audit, skill);
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Total work items currently available across all improvements (uncapped), used
|
|
16
|
+
* as the loop's "backlog" signal. Reuses {@link selectWorkItems} so it counts
|
|
17
|
+
* exactly what would become work — i.e. improvements with a parseable tag and
|
|
18
|
+
* targets. Shrinks as config options get tagged; stays flat when the model is
|
|
19
|
+
* stuck re-drafting the same still-failing targets.
|
|
20
|
+
*/
|
|
21
|
+
function countAvailableWork(improvements) {
|
|
22
|
+
return selectWorkItems(improvements, Number.POSITIVE_INFINITY).length;
|
|
23
|
+
}
|
|
14
24
|
export async function refineSkill(opts) {
|
|
15
|
-
const { source, model, passingGrades = DEFAULT_PASSING_GRADES, maxIterations = DEFAULT_MAX_ITERATIONS, itemsPerIteration = DEFAULT_ITEMS_PER_ITERATION, onIteration, scoreSkill = defaultScore(
|
|
25
|
+
const { source, model, passingGrades = DEFAULT_PASSING_GRADES, maxIterations = DEFAULT_MAX_ITERATIONS, itemsPerIteration = DEFAULT_ITEMS_PER_ITERATION, onIteration, scoreSkill = defaultScore() } = opts;
|
|
16
26
|
const passingSet = new Set(passingGrades);
|
|
17
27
|
const iterations = [];
|
|
18
28
|
let skill = await source.extract();
|
|
@@ -22,9 +32,19 @@ export async function refineSkill(opts) {
|
|
|
22
32
|
return finished('passed', skill, estimate, iterations, guidance);
|
|
23
33
|
}
|
|
24
34
|
let prevTotal = estimate.total;
|
|
35
|
+
let prevAvailable = countAvailableWork(estimate.improvements);
|
|
25
36
|
for (let i = 0; i < maxIterations; i++) {
|
|
26
|
-
|
|
27
|
-
|
|
37
|
+
const available = countAvailableWork(estimate.improvements);
|
|
38
|
+
// Plateau: stop early when the score has stalled — but NOT while we're still
|
|
39
|
+
// burning down a backlog of work. Per-option config coverage targets become
|
|
40
|
+
// score-neutral once the routing thresholds (W7/W8/W9) pass, yet each
|
|
41
|
+
// iteration still documents more options; a pure score check would halt that
|
|
42
|
+
// mid-surface. Only plateau when the score is flat AND the available-work
|
|
43
|
+
// pool is not shrinking (the genuinely-stuck case the check exists to catch).
|
|
44
|
+
if (i > 0 &&
|
|
45
|
+
i < maxIterations - 1 &&
|
|
46
|
+
estimate.total <= prevTotal &&
|
|
47
|
+
available >= prevAvailable) {
|
|
28
48
|
return finished('plateau', skill, estimate, iterations, guidance);
|
|
29
49
|
}
|
|
30
50
|
const workItems = selectWorkItems(estimate.improvements, itemsPerIteration);
|
|
@@ -74,6 +94,7 @@ export async function refineSkill(opts) {
|
|
|
74
94
|
}
|
|
75
95
|
await source.applyFixes(fixes);
|
|
76
96
|
prevTotal = estimate.total;
|
|
97
|
+
prevAvailable = available;
|
|
77
98
|
skill = await source.extract();
|
|
78
99
|
estimate = scoreSkill(skill);
|
|
79
100
|
const iteration = { iteration: i + 1, estimate, workItems, fixes };
|
package/dist/refine/loop.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop.js","sourceRoot":"","sources":["../../src/refine/loop.ts"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAYtD,MAAM,sBAAsB,GAA+C,CAAC,GAAG,CAAC,CAAC;AACjF,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAEtC,SAAS,YAAY
|
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CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACvE,CAAC;QAED,MAAM,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAC/B,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC;QAC3B,aAAa,GAAG,SAAS,CAAC;QAC1B,KAAK,GAAG,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;QAC/B,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;QAE7B,MAAM,SAAS,GAAoB,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QACpF,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC3B,WAAW,EAAE,CAAC,SAAS,CAAC,CAAC;QAEzB,IAAI,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,QAAQ,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC,gBAAgB,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,QAAQ,CACf,aAA+B,EAC/B,UAA0B,EAC1B,aAAiC,EACjC,UAAsC,EACtC,QAA4B;IAE5B,OAAO;QACL,UAAU;QACV,UAAU;QACV,aAAa;QACb,MAAM,EAAE,aAAa,KAAK,QAAQ;QAClC,aAAa;QACb,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ParsedReadme } from '../audit-types.js';
|
|
2
|
+
/** Package metadata read from a package dir (package.json fields + parsed README). */
|
|
3
|
+
export interface PackageMetadata {
|
|
4
|
+
/** Scope-stripped package name. */
|
|
5
|
+
packageName?: string;
|
|
6
|
+
/** Full (scoped) package name as written in package.json, e.g. `@scope/pkg`. */
|
|
7
|
+
fullPackageName?: string;
|
|
8
|
+
packageDescription?: string;
|
|
9
|
+
keywords?: string[];
|
|
10
|
+
repository?: string;
|
|
11
|
+
readme?: ParsedReadme;
|
|
12
|
+
/** `bin` field from package.json — maps command names to entry-point paths. */
|
|
13
|
+
bin?: Record<string, string>;
|
|
14
|
+
/** `private` field from package.json — true means the package is not published. */
|
|
15
|
+
isPrivate?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** Strip a leading `@scope/` from a package name. */
|
|
18
|
+
export declare function stripScope(name: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Walk up from `startDir` (inclusive) up to `maxDepth` parents looking for a
|
|
21
|
+
* directory containing a `package.json`. Returns the dir, or undefined.
|
|
22
|
+
*
|
|
23
|
+
* @param startDir - Directory to start the upward search from (searched first).
|
|
24
|
+
* @param maxDepth - Maximum number of parent directories to ascend (default 5).
|
|
25
|
+
* @returns The nearest directory containing a `package.json`, or `undefined`
|
|
26
|
+
* when none is found within `maxDepth` levels (or the filesystem root is hit).
|
|
27
|
+
*/
|
|
28
|
+
export declare function findNearestPackageDir(startDir: string, maxDepth?: number): Promise<string | undefined>;
|
|
29
|
+
/**
|
|
30
|
+
* Read package.json fields + `parseReadme(README.md)` from `pkgDir`. Never
|
|
31
|
+
* throws — unreadable/absent files yield unset fields.
|
|
32
|
+
*/
|
|
33
|
+
export declare function readPackageMetadata(pkgDir: string): Promise<PackageMetadata>;
|
|
34
|
+
//# sourceMappingURL=package-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-metadata.d.ts","sourceRoot":"","sources":["../../src/refine/package-metadata.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,sFAAsF;AACtF,MAAM,WAAW,eAAe;IAC9B,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,mFAAmF;IACnF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAID,qDAAqD;AACrD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG/C;AAED;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,QAAQ,SAAoB,GAC3B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAa7B;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAsClF"}
|