@raolin2025/claude-code-node 2.3.0 → 2.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raolin2025/claude-code-node",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Node.js AI Code Agent CLI - Zero dependencies, pure JavaScript, security hardened, multi-channel notifications",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -76,6 +76,7 @@ export class EnhancedPermissionChecker {
76
76
  this.auditLog = [] // 审计日志
77
77
  this.cwd = options.cwd || process.cwd()
78
78
  this.projectDir = options.projectDir || process.cwd()
79
+ this.sessionAllowAll = false // 新增:会话剩余时间全部自动允许
79
80
  this._maxAuditEntries = 1000
80
81
  }
81
82
 
@@ -111,6 +112,26 @@ export class EnhancedPermissionChecker {
111
112
  })
112
113
  }
113
114
 
115
+ // 会话剩余时间全部工具自动允许
116
+ allowAllForSession() {
117
+ this.sessionAllowAll = true
118
+ }
119
+
120
+ // 重置会话允许状态
121
+ resetSessionAllow() {
122
+ this.sessionAllowAll = false
123
+ }
124
+
125
+ // 允许指定工具(会话级规则)
126
+ allow(tool, pattern = '*') {
127
+ return this.addRule({
128
+ tool,
129
+ pattern,
130
+ decision: PermissionDecision.ALLOW,
131
+ reason: '用户手动允许',
132
+ })
133
+ }
134
+
114
135
  /**
115
136
  * 综合权限检查
116
137
  * @param {string} toolName — 工具名
@@ -118,6 +139,16 @@ export class EnhancedPermissionChecker {
118
139
  * @returns {Promise<{allowed: boolean, reason?: string, requiresConfirmation?: boolean, securityCheck?: object}>}
119
140
  */
120
141
  async check(toolName, input = {}) {
142
+ // 1. 会话全局允许功能 (skip ask)
143
+ if (this.sessionAllowAll) {
144
+ const securityResult = await this._securityCheck(toolName, input)
145
+ if (!securityResult.safe) {
146
+ this._log(toolName, input, false, securityResult.reason)
147
+ return { allowed: false, reason: securityResult.reason, securityCheck: securityResult }
148
+ }
149
+ this._log(toolName, input, true, '会话全局自动允许')
150
+ return { allowed: true }
151
+ }
121
152
  // 1. 模式级检查
122
153
  if (this.mode === 'deny') {
123
154
  this._log(toolName, input, false, '全局拒绝模式')