@webpieces/ai-hook-rules 0.4.942 → 0.4.943
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/ai-hook-rules",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.943",
|
|
4
4
|
"description": "Independent source edit rules and source hook for AI coding agents.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -23,18 +23,18 @@
|
|
|
23
23
|
"directory": "packages/tooling/ai-hook-rules"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@webpieces/hook-runtime": "0.4.
|
|
27
|
-
"@webpieces/rules-config": "0.4.
|
|
26
|
+
"@webpieces/hook-runtime": "0.4.943",
|
|
27
|
+
"@webpieces/rules-config": "0.4.943",
|
|
28
28
|
"inversify": "7.10.4",
|
|
29
29
|
"reflect-metadata": "0.2.2",
|
|
30
|
-
"@webpieces/tooling-common": "0.4.
|
|
31
|
-
"@webpieces/rules-sdk": "0.4.
|
|
30
|
+
"@webpieces/tooling-common": "0.4.943",
|
|
31
|
+
"@webpieces/rules-sdk": "0.4.943"
|
|
32
32
|
},
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@webpieces/tooling-testkit": "0.4.
|
|
37
|
+
"@webpieces/tooling-testkit": "0.4.943"
|
|
38
38
|
},
|
|
39
39
|
"types": "./src/index.d.ts",
|
|
40
40
|
"bin": {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SourceSyntax } from '@webpieces/tooling-common/source-syntax';
|
|
2
|
+
import { FileContext, ProposedContent } from '@webpieces/hook-runtime';
|
|
3
|
+
/** The proposed file's parse, plus the original's on demand (for rules that grandfather unchanged code). */
|
|
4
|
+
export declare class FileSyntax {
|
|
5
|
+
private readonly fileName;
|
|
6
|
+
readonly content: ProposedContent;
|
|
7
|
+
readonly proposed: SourceSyntax;
|
|
8
|
+
private originalSource;
|
|
9
|
+
constructor(fileName: string, content: ProposedContent);
|
|
10
|
+
original(): SourceSyntax;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The shared AST entry point for Write/Edit-time syntax rules. Every rule judging one invocation's file
|
|
14
|
+
* gets the SAME parse: weak keys expire with the invocation's projected file, so nothing outlives it.
|
|
15
|
+
*/
|
|
16
|
+
export declare class SourceAnalysis {
|
|
17
|
+
private readonly cache;
|
|
18
|
+
forFile(ctx: FileContext): FileSyntax;
|
|
19
|
+
}
|
|
20
|
+
export declare const sourceAnalysis: SourceAnalysis;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sourceAnalysis = exports.SourceAnalysis = exports.FileSyntax = void 0;
|
|
4
|
+
const source_syntax_1 = require("@webpieces/tooling-common/source-syntax");
|
|
5
|
+
const tooling_common_1 = require("@webpieces/tooling-common");
|
|
6
|
+
/** The proposed file's parse, plus the original's on demand (for rules that grandfather unchanged code). */
|
|
7
|
+
class FileSyntax {
|
|
8
|
+
fileName;
|
|
9
|
+
content;
|
|
10
|
+
proposed;
|
|
11
|
+
originalSource = null;
|
|
12
|
+
constructor(fileName, content) {
|
|
13
|
+
this.fileName = fileName;
|
|
14
|
+
this.content = content;
|
|
15
|
+
this.proposed = new source_syntax_1.SourceSyntax(fileName, content.text);
|
|
16
|
+
}
|
|
17
|
+
original() {
|
|
18
|
+
if (!this.originalSource)
|
|
19
|
+
this.originalSource = new source_syntax_1.SourceSyntax(this.fileName, this.content.original);
|
|
20
|
+
return this.originalSource;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.FileSyntax = FileSyntax;
|
|
24
|
+
/**
|
|
25
|
+
* The shared AST entry point for Write/Edit-time syntax rules. Every rule judging one invocation's file
|
|
26
|
+
* gets the SAME parse: weak keys expire with the invocation's projected file, so nothing outlives it.
|
|
27
|
+
*/
|
|
28
|
+
class SourceAnalysis {
|
|
29
|
+
cache = new WeakMap();
|
|
30
|
+
forFile(ctx) {
|
|
31
|
+
if (!ctx.proposedFile)
|
|
32
|
+
throw new tooling_common_1.InformAiError('Source syntax rules require the proposed file for a write/edit.');
|
|
33
|
+
const cached = this.cache.get(ctx.proposedFile);
|
|
34
|
+
if (cached)
|
|
35
|
+
return cached;
|
|
36
|
+
const syntax = new FileSyntax(ctx.filePath, ctx.proposedFile.read());
|
|
37
|
+
this.cache.set(ctx.proposedFile, syntax);
|
|
38
|
+
return syntax;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.SourceAnalysis = SourceAnalysis;
|
|
42
|
+
exports.sourceAnalysis = new SourceAnalysis();
|
|
43
|
+
//# sourceMappingURL=source-analysis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-analysis.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/source-analysis.ts"],"names":[],"mappings":";;;AAAA,2EAAuE;AAEvE,8DAA0D;AAE1D,4GAA4G;AAC5G,MAAa,UAAU;IAIU;IAA2B;IAH/C,QAAQ,CAAe;IACxB,cAAc,GAAwB,IAAI,CAAC;IAEnD,YAA6B,QAAgB,EAAW,OAAwB;QAAnD,aAAQ,GAAR,QAAQ,CAAQ;QAAW,YAAO,GAAP,OAAO,CAAiB;QAC5E,IAAI,CAAC,QAAQ,GAAG,IAAI,4BAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,CAAC;IAED,QAAQ;QACJ,IAAI,CAAC,IAAI,CAAC,cAAc;YAAE,IAAI,CAAC,cAAc,GAAG,IAAI,4BAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvG,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;CACJ;AAZD,gCAYC;AAED;;;GAGG;AACH,MAAa,cAAc;IACN,KAAK,GAAG,IAAI,OAAO,EAA4B,CAAC;IAEjE,OAAO,CAAC,GAAgB;QACpB,IAAI,CAAC,GAAG,CAAC,YAAY;YAAE,MAAM,IAAI,8BAAa,CAAC,iEAAiE,CAAC,CAAC;QAClH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAChD,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;QAC1B,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;QACrE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QACzC,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAXD,wCAWC;AAEY,QAAA,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC","sourcesContent":["import { SourceSyntax } from '@webpieces/tooling-common/source-syntax';\nimport { FileContext, ProposedContent, ProposedFile } from '@webpieces/hook-runtime';\nimport { InformAiError } from '@webpieces/tooling-common';\n\n/** The proposed file's parse, plus the original's on demand (for rules that grandfather unchanged code). */\nexport class FileSyntax {\n readonly proposed: SourceSyntax;\n private originalSource: SourceSyntax | null = null;\n\n constructor(private readonly fileName: string, readonly content: ProposedContent) {\n this.proposed = new SourceSyntax(fileName, content.text);\n }\n\n original(): SourceSyntax {\n if (!this.originalSource) this.originalSource = new SourceSyntax(this.fileName, this.content.original);\n return this.originalSource;\n }\n}\n\n/**\n * The shared AST entry point for Write/Edit-time syntax rules. Every rule judging one invocation's file\n * gets the SAME parse: weak keys expire with the invocation's projected file, so nothing outlives it.\n */\nexport class SourceAnalysis {\n private readonly cache = new WeakMap<ProposedFile, FileSyntax>();\n\n forFile(ctx: FileContext): FileSyntax {\n if (!ctx.proposedFile) throw new InformAiError('Source syntax rules require the proposed file for a write/edit.');\n const cached = this.cache.get(ctx.proposedFile);\n if (cached) return cached;\n const syntax = new FileSyntax(ctx.filePath, ctx.proposedFile.read());\n this.cache.set(ctx.proposedFile, syntax);\n return syntax;\n }\n}\n\nexport const sourceAnalysis = new SourceAnalysis();\n"]}
|