Skip to content

Commit b2ad279

Browse files
committed
fix: use NodeNext module resolution with .js import extensions
All 66 relative imports updated with .js extensions for Node.js ESM compatibility. Changed tsconfig from ESNext to NodeNext module format. Build and all 112 tests pass.
1 parent baf3fcf commit b2ad279

26 files changed

+68
-68
lines changed

src/audit-log.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import { appendFileSync, mkdirSync, renameSync, statSync, writeFileSync } from 'fs'
44
import { join } from 'path'
5-
import { getHomeDir } from './utils'
6-
import type { AuditEntry, ShellWardConfig } from './types'
5+
import { getHomeDir } from './utils.js'
6+
import type { AuditEntry, ShellWardConfig } from './types.js'
77

88
const LOG_DIR = join(getHomeDir(), '.openclaw', 'shellward')
99
const LOG_FILE = join(LOG_DIR, 'audit.jsonl')

src/auto-check.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import { execSync } from 'child_process'
55
import { existsSync, readFileSync, readdirSync } from 'fs'
66
import { join } from 'path'
7-
import { getHomeDir } from './utils'
8-
import { fetchVulnDB, compareVersions } from './update-check'
7+
import { getHomeDir } from './utils.js'
8+
import { fetchVulnDB, compareVersions } from './update-check.js'
99

1010
const OPENCLAW_DIR = join(getHomeDir(), '.openclaw')
1111

src/commands/audit.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import { readFileSync, statSync } from 'fs'
44
import { join } from 'path'
5-
import { getHomeDir } from '../utils'
6-
import type { ShellWardConfig } from '../types'
7-
import { resolveLocale } from '../types'
5+
import { getHomeDir } from '../utils.js'
6+
import type { ShellWardConfig } from '../types.js'
7+
import { resolveLocale } from '../types.js'
88

99
const LOG_FILE = join(getHomeDir(), '.openclaw', 'shellward', 'audit.jsonl')
1010

src/commands/check-updates.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import { execSync } from 'child_process'
44
import { existsSync, readFileSync } from 'fs'
55
import { join } from 'path'
6-
import type { ShellWardConfig } from '../types'
7-
import { resolveLocale } from '../types'
8-
import { checkForUpdate, fetchVulnDB, compareVersions, type VulnEntry } from '../update-check'
6+
import type { ShellWardConfig } from '../types.js'
7+
import { resolveLocale } from '../types.js'
8+
import { checkForUpdate, fetchVulnDB, compareVersions, type VulnEntry } from '../update-check.js'
99

1010
// Local fallback vulnerability database (used when remote fetch fails)
1111
// Contains only CVE-assigned vulnerabilities as minimum baseline

src/commands/harden.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import { existsSync, statSync, chmodSync, readFileSync, readdirSync } from 'fs'
44
import { join } from 'path'
55
import { execSync } from 'child_process'
6-
import type { ShellWardConfig } from '../types'
7-
import { resolveLocale } from '../types'
6+
import type { ShellWardConfig } from '../types.js'
7+
import { resolveLocale } from '../types.js'
88

9-
import { getHomeDir } from '../utils'
9+
import { getHomeDir } from '../utils.js'
1010
const HOME = getHomeDir()
1111

1212
export function registerHardenCommand(api: any, config: ShellWardConfig) {

src/commands/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// src/commands/index.ts — Register all ShellWard commands
22

3-
import type { ShellWardConfig } from '../types'
4-
import { resolveLocale } from '../types'
5-
import { registerSecurityCommand } from './security'
6-
import { registerAuditCommand } from './audit'
7-
import { registerHardenCommand } from './harden'
8-
import { registerScanPluginsCommand } from './scan-plugins'
9-
import { registerCheckUpdatesCommand } from './check-updates'
10-
import { registerUpgradeOpenClawCommand } from './upgrade-openclaw'
3+
import type { ShellWardConfig } from '../types.js'
4+
import { resolveLocale } from '../types.js'
5+
import { registerSecurityCommand } from './security.js'
6+
import { registerAuditCommand } from './audit.js'
7+
import { registerHardenCommand } from './harden.js'
8+
import { registerScanPluginsCommand } from './scan-plugins.js'
9+
import { registerCheckUpdatesCommand } from './check-updates.js'
10+
import { registerUpgradeOpenClawCommand } from './upgrade-openclaw.js'
1111

1212
export function registerAllCommands(api: any, config: ShellWardConfig) {
1313
const locale = resolveLocale(config)

src/commands/scan-plugins.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import { existsSync, readFileSync, readdirSync, statSync } from 'fs'
44
import { join } from 'path'
5-
import type { ShellWardConfig } from '../types'
6-
import { resolveLocale } from '../types'
5+
import type { ShellWardConfig } from '../types.js'
6+
import { resolveLocale } from '../types.js'
77

8-
import { getHomeDir } from '../utils'
8+
import { getHomeDir } from '../utils.js'
99
const HOME = getHomeDir()
1010
const OPENCLAW_DIR = join(HOME, '.openclaw')
1111

src/commands/security.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import { readFileSync, statSync, existsSync, readdirSync } from 'fs'
44
import { join } from 'path'
55
import { execSync } from 'child_process'
6-
import { getHomeDir } from '../utils'
7-
import type { ShellWardConfig } from '../types'
8-
import { resolveLocale } from '../types'
6+
import { getHomeDir } from '../utils.js'
7+
import type { ShellWardConfig } from '../types.js'
8+
import { resolveLocale } from '../types.js'
99

1010
const LOG_DIR = join(getHomeDir(), '.openclaw', 'shellward')
1111
const LOG_FILE = join(LOG_DIR, 'audit.jsonl')

src/commands/upgrade-openclaw.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// src/commands/upgrade-openclaw.ts — 一键升级 OpenClaw,减少手动操作
22

33
import { execSync } from 'child_process'
4-
import type { ShellWardConfig } from '../types'
5-
import { resolveLocale } from '../types'
4+
import type { ShellWardConfig } from '../types.js'
5+
import { resolveLocale } from '../types.js'
66

77
export function registerUpgradeOpenClawCommand(api: any, config: ShellWardConfig) {
88
const locale = resolveLocale(config)

src/core/engine.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
import { randomBytes } from 'crypto'
99
import { resolve } from 'path'
1010
import { homedir } from 'os'
11-
import { DANGEROUS_COMMANDS, splitCommands } from '../rules/dangerous-commands'
12-
import { PROTECTED_PATHS } from '../rules/protected-paths'
13-
import { INJECTION_RULES_ZH } from '../rules/injection-zh'
14-
import { INJECTION_RULES_EN } from '../rules/injection-en'
15-
import { redactSensitive } from '../rules/sensitive-patterns'
16-
import { AuditLog } from '../audit-log'
17-
import { resolveLocale, DEFAULT_CONFIG } from '../types'
18-
import type { ShellWardConfig, ResolvedLocale, InjectionRule } from '../types'
11+
import { DANGEROUS_COMMANDS, splitCommands } from '../rules/dangerous-commands.js'
12+
import { PROTECTED_PATHS } from '../rules/protected-paths.js'
13+
import { INJECTION_RULES_ZH } from '../rules/injection-zh.js'
14+
import { INJECTION_RULES_EN } from '../rules/injection-en.js'
15+
import { redactSensitive } from '../rules/sensitive-patterns.js'
16+
import { AuditLog } from '../audit-log.js'
17+
import { resolveLocale, DEFAULT_CONFIG } from '../types.js'
18+
import type { ShellWardConfig, ResolvedLocale, InjectionRule } from '../types.js'
1919

2020
// ===== Result Types =====
2121

0 commit comments

Comments
 (0)