@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
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @packageDocumentation
|
|
15
15
|
*/
|
|
16
|
-
export type { ExtractedSkill, ExtractedSkillAudit, ExtractedFunction, ExtractedFunctionMcpMetadata, ExtractedClass, ExtractedType, ExtractedEnum, ExtractedParameter, ExtractedProperty, ExtractedVariable, ExtractedDocument, ExtractedResource, ExtractedPrompt, ExtractedPromptArgument, SkillSetup, AdapterFingerprint, InvocationAdapter, AdapterRenderContext, AdapterRenderContextBase, AdapterRenderContextBundle, AdapterRenderContextHttp, AdapterRenderContextStdio, RefCategory, RefManifest, RefManifestEntry, RenderedFile, RenderedSkill, SkillRenderOptions, SkillWriteOptions, SkillWriteResult, SkillWritePreserveReason, McpAuditSeverity, McpAuditIssue } from './types.js';
|
|
16
|
+
export type { DepSkillRef, ExtractedSkill, ExtractedSkillAudit, ExtractedFunction, ExtractedFunctionMcpMetadata, ExtractedClass, ExtractedType, ExtractedEnum, ExtractedParameter, ExtractedProperty, ExtractedVariable, ExtractedDocument, ExtractedResource, ExtractedPrompt, ExtractedPromptArgument, SkillSetup, AdapterFingerprint, InvocationAdapter, AdapterRenderContext, AdapterRenderContextBase, AdapterRenderContextBundle, AdapterRenderContextHttp, AdapterRenderContextStdio, RefCategory, RefManifest, RefManifestEntry, RenderedFile, RenderedSkill, SkillRenderOptions, SkillWriteOptions, SkillWriteResult, SkillWritePreserveReason, McpAuditSeverity, McpAuditIssue } from './types.js';
|
|
17
17
|
export { renderSkills, renderSkill } from './renderer.js';
|
|
18
18
|
export { canonicalize } from './canonical.js';
|
|
19
19
|
export type { CanonicalizeOptions } from './canonical.js';
|
|
@@ -23,7 +23,7 @@ export { renderResourcesReference, renderPromptsReference } from './references-m
|
|
|
23
23
|
export type { McpReferenceOptions } from './references-mcp.js';
|
|
24
24
|
export { renderLlmsTxt } from './llms-txt.js';
|
|
25
25
|
export type { LlmsTxtOptions, LlmsTxtResult } from './llms-txt.js';
|
|
26
|
-
export type { AuditSeverity, AuditIssue, AuditPass,
|
|
26
|
+
export type { AuditSeverity, AuditIssue, AuditPass, ParsedReadme, AuditResult } from './audit-types.js';
|
|
27
27
|
export { parseReadme } from './readme-parser.js';
|
|
28
28
|
export { auditSkill } from './audit.js';
|
|
29
29
|
export { formatAuditText, formatAuditJson, formatScoreEstimate } from './audit-formatter.js';
|
|
@@ -31,6 +31,7 @@ export { estimateSkillJudgeScore } from './audit-score.js';
|
|
|
31
31
|
export type { SkillJudgeEstimate, ActionableImprovement } from './audit-score.js';
|
|
32
32
|
export type { ConfigSourceType, ExtractedConfigSurface, ExtractedConfigOption, ExtractedConfigArgument } from './config-types.js';
|
|
33
33
|
export { renderConfigSurfaceSection, renderConfigReference } from './config-renderer.js';
|
|
34
|
+
export { extractConfigSurface } from './config-extract.js';
|
|
34
35
|
export type { ParsedSection, ParsedMarkdownDoc, DocsExtractionOptions } from './markdown-types.js';
|
|
35
36
|
export { parseMarkdownDoc } from './markdown-parser.js';
|
|
36
37
|
export { scanDocs, docsToExtractedDocuments, scanRootDocs } from './docs-scanner.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,4BAA4B,EAC5B,cAAc,EACd,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,uBAAuB,EACvB,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,yBAAyB,EACzB,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACxB,gBAAgB,EAChB,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AACvF,YAAY,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CA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,CAAC;AAEnE,YAAY,EACV,aAAa,EACb,UAAU,EACV,SAAS,EACT,YAAY,EACZ,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE7F,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,YAAY,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAElF,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEnG,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAErF,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC1E,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -24,6 +24,7 @@ export { auditSkill } from './audit.js';
|
|
|
24
24
|
export { formatAuditText, formatAuditJson, formatScoreEstimate } from './audit-formatter.js';
|
|
25
25
|
export { estimateSkillJudgeScore } from './audit-score.js';
|
|
26
26
|
export { renderConfigSurfaceSection, renderConfigReference } from './config-renderer.js';
|
|
27
|
+
export { extractConfigSurface } from './config-extract.js';
|
|
27
28
|
export { parseMarkdownDoc } from './markdown-parser.js';
|
|
28
29
|
export { scanDocs, docsToExtractedDocuments, scanRootDocs } from './docs-scanner.js';
|
|
29
30
|
export { scanExamples, linkExamplesToSkill } from './examples-scanner.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAuCH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAEvF,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAW9C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE7F,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAU3D,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAI3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,wBAAwB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAErF,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG1E,cAAc,mBAAmB,CAAC"}
|
|
@@ -8,8 +8,49 @@ import type { RefineTag } from './types.js';
|
|
|
8
8
|
* - If a JSDoc block exists without the tag, the tag is appended before the
|
|
9
9
|
* closing `*\/`.
|
|
10
10
|
* - If the declaration is not found, the source is returned unchanged.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* Parses `source` with ast-grep (core carries no `typescript` dependency) and
|
|
14
|
+
* edits the text in place, so formatting outside the touched JSDoc block is
|
|
15
|
+
* preserved. Tag matching is by name, so re-running with the same tag is a
|
|
16
|
+
* no-op rather than a duplicate.
|
|
11
17
|
*/
|
|
12
18
|
export declare function upsertJsDocTag(source: string, declName: string, tag: RefineTag, content: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Insert or update a JSDoc tag on a property of a config type.
|
|
21
|
+
*
|
|
22
|
+
* `propertyPath` is a dot path into the interface or object-type alias named
|
|
23
|
+
* `typeName` (e.g. `outDir` or `components.prefix`). Otherwise behaves like
|
|
24
|
+
* {@link upsertJsDocTag}. Returns the source unchanged when the type or
|
|
25
|
+
* property is not found. Used by the config refine source to write routing
|
|
26
|
+
* tags back onto a config type's property declarations.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* Resolves `propertyPath` against the body of `typeName` via ast-grep, recursing
|
|
30
|
+
* into nested object-type members for dotted paths. Like {@link upsertJsDocTag},
|
|
31
|
+
* the edit is text-level and idempotent per tag name.
|
|
32
|
+
*/
|
|
33
|
+
export declare function upsertPropertyJsDocTag(source: string, typeName: string, propertyPath: string, tag: RefineTag, content: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Remove the refine-managed tag spans (`@useWhen`, `@avoidWhen`, `@pitfalls`,
|
|
36
|
+
* `@remarks`, `@example` — see {@link REFINE_TAGS}) from every JSDoc block in
|
|
37
|
+
* `source`, leaving each block's prose description and any non-refine tags
|
|
38
|
+
* intact.
|
|
39
|
+
*
|
|
40
|
+
* Used to feed an annotated config module back to the model as grounding
|
|
41
|
+
* without echoing the routing tags this package itself wrote across earlier
|
|
42
|
+
* refine iterations — those are documentation, not the implementation the model
|
|
43
|
+
* should ground runtime claims in. Unlike a blanket JSDoc strip, this preserves
|
|
44
|
+
* genuine hand-authored docs (e.g. validation notes on a `defineConfig` helper),
|
|
45
|
+
* which are exactly the runtime-behavior grounding we want to keep.
|
|
46
|
+
*
|
|
47
|
+
* Handles single-line (`/** @tag x */`) as well as multi-line blocks: each block
|
|
48
|
+
* is reduced to its inner content (opener/closer and ` * ` gutter dropped) before
|
|
49
|
+
* tags are matched, so an inline opener can't hide a tag. The block-matching
|
|
50
|
+
* regex is non-greedy, and writeback escapes a literal close sequence in content
|
|
51
|
+
* to `*\/`, so an escaped sequence inside a kept line never terminates early.
|
|
52
|
+
*/
|
|
53
|
+
export declare function stripRefineTags(source: string): string;
|
|
13
54
|
/**
|
|
14
55
|
* Parse the leading JSDoc block of a named export declaration and return a
|
|
15
56
|
* map of the RefineTag values found in it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-edit.d.ts","sourceRoot":"","sources":["../../src/refine/ast-edit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ast-edit.d.ts","sourceRoot":"","sources":["../../src/refine/ast-edit.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAwF5C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,MAAM,GACd,MAAM,CAKR;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,SAAS,EACd,OAAO,EAAE,MAAM,GACd,MAAM,CAOR;AAgFD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAOtD;AA0CD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAyCpC"}
|
package/dist/refine/ast-edit.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// packages/core/src/refine/ast-edit.ts
|
|
2
2
|
import { parse, Lang } from '@ast-grep/napi';
|
|
3
|
+
import { escapeJsDocClose, findPropertyByPath, findTypeBody, unescapeJsDocClose } from '../config-extract.js';
|
|
3
4
|
// `satisfies` ensures every listed value is a valid RefineTag. The
|
|
4
5
|
// `MissingTags` assertion below makes the inverse hold too: if a value is added
|
|
5
6
|
// to the RefineTag union but not to this list, compilation fails — so the
|
|
@@ -90,34 +91,179 @@ function leadingJsDoc(anchorNode) {
|
|
|
90
91
|
* - If a JSDoc block exists without the tag, the tag is appended before the
|
|
91
92
|
* closing `*\/`.
|
|
92
93
|
* - If the declaration is not found, the source is returned unchanged.
|
|
94
|
+
*
|
|
95
|
+
* @remarks
|
|
96
|
+
* Parses `source` with ast-grep (core carries no `typescript` dependency) and
|
|
97
|
+
* edits the text in place, so formatting outside the touched JSDoc block is
|
|
98
|
+
* preserved. Tag matching is by name, so re-running with the same tag is a
|
|
99
|
+
* no-op rather than a duplicate.
|
|
93
100
|
*/
|
|
94
101
|
export function upsertJsDocTag(source, declName, tag, content) {
|
|
95
102
|
const root = parse(Lang.TypeScript, source).root();
|
|
96
103
|
const anchorNode = findDeclaration(root, declName);
|
|
97
104
|
if (!anchorNode)
|
|
98
105
|
return source;
|
|
99
|
-
|
|
106
|
+
return upsertTagOnAnchor(source, root, anchorNode, tag, content);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Insert or update a JSDoc tag on a property of a config type.
|
|
110
|
+
*
|
|
111
|
+
* `propertyPath` is a dot path into the interface or object-type alias named
|
|
112
|
+
* `typeName` (e.g. `outDir` or `components.prefix`). Otherwise behaves like
|
|
113
|
+
* {@link upsertJsDocTag}. Returns the source unchanged when the type or
|
|
114
|
+
* property is not found. Used by the config refine source to write routing
|
|
115
|
+
* tags back onto a config type's property declarations.
|
|
116
|
+
*
|
|
117
|
+
* @remarks
|
|
118
|
+
* Resolves `propertyPath` against the body of `typeName` via ast-grep, recursing
|
|
119
|
+
* into nested object-type members for dotted paths. Like {@link upsertJsDocTag},
|
|
120
|
+
* the edit is text-level and idempotent per tag name.
|
|
121
|
+
*/
|
|
122
|
+
export function upsertPropertyJsDocTag(source, typeName, propertyPath, tag, content) {
|
|
123
|
+
const root = parse(Lang.TypeScript, source).root();
|
|
124
|
+
const body = findTypeBody(root, typeName);
|
|
125
|
+
if (!body)
|
|
126
|
+
return source;
|
|
127
|
+
const property = findPropertyByPath(body, propertyPath);
|
|
128
|
+
if (!property)
|
|
129
|
+
return source;
|
|
130
|
+
return upsertTagOnAnchor(source, root, property, tag, content);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Insert or update `@tag content` on the JSDoc block leading `anchorNode`,
|
|
134
|
+
* creating the block when absent. Idempotent per tag (matches the tag NAME, so
|
|
135
|
+
* multi-line content never produces duplicates) and rebuilds the block as
|
|
136
|
+
* well-formed multi-line (handling single-line `/** text *\/` inputs). Shared by
|
|
137
|
+
* the declaration-level ({@link upsertJsDocTag}) and property-level
|
|
138
|
+
* ({@link upsertPropertyJsDocTag}) upserts.
|
|
139
|
+
*/
|
|
140
|
+
function upsertTagOnAnchor(source, root, anchorNode, tag, content) {
|
|
141
|
+
// Escape any comment-close sequence in the content so a value containing it
|
|
142
|
+
// (e.g. a glob like `**/*.ts` in a config pitfall) can't terminate the block
|
|
143
|
+
// early and corrupt the file. readJsDocTags / config extraction unescape it.
|
|
144
|
+
const tagText = escapeJsDocClose(`@${tag} ${content}`);
|
|
100
145
|
const jsdocNode = leadingJsDoc(anchorNode);
|
|
146
|
+
// Indent from the comment when one exists: it may sit on the SAME line as the
|
|
147
|
+
// declaration (`/** x */ prop`), where the declaration's own column is the
|
|
148
|
+
// text after the comment, not the line indent — using it over-indented every
|
|
149
|
+
// rebuilt continuation line. With no comment, indent from the declaration the
|
|
150
|
+
// new block is prepended to.
|
|
151
|
+
const indent = ' '.repeat((jsdocNode ?? anchorNode).range().start.column);
|
|
101
152
|
if (jsdocNode) {
|
|
102
153
|
const block = jsdocNode.text();
|
|
103
|
-
if (block.
|
|
154
|
+
if (block.match(new RegExp(`(^|\\n)\\s*\\*?\\s*@${tag}\\b`)))
|
|
104
155
|
return source;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
156
|
+
const innerLines = block
|
|
157
|
+
.replace(/^\/\*\*/, '')
|
|
158
|
+
.replace(/\s*\*\/\s*$/, '')
|
|
159
|
+
.split('\n')
|
|
160
|
+
.map((line) => line.replace(/^\s*\*? ?/, '').trimEnd());
|
|
161
|
+
while (innerLines.length > 0 && innerLines[0] === '')
|
|
162
|
+
innerLines.shift();
|
|
163
|
+
while (innerLines.length > 0 && innerLines[innerLines.length - 1] === '')
|
|
164
|
+
innerLines.pop();
|
|
165
|
+
// Prefix every physical line (including multi-line tag content) with ` * `.
|
|
166
|
+
const allLines = [...innerLines, ...tagText.split('\n')];
|
|
167
|
+
const body = allLines
|
|
168
|
+
.map((line) => (line.length > 0 ? `${indent} * ${line}` : `${indent} *`))
|
|
169
|
+
.join('\n');
|
|
170
|
+
const merged = `/**\n${body}\n${indent} */`;
|
|
171
|
+
// Own-line comment: a clean node replace suffices.
|
|
172
|
+
if (jsdocNode.range().end.line !== anchorNode.range().start.line) {
|
|
173
|
+
return root.commitEdits([jsdocNode.replace(merged)]);
|
|
174
|
+
}
|
|
175
|
+
// Same-line `/** x */ prop`: a node replace swaps only the comment text and
|
|
176
|
+
// leaves the declaration packed onto the closing `*/` line. Splice manually
|
|
177
|
+
// — drop the inline gap and start the declaration on its own indented line.
|
|
178
|
+
const start = jsdocNode.range().start.index;
|
|
179
|
+
const end = jsdocNode.range().end.index;
|
|
180
|
+
const tail = source.slice(end).replace(/^[^\S\n]+/, '');
|
|
181
|
+
return `${source.slice(0, start)}${merged}\n${indent}${tail}`;
|
|
113
182
|
}
|
|
114
|
-
// No existing JSDoc — create one before the anchor node.
|
|
115
|
-
|
|
116
|
-
|
|
183
|
+
// No existing JSDoc — create one before the anchor node. Prefix EVERY physical
|
|
184
|
+
// line of the tag (multi-line content too) with ` * `, mirroring the merge
|
|
185
|
+
// branch above. Without this, a multi-line first tag left continuation lines
|
|
186
|
+
// at column 0 — malformed JSDoc that also broke the re-parse for any tag
|
|
187
|
+
// appended to the same declaration in a later pass.
|
|
117
188
|
const at = anchorNode.range().start.index;
|
|
118
|
-
const
|
|
189
|
+
const body = tagText
|
|
190
|
+
.split('\n')
|
|
191
|
+
.map((line) => (line.length > 0 ? `${indent} * ${line}` : `${indent} *`))
|
|
192
|
+
.join('\n');
|
|
193
|
+
const blockText = `/**\n${body}\n${indent} */\n${indent}`;
|
|
119
194
|
return source.slice(0, at) + blockText + source.slice(at);
|
|
120
195
|
}
|
|
196
|
+
// Fast membership set for tag-name lookups (typed as strings so an arbitrary
|
|
197
|
+
// captured `@word` can be tested without a cast). Derived from REFINE_TAGS so
|
|
198
|
+
// it stays in sync with the union automatically.
|
|
199
|
+
const REFINE_TAG_SET = new Set(REFINE_TAGS);
|
|
200
|
+
/**
|
|
201
|
+
* Remove the refine-managed tag spans (`@useWhen`, `@avoidWhen`, `@pitfalls`,
|
|
202
|
+
* `@remarks`, `@example` — see {@link REFINE_TAGS}) from every JSDoc block in
|
|
203
|
+
* `source`, leaving each block's prose description and any non-refine tags
|
|
204
|
+
* intact.
|
|
205
|
+
*
|
|
206
|
+
* Used to feed an annotated config module back to the model as grounding
|
|
207
|
+
* without echoing the routing tags this package itself wrote across earlier
|
|
208
|
+
* refine iterations — those are documentation, not the implementation the model
|
|
209
|
+
* should ground runtime claims in. Unlike a blanket JSDoc strip, this preserves
|
|
210
|
+
* genuine hand-authored docs (e.g. validation notes on a `defineConfig` helper),
|
|
211
|
+
* which are exactly the runtime-behavior grounding we want to keep.
|
|
212
|
+
*
|
|
213
|
+
* Handles single-line (`/** @tag x */`) as well as multi-line blocks: each block
|
|
214
|
+
* is reduced to its inner content (opener/closer and ` * ` gutter dropped) before
|
|
215
|
+
* tags are matched, so an inline opener can't hide a tag. The block-matching
|
|
216
|
+
* regex is non-greedy, and writeback escapes a literal close sequence in content
|
|
217
|
+
* to `*\/`, so an escaped sequence inside a kept line never terminates early.
|
|
218
|
+
*/
|
|
219
|
+
export function stripRefineTags(source) {
|
|
220
|
+
return source.replace(/\/\*\*[\s\S]*?\*\//g, (block, offset) => {
|
|
221
|
+
// Indent of the line the block opens on, for a clean re-wrap when we rebuild.
|
|
222
|
+
const lineStart = source.lastIndexOf('\n', offset) + 1;
|
|
223
|
+
const indent = source.slice(lineStart, offset).match(/^\s*/)?.[0] ?? '';
|
|
224
|
+
return stripRefineTagsFromBlock(block, indent);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Strip refine-tag spans from one JSDoc block. Returns the block unchanged when
|
|
229
|
+
* it holds no refine tag (preserving hand-authored formatting), the empty string
|
|
230
|
+
* when nothing but refine tags remain (the whole block is dropped), or a clean
|
|
231
|
+
* re-wrapped block at `indent` otherwise. A `@tag` line and the lines following
|
|
232
|
+
* it (its continuation) form one span; a non-refine `@tag` closes any open span.
|
|
233
|
+
*/
|
|
234
|
+
function stripRefineTagsFromBlock(block, indent) {
|
|
235
|
+
// Reduce to inner content so tag detection is independent of how the block is
|
|
236
|
+
// wrapped: drop the `/**` opener and `*/` closer (own-line OR inline, as in a
|
|
237
|
+
// single-line `/** @tag x */`), then the per-line ` * ` gutter.
|
|
238
|
+
const inner = block.replace(/^\s*\/\*\*/, '').replace(/\*\/\s*$/, '');
|
|
239
|
+
const lines = inner.split('\n').map((line) => line.replace(/^\s*\*? ?/, '').trimEnd());
|
|
240
|
+
const kept = [];
|
|
241
|
+
let dropping = false;
|
|
242
|
+
let droppedAny = false;
|
|
243
|
+
for (const line of lines) {
|
|
244
|
+
const tagMatch = line.match(/^@(\w+)\b/);
|
|
245
|
+
if (tagMatch) {
|
|
246
|
+
dropping = REFINE_TAG_SET.has(tagMatch[1] ?? '');
|
|
247
|
+
}
|
|
248
|
+
if (dropping) {
|
|
249
|
+
droppedAny = true;
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
kept.push(line);
|
|
253
|
+
}
|
|
254
|
+
if (!droppedAny)
|
|
255
|
+
return block; // no refine tag — keep original formatting verbatim
|
|
256
|
+
while (kept.length > 0 && kept[0] === '')
|
|
257
|
+
kept.shift();
|
|
258
|
+
while (kept.length > 0 && kept[kept.length - 1] === '')
|
|
259
|
+
kept.pop();
|
|
260
|
+
if (kept.length === 0)
|
|
261
|
+
return ''; // block was nothing but refine tags
|
|
262
|
+
const body = kept
|
|
263
|
+
.map((line) => (line.length > 0 ? `${indent} * ${line}` : `${indent} *`))
|
|
264
|
+
.join('\n');
|
|
265
|
+
return `/**\n${body}\n${indent} */`;
|
|
266
|
+
}
|
|
121
267
|
/**
|
|
122
268
|
* Parse the leading JSDoc block of a named export declaration and return a
|
|
123
269
|
* map of the RefineTag values found in it.
|
|
@@ -134,13 +280,35 @@ export function readJsDocTags(source, declName) {
|
|
|
134
280
|
if (!jsdocNode)
|
|
135
281
|
return {};
|
|
136
282
|
const block = jsdocNode.text();
|
|
283
|
+
// Strip the block to inner content lines (no `/** */` wrapper, no ` * `
|
|
284
|
+
// prefixes), then walk them: a known `@tag` line opens a capture and the
|
|
285
|
+
// following non-tag lines are its continuation. This keeps multi-line tag
|
|
286
|
+
// content (e.g. bullet lists) intact instead of truncating at the first
|
|
287
|
+
// newline — otherwise a refined `@pitfalls` with several bullets would lose
|
|
288
|
+
// everything past line one when re-extracted into SKILL.md.
|
|
289
|
+
const innerLines = block
|
|
290
|
+
.replace(/^\/\*\*/, '')
|
|
291
|
+
.replace(/\s*\*\/\s*$/, '')
|
|
292
|
+
.split('\n')
|
|
293
|
+
.map((line) => line.replace(/^\s*\*? ?/, '').trimEnd());
|
|
294
|
+
const collected = {};
|
|
295
|
+
let current;
|
|
296
|
+
for (const line of innerLines) {
|
|
297
|
+
const tagMatch = line.match(/^@(\w+)\s?(.*)$/);
|
|
298
|
+
const matchedTag = tagMatch ? REFINE_TAGS.find((t) => t === tagMatch[1]) : undefined;
|
|
299
|
+
if (matchedTag) {
|
|
300
|
+
current = matchedTag;
|
|
301
|
+
collected[current] = [tagMatch[2] ?? ''];
|
|
302
|
+
}
|
|
303
|
+
else if (current) {
|
|
304
|
+
collected[current].push(line);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
137
307
|
const result = {};
|
|
138
308
|
for (const tag of REFINE_TAGS) {
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
result[tag] = hit[1]?.trim() ?? '';
|
|
143
|
-
}
|
|
309
|
+
const lines = collected[tag];
|
|
310
|
+
if (lines)
|
|
311
|
+
result[tag] = unescapeJsDocClose(lines.join('\n').trim());
|
|
144
312
|
}
|
|
145
313
|
return result;
|
|
146
314
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast-edit.js","sourceRoot":"","sources":["../../src/refine/ast-edit.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ast-edit.js","sourceRoot":"","sources":["../../src/refine/ast-edit.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,gBA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,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ExtractedSkill } from '../types.js';
|
|
2
|
+
import type { DraftedFix, RefineSource, TargetLocation } from './types.js';
|
|
3
|
+
export interface ConfigRefineSourceOptions {
|
|
4
|
+
/** Path to the TypeScript file declaring the config type. */
|
|
5
|
+
configFile: string;
|
|
6
|
+
/** Name of the exported interface or object-type alias to document. */
|
|
7
|
+
typeName: string;
|
|
8
|
+
/** Skill name (defaults to the package name, then `typeName`). */
|
|
9
|
+
name?: string;
|
|
10
|
+
/** Skill description (defaults to the package.json description). */
|
|
11
|
+
description?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Globs pointing at the code that CONSUMES this config (e.g. the CLI/filter
|
|
14
|
+
* logic). Their contents are fed to the draft model as an implementation
|
|
15
|
+
* reference so it can state CORRECT runtime behavior instead of guessing it
|
|
16
|
+
* from the type alone. Token-capped. Without grounding the model is told not
|
|
17
|
+
* to assert unverifiable runtime semantics.
|
|
18
|
+
*/
|
|
19
|
+
groundingGlobs?: string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* {@link RefineSource} for a TypeScript configuration surface.
|
|
23
|
+
*
|
|
24
|
+
* Reads the consumer's config type with {@link extractConfigSurface}, exposes it
|
|
25
|
+
* as a single `config` surface in an {@link ExtractedSkill}, and writes routing
|
|
26
|
+
* tags back as JSDoc onto the type's individual property declarations. Unlike
|
|
27
|
+
* the CLI source — whose routing lives at the command (surface) level — a config
|
|
28
|
+
* surface is documented per-OPTION: each fix targets one property by its
|
|
29
|
+
* dot-path `configKey` (e.g. `outDir`, `components.prefix`), routed through
|
|
30
|
+
* {@link upsertPropertyJsDocTag}.
|
|
31
|
+
*
|
|
32
|
+
* It also enriches the skill from the package.json nearest the config file (its
|
|
33
|
+
* description, keywords, repository) and a sibling README, supplying the audit
|
|
34
|
+
* context the metadata checks (F1/F2/F3/E5/W4/W5/W6) score against — without it
|
|
35
|
+
* a config skill forfeits those points even when the package already carries
|
|
36
|
+
* the data.
|
|
37
|
+
*/
|
|
38
|
+
export declare class ConfigRefineSource implements RefineSource {
|
|
39
|
+
private readonly opts;
|
|
40
|
+
/** Cached metadata, populated by {@link extract} (which the loop runs first). */
|
|
41
|
+
private metadata;
|
|
42
|
+
/** Cached surface, populated by {@link extract}; read by {@link guidance}. */
|
|
43
|
+
private surface;
|
|
44
|
+
/** Cached implementation-reference grounding, populated by {@link extract}. */
|
|
45
|
+
private grounding;
|
|
46
|
+
constructor(opts: ConfigRefineSourceOptions);
|
|
47
|
+
extract(): Promise<ExtractedSkill>;
|
|
48
|
+
/**
|
|
49
|
+
* Map an improvement target to its on-disk location. Config targets carry the
|
|
50
|
+
* option's dot-path `configKey` as `name` (kind `config-option`); the config
|
|
51
|
+
* type holds them, so the file is always the config file and the declName is
|
|
52
|
+
* the type. A `config-example` target points at the same file with no path.
|
|
53
|
+
*/
|
|
54
|
+
resolveTargetLocation(target: {
|
|
55
|
+
name: string;
|
|
56
|
+
kind: string;
|
|
57
|
+
file?: string;
|
|
58
|
+
}): TargetLocation | undefined;
|
|
59
|
+
applyFixes(fixes: readonly DraftedFix[]): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Drafting conventions passed to the model each iteration. Scopes every
|
|
62
|
+
* routing tag to the single named option, constrains claims to what the type
|
|
63
|
+
* and provided context can support (the model sees the type, NOT the code that
|
|
64
|
+
* consumes the config, so unconstrained drafting invents wrong runtime
|
|
65
|
+
* semantics), and tells it how to draft the `@example` config file. Built from
|
|
66
|
+
* the cached surface that {@link extract} populates first.
|
|
67
|
+
*/
|
|
68
|
+
guidance(): string;
|
|
69
|
+
private loadMetadata;
|
|
70
|
+
/**
|
|
71
|
+
* Sibling example path for the config file: same directory, the config file's
|
|
72
|
+
* base name with any `.ts`/`.tsx`/`.mts`/`.cts` extension replaced by
|
|
73
|
+
* `.example.ts` (e.g. `z2f.config.ts` → `z2f.config.example.ts`,
|
|
74
|
+
* `config.ts` → `config.example.ts`).
|
|
75
|
+
*/
|
|
76
|
+
private exampleFilePath;
|
|
77
|
+
private loadGrounding;
|
|
78
|
+
/** Nearest ancestor directory of the config file that holds a package.json. */
|
|
79
|
+
private findPackageDir;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=config-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-source.d.ts","sourceRoot":"","sources":["../../src/refine/config-source.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE3E,MAAM,WAAW,yBAAyB;IACxC,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,QAAQ,EAAE,MAAM,CAAC;IACjB,kEAAkE;IAClE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;CAC3B;AAkBD;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,kBAAmB,YAAW,YAAY;IAQzC,OAAO,CAAC,QAAQ,CAAC,IAAI;IAPjC,iFAAiF;IACjF,OAAO,CAAC,QAAQ,CAAsB;IACtC,8EAA8E;IAC9E,OAAO,CAAC,OAAO,CAAqC;IACpD,+EAA+E;IAC/E,OAAO,CAAC,SAAS,CAAM;IAEvB,YAA6B,IAAI,EAAE,yBAAyB,EAAI;IAE1D,OAAO,IAAI,OAAO,CAAC,cAAc,CAAC,CAgDvC;IAED;;;;;OAKG;IACH,qBAAqB,CAAC,MAAM,EAAE;QAC5B,IA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