@webpieces/webpieces-tooling 0.0.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.
- package/README.md +13 -0
- package/openclaw.plugin.json +15 -0
- package/package.json +44 -0
- package/src/adapters/openclaw-plugin.d.ts +14 -0
- package/src/adapters/openclaw-plugin.js +99 -0
- package/src/adapters/openclaw-plugin.js.map +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -0
- package/src/index.js.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @webpieces/webpieces-tooling
|
|
2
|
+
|
|
3
|
+
Install the complete toolchain through this umbrella package. Its workspace dependencies carry every published tooling package and its public bins, including `wp-ai-rules-hook` and `wp-ai-guards-hook`.
|
|
4
|
+
|
|
5
|
+
For a published release, declare `@webpieces/webpieces-tooling` as the single tooling dependency. Existing consumers should replace their former Nx umbrella declaration with this package when adopting the release. Keep registering `@webpieces/nx-webpieces-rules` in `nx.json`; that package implements the inference plugin and executors.
|
|
6
|
+
|
|
7
|
+
OpenClaw uses `@webpieces/webpieces-tooling/openclaw-plugin` and the packaged `openclaw.plugin.json`. Its single write/edit handler composes source rules, workflow guards, and source extensions in their original order.
|
|
8
|
+
|
|
9
|
+
This package owns packaging and composition smoke checks. Feature suites remain in ai-hook-rules, agent-workflow-rules, pr-gate, and the Nx implementation package.
|
|
10
|
+
|
|
11
|
+
The repository itself is validated with its previously published catalog release. Adding this source package does not upgrade that installed toolchain or its committed dispatcher.
|
|
12
|
+
|
|
13
|
+
The ordinary test target runs the small aggregation and OpenClaw checks. Run `pnpm nx run webpieces-tooling:release-test` when changing `scripts/publish-packages.sh`; it exercises the release retry loop in a fake registry workspace and is kept separate from source-rule edit workloads.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "webpieces-ai-hooks",
|
|
3
|
+
"name": "webpieces AI Hooks",
|
|
4
|
+
"description": "Pre-write validation rules for AI-driven development. Blocks writes containing any, missing return types, destructuring, unmanaged exceptions, orphan files, or oversized files.",
|
|
5
|
+
"hooks": {
|
|
6
|
+
"before_tool_call": {
|
|
7
|
+
"handler": "./src/adapters/openclaw-plugin.js"
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"configSchema": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"additionalProperties": false,
|
|
13
|
+
"properties": {}
|
|
14
|
+
}
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webpieces/webpieces-tooling",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Complete webpieces tooling installation and the combined OpenClaw hook adapter.",
|
|
5
|
+
"type": "commonjs",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./src/index.js",
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
"./openclaw-plugin": "./src/adapters/openclaw-plugin.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"src/**/*",
|
|
14
|
+
"openclaw.plugin.json",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@webpieces/agent-workflow-rules": "0.0.1",
|
|
19
|
+
"@webpieces/ai-hook-rules": "0.4.845",
|
|
20
|
+
"@webpieces/code-rules": "0.4.845",
|
|
21
|
+
"@webpieces/eslint-rules": "0.4.845",
|
|
22
|
+
"@webpieces/hook-runtime": "0.0.1",
|
|
23
|
+
"@webpieces/nx-webpieces-rules": "0.4.845",
|
|
24
|
+
"@webpieces/pr-gate": "0.4.845",
|
|
25
|
+
"@webpieces/repo-workflow-core": "0.0.1",
|
|
26
|
+
"@webpieces/rules-config": "0.4.845",
|
|
27
|
+
"@webpieces/tooling-common": "0.0.1",
|
|
28
|
+
"@webpieces/rules-sdk": "0.0.1"
|
|
29
|
+
},
|
|
30
|
+
"author": "Dean Hiller",
|
|
31
|
+
"license": "Apache-2.0",
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/deanhiller/webpieces-ts.git",
|
|
35
|
+
"directory": "packages/tooling/webpieces-tooling"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@webpieces/tooling-testkit": "0.0.1"
|
|
42
|
+
},
|
|
43
|
+
"types": "./src/index.d.ts"
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface ToolCallEvent {
|
|
2
|
+
toolName: string;
|
|
3
|
+
arguments: Record<string, unknown>;
|
|
4
|
+
}
|
|
5
|
+
interface HookContext {
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
declare class OpenclawHandlerResult {
|
|
9
|
+
readonly status: 'approved' | 'rejected';
|
|
10
|
+
readonly reason: string | undefined;
|
|
11
|
+
constructor(status: 'approved' | 'rejected', reason?: string);
|
|
12
|
+
}
|
|
13
|
+
export default function handler(event: ToolCallEvent, _context: HookContext): Promise<OpenclawHandlerResult | undefined>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = handler;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
7
|
+
const rules_config_1 = require("@webpieces/rules-config");
|
|
8
|
+
const ai_hook_rules_1 = require("@webpieces/ai-hook-rules");
|
|
9
|
+
const agent_workflow_rules_1 = require("@webpieces/agent-workflow-rules");
|
|
10
|
+
const hook_runtime_1 = require("@webpieces/hook-runtime");
|
|
11
|
+
const rules_config_2 = require("@webpieces/rules-config");
|
|
12
|
+
const hook_runtime_2 = require("@webpieces/hook-runtime");
|
|
13
|
+
const tooling_common_1 = require("@webpieces/tooling-common");
|
|
14
|
+
const rules_config_3 = require("@webpieces/rules-config");
|
|
15
|
+
const to_error_1 = require("@webpieces/tooling-common/to-error");
|
|
16
|
+
class OpenclawHandlerResult {
|
|
17
|
+
status;
|
|
18
|
+
reason;
|
|
19
|
+
constructor(status, reason) {
|
|
20
|
+
this.status = status;
|
|
21
|
+
this.reason = reason;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const TOOL_MAP = {
|
|
25
|
+
'write': 'Write',
|
|
26
|
+
'edit': 'Edit',
|
|
27
|
+
};
|
|
28
|
+
// webpieces-disable no-function-outside-class -- existing OpenClaw callback and stateless adapter helpers moved intact; the SDK invokes this module function
|
|
29
|
+
function mapToolName(openclawName) {
|
|
30
|
+
return TOOL_MAP[openclawName] || null;
|
|
31
|
+
}
|
|
32
|
+
// webpieces-disable no-any-unknown -- openclaw SDK passes opaque tool arguments
|
|
33
|
+
// webpieces-disable no-function-outside-class -- existing OpenClaw callback and stateless adapter helpers moved intact; the SDK invokes this module function
|
|
34
|
+
function mapToolInput(toolName, args) {
|
|
35
|
+
const filePath = typeof args['path'] === 'string' ? args['path'] : null;
|
|
36
|
+
if (!filePath)
|
|
37
|
+
return null;
|
|
38
|
+
if (toolName === 'write') {
|
|
39
|
+
const content = typeof args['content'] === 'string' ? args['content'] : '';
|
|
40
|
+
return new hook_runtime_2.NormalizedToolInput(filePath, [new hook_runtime_2.NormalizedEdit('', content)]);
|
|
41
|
+
}
|
|
42
|
+
if (toolName === 'edit') {
|
|
43
|
+
const oldStr = typeof args['old_string'] === 'string' ? args['old_string'] : '';
|
|
44
|
+
const newStr = typeof args['new_string'] === 'string' ? args['new_string'] : '';
|
|
45
|
+
return new hook_runtime_2.NormalizedToolInput(filePath, [new hook_runtime_2.NormalizedEdit(oldStr, newStr)]);
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
// webpieces-disable no-function-outside-class -- existing OpenClaw callback and stateless adapter helpers moved intact; the SDK invokes this module function
|
|
50
|
+
function findWorkspaceRoot(filePath) {
|
|
51
|
+
let dir = path.dirname(filePath);
|
|
52
|
+
while (true) {
|
|
53
|
+
if (fs.existsSync(path.join(dir, rules_config_1.CONFIG_FILENAME)))
|
|
54
|
+
return dir;
|
|
55
|
+
const parent = path.dirname(dir);
|
|
56
|
+
if (parent === dir)
|
|
57
|
+
return null;
|
|
58
|
+
dir = parent;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// webpieces-disable no-function-outside-class -- existing OpenClaw callback and stateless adapter helpers moved intact; the SDK invokes this module function
|
|
62
|
+
async function handler(event, _context) {
|
|
63
|
+
// eslint-disable-next-line @webpieces/no-unmanaged-exceptions
|
|
64
|
+
try {
|
|
65
|
+
const toolKind = mapToolName(event.toolName);
|
|
66
|
+
if (!toolKind)
|
|
67
|
+
return undefined;
|
|
68
|
+
const input = mapToolInput(event.toolName, event.arguments);
|
|
69
|
+
if (!input)
|
|
70
|
+
return undefined;
|
|
71
|
+
const wsRoot = findWorkspaceRoot(input.filePath);
|
|
72
|
+
if (!wsRoot)
|
|
73
|
+
return undefined;
|
|
74
|
+
const loaded = (0, rules_config_2.loadAndValidate)(wsRoot);
|
|
75
|
+
const source = new ai_hook_rules_1.SourceHookRules().load(loaded);
|
|
76
|
+
const guards = new agent_workflow_rules_1.WorkflowHookRules().load(loaded);
|
|
77
|
+
const result = new hook_runtime_1.HookFileEvaluation().evaluate(toolKind, input, loaded, new hook_runtime_1.HookRuleSet([...source.builtInRules, ...guards.rules, ...source.extensionRules], [...source.configuredRules, ...guards.configuredRules]));
|
|
78
|
+
if (!result)
|
|
79
|
+
return new OpenclawHandlerResult('approved');
|
|
80
|
+
return new OpenclawHandlerResult('rejected', result.report);
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
const error = (0, to_error_1.toError)(err);
|
|
84
|
+
// An escaped RuleFailError or InformAiError carries an AI-readable message; anything else is
|
|
85
|
+
// an unexpected bug. All reject (fail closed).
|
|
86
|
+
let msg;
|
|
87
|
+
if (error instanceof rules_config_3.RuleFailError) {
|
|
88
|
+
msg = (0, rules_config_1.renderRuleFailForAi)(error);
|
|
89
|
+
}
|
|
90
|
+
else if (error instanceof tooling_common_1.InformAiError) {
|
|
91
|
+
msg = error.message;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
msg = `[ai-hooks] openclaw adapter crashed — failing closed: ${error.message}`;
|
|
95
|
+
}
|
|
96
|
+
return new OpenclawHandlerResult('rejected', msg);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=openclaw-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openclaw-plugin.js","sourceRoot":"","sources":["../../../../../../packages/tooling/webpieces-tooling/src/adapters/openclaw-plugin.ts"],"names":[],"mappings":";;AA0EA,0BAoCC;;AA9GD,mDAA6B;AAC7B,+CAAyB;AAEzB,0DAA+E;AAC/E,4DAA2D;AAC3D,0EAAoE;AACpE,0DAA0E;AAC1E,0DAA0D;AAC1D,0DAAwF;AACxF,8DAA0D;AAC1D,0DAAwD;AACxD,iEAA6D;AAa7D,MAAM,qBAAqB;IACd,MAAM,CAA0B;IAChC,MAAM,CAAqB;IAEpC,YAAY,MAA+B,EAAE,MAAe;QACxD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;CACJ;AAED,MAAM,QAAQ,GAA6B;IACvC,OAAO,EAAE,OAAO;IAChB,MAAM,EAAE,MAAM;CACjB,CAAC;AAEF,6JAA6J;AAC7J,SAAS,WAAW,CAAC,YAAoB;IACrC,OAAO,QAAQ,CAAC,YAAY,CAAC,IAAI,IAAI,CAAC;AAC1C,CAAC;AAED,gFAAgF;AAChF,6JAA6J;AAC7J,SAAS,YAAY,CAAC,QAAgB,EAAE,IAA6B;I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I,qBAAqB,CAAC,UAAU,CAAC,CAAC;QAC1D,OAAO,IAAI,qBAAqB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IAChE,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACpB,MAAM,KAAK,GAAG,IAAA,kBAAO,EAAC,GAAG,CAAC,CAAC;QAC3B,6FAA6F;QAC7F,+CAA+C;QAC/C,IAAI,GAAW,CAAC;QAChB,IAAI,KAAK,YAAY,4BAAa,EAAE,CAAC;YACjC,GAAG,GAAG,IAAA,kCAAmB,EAAC,KAAK,CAAC,CAAC;QACrC,CAAC;aAAM,IAAI,KAAK,YAAY,8BAAa,EAAE,CAAC;YACxC,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC;QACxB,CAAC;aAAM,CAAC;YACJ,GAAG,GAAG,yDAAyD,KAAK,CAAC,OAAO,EAAE,CAAC;QACnF,CAAC;QACD,OAAO,IAAI,qBAAqB,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACtD,CAAC;AACL,CAAC","sourcesContent":["import * as path from 'path';\nimport * as fs from 'fs';\n\nimport { CONFIG_FILENAME, renderRuleFailForAi } from '@webpieces/rules-config';\nimport { SourceHookRules } from '@webpieces/ai-hook-rules';\nimport { WorkflowHookRules } from '@webpieces/agent-workflow-rules';\nimport { HookRuleSet, HookFileEvaluation } from '@webpieces/hook-runtime';\nimport { loadAndValidate } from '@webpieces/rules-config';\nimport { NormalizedToolInput, NormalizedEdit, ToolKind } from '@webpieces/hook-runtime';\nimport { InformAiError } from '@webpieces/tooling-common';\nimport { RuleFailError } from '@webpieces/rules-config';\nimport { toError } from '@webpieces/tooling-common/to-error';\n\ninterface ToolCallEvent {\n toolName: string;\n // webpieces-disable no-any-unknown -- openclaw SDK passes opaque tool arguments\n arguments: Record<string, unknown>;\n}\n\ninterface HookContext {\n // webpieces-disable no-any-unknown -- openclaw SDK context shape is opaque\n [key: string]: unknown;\n}\n\nclass OpenclawHandlerResult {\n readonly status: 'approved' | 'rejected';\n readonly reason: string | undefined;\n\n constructor(status: 'approved' | 'rejected', reason?: string) {\n this.status = status;\n this.reason = reason;\n }\n}\n\nconst TOOL_MAP: Record<string, ToolKind> = {\n 'write': 'Write',\n 'edit': 'Edit',\n};\n\n// webpieces-disable no-function-outside-class -- existing OpenClaw callback and stateless adapter helpers moved intact; the SDK invokes this module function\nfunction mapToolName(openclawName: string): ToolKind | null {\n return TOOL_MAP[openclawName] || null;\n}\n\n// webpieces-disable no-any-unknown -- openclaw SDK passes opaque tool arguments\n// webpieces-disable no-function-outside-class -- existing OpenClaw callback and stateless adapter helpers moved intact; the SDK invokes this module function\nfunction mapToolInput(toolName: string, args: Record<string, unknown>): NormalizedToolInput | null {\n const filePath = typeof args['path'] === 'string' ? args['path'] as string : null;\n if (!filePath) return null;\n\n if (toolName === 'write') {\n const content = typeof args['content'] === 'string' ? args['content'] as string : '';\n return new NormalizedToolInput(filePath, [new NormalizedEdit('', content)]);\n }\n if (toolName === 'edit') {\n const oldStr = typeof args['old_string'] === 'string' ? args['old_string'] as string : '';\n const newStr = typeof args['new_string'] === 'string' ? args['new_string'] as string : '';\n return new NormalizedToolInput(filePath, [new NormalizedEdit(oldStr, newStr)]);\n }\n return null;\n}\n\n// webpieces-disable no-function-outside-class -- existing OpenClaw callback and stateless adapter helpers moved intact; the SDK invokes this module function\nfunction findWorkspaceRoot(filePath: string): string | null {\n let dir = path.dirname(filePath);\n while (true) {\n if (fs.existsSync(path.join(dir, CONFIG_FILENAME))) return dir;\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n\n// webpieces-disable no-function-outside-class -- existing OpenClaw callback and stateless adapter helpers moved intact; the SDK invokes this module function\nexport default async function handler(\n event: ToolCallEvent,\n _context: HookContext,\n): Promise<OpenclawHandlerResult | undefined> {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const toolKind = mapToolName(event.toolName);\n if (!toolKind) return undefined;\n\n const input = mapToolInput(event.toolName, event.arguments);\n if (!input) return undefined;\n\n const wsRoot = findWorkspaceRoot(input.filePath);\n if (!wsRoot) return undefined;\n\n const loaded = loadAndValidate(wsRoot);\n const source = new SourceHookRules().load(loaded);\n const guards = new WorkflowHookRules().load(loaded);\n const result = new HookFileEvaluation().evaluate(toolKind, input, loaded,\n new HookRuleSet([...source.builtInRules, ...guards.rules, ...source.extensionRules], [...source.configuredRules, ...guards.configuredRules]));\n if (!result) return new OpenclawHandlerResult('approved');\n return new OpenclawHandlerResult('rejected', result.report);\n } catch (err: unknown) {\n const error = toError(err);\n // An escaped RuleFailError or InformAiError carries an AI-readable message; anything else is\n // an unexpected bug. All reject (fail closed).\n let msg: string;\n if (error instanceof RuleFailError) {\n msg = renderRuleFailForAi(error);\n } else if (error instanceof InformAiError) {\n msg = error.message;\n } else {\n msg = `[ai-hooks] openclaw adapter crashed — failing closed: ${error.message}`;\n }\n return new OpenclawHandlerResult('rejected', msg);\n }\n}\n"]}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/src/index.js
ADDED
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/webpieces-tooling/src/index.ts"],"names":[],"mappings":"","sourcesContent":["// Installation is the root entry point; OpenClaw has its own explicit export subpath.\nexport {};\n"]}
|