Skip to content

Commit baf3fcf

Browse files
committed
build: add TypeScript build step, sync versions, add CI and issue templates
- Add tsconfig.json and build/prepublishOnly scripts so npm package ships JS - Change package.json main/exports to point at dist/ instead of src/ - Add typescript and @types/node as devDependencies - Fix type errors in audit-log.ts and check-updates.ts for strict tsc - Sync openclaw.plugin.json version from 0.5.3 to 0.5.10 - Add GitHub Actions CI workflow (test.yml) - Add bug report and feature request issue templates (bilingual)
1 parent 90e9285 commit baf3fcf

File tree

8 files changed

+83
-10
lines changed

8 files changed

+83
-10
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
name: Bug Report / Bug 报告
3+
about: Report a security issue or bug / 报告安全问题或 Bug
4+
title: '[Bug] '
5+
labels: bug
6+
assignees: ''
7+
---
8+
9+
**Describe the bug / 问题描述**
10+
11+
**Steps to reproduce / 复现步骤**
12+
1. ...
13+
14+
**Expected behavior / 期望行为**
15+
16+
**Environment / 环境信息**
17+
- OS:
18+
- Node.js version:
19+
- ShellWard version:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
name: Feature Request / 功能建议
3+
about: Suggest a new security feature / 提出新的安全功能建议
4+
title: '[Feature] '
5+
labels: enhancement
6+
assignees: ''
7+
---
8+
9+
**Feature description / 功能描述**
10+
11+
**Use case / 使用场景**
12+
13+
**Proposed solution / 建议方案**

.github/workflows/test.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Tests
2+
on: [push, pull_request]
3+
jobs:
4+
test:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- uses: actions/setup-node@v4
9+
with:
10+
node-version: 20
11+
- run: npx tsx test-sdk.ts
12+
- run: npx tsx test-integration.ts
13+
- run: npx tsx test-edge-cases.ts

openclaw.plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "shellward",
33
"name": "ShellWard",
44
"description": "AI Agent Security Middleware — injection detection, dangerous operation blocking, PII audit (incl. Chinese ID card, phone, bank card), data exfiltration prevention. SDK + OpenClaw plugin.",
5-
"version": "0.5.3",
5+
"version": "0.5.10",
66
"skills": ["./skills"],
77
"configSchema": {
88
"type": "object",

package.json

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,21 @@
4141
"url": "https://github.com/jnMetaCode/shellward"
4242
},
4343
"type": "module",
44-
"main": "src/index.ts",
44+
"main": "dist/index.js",
45+
"types": "dist/index.d.ts",
4546
"exports": {
4647
".": {
47-
"import": "./src/index.ts",
48-
"default": "./src/index.ts"
48+
"import": "./dist/index.js",
49+
"types": "./dist/index.d.ts"
4950
}
5051
},
5152
"scripts": {
52-
"test": "npx tsx test-integration.ts && npx tsx test-edge-cases.ts && npx tsx test-sdk.ts",
53+
"build": "tsc",
54+
"test": "npx tsx test-sdk.ts && npx tsx test-integration.ts && npx tsx test-edge-cases.ts",
5355
"test:integration": "npx tsx test-integration.ts",
5456
"test:edge": "npx tsx test-edge-cases.ts",
55-
"test:sdk": "npx tsx test-sdk.ts"
57+
"test:sdk": "npx tsx test-sdk.ts",
58+
"prepublishOnly": "npm run build"
5659
},
5760
"openclaw": {
5861
"extensions": [
@@ -61,6 +64,7 @@
6164
},
6265
"files": [
6366
"src/",
67+
"dist/",
6468
"skills/",
6569
"openclaw.plugin.json",
6670
"vuln-db.json",
@@ -71,5 +75,9 @@
7175
],
7276
"engines": {
7377
"node": ">=18"
78+
},
79+
"devDependencies": {
80+
"@types/node": "^25.5.0",
81+
"typescript": "^5.9.3"
7482
}
7583
}

src/audit-log.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ export class AuditLog {
3434
} catch { /* directory may already exist */ }
3535
}
3636

37-
write(entry: Omit<AuditEntry, 'ts' | 'mode'>): void {
37+
write(entry: Pick<AuditEntry, 'level' | 'layer' | 'action' | 'detail'> & Record<string, unknown>): void {
3838
try {
3939
const record: AuditEntry = {
40+
...entry,
41+
level: entry.level,
42+
layer: entry.layer,
43+
action: entry.action,
44+
detail: entry.detail,
4045
ts: new Date().toISOString(),
4146
mode: this.config.mode,
4247
riskScore: RISK_SCORES[entry.level] ?? 0,
43-
...entry,
4448
}
4549
appendFileSync(LOG_FILE, JSON.stringify(record) + '\n', { mode: 0o600 })
4650
this.rotateIfNeeded()

src/commands/check-updates.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { existsSync, readFileSync } from 'fs'
55
import { join } from 'path'
66
import type { ShellWardConfig } from '../types'
77
import { resolveLocale } from '../types'
8-
import { checkForUpdate, fetchVulnDB, compareVersions } from '../update-check'
8+
import { checkForUpdate, fetchVulnDB, compareVersions, type VulnEntry } from '../update-check'
99

1010
// Local fallback vulnerability database (used when remote fetch fails)
1111
// Contains only CVE-assigned vulnerabilities as minimum baseline
@@ -92,7 +92,7 @@ export function registerCheckUpdatesCommand(api: any, config: ShellWardConfig) {
9292
// 3. Check known vulnerabilities (remote DB with local fallback)
9393
lines.push(zh ? '### 已知漏洞检查' : '### Known Vulnerability Check')
9494

95-
let vulnDB = LOCAL_VULNS
95+
let vulnDB: VulnEntry[] = LOCAL_VULNS
9696
let alerts: { id: string; severity: string; date: string; description_zh: string; description_en: string }[] = []
9797
let dbSource = 'local'
9898
try {

tsconfig.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"module": "ESNext",
5+
"moduleResolution": "bundler",
6+
"declaration": true,
7+
"declarationDir": "dist",
8+
"outDir": "dist",
9+
"rootDir": "src",
10+
"strict": true,
11+
"esModuleInterop": true,
12+
"skipLibCheck": true
13+
},
14+
"include": ["src/**/*.ts"],
15+
"exclude": ["test-*.ts"]
16+
}

0 commit comments

Comments
 (0)