@defai.digital/ax-cli 4.4.6 → 4.4.10
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/bin/ax-cli +1 -5
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +158 -9
- package/dist/index.js.map +1 -1
- package/dist/setup.d.ts +27 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +591 -0
- package/dist/setup.js.map +1 -0
- package/package.json +43 -135
- package/LICENSE +0 -22
- package/README.md +0 -387
- package/config-defaults/messages.yaml +0 -75
- package/config-defaults/models.yaml +0 -57
- package/config-defaults/prompts.yaml +0 -948
- package/config-defaults/settings.yaml +0 -157
- package/dist/agent/agent-executor.d.ts +0 -61
- package/dist/agent/agent-executor.js +0 -194
- package/dist/agent/agent-executor.js.map +0 -1
- package/dist/agent/agent-router.d.ts +0 -68
- package/dist/agent/agent-router.js +0 -242
- package/dist/agent/agent-router.js.map +0 -1
- package/dist/agent/context-manager.d.ts +0 -122
- package/dist/agent/context-manager.js +0 -406
- package/dist/agent/context-manager.js.map +0 -1
- package/dist/agent/core/index.d.ts +0 -8
- package/dist/agent/core/index.js +0 -9
- package/dist/agent/core/index.js.map +0 -1
- package/dist/agent/core/types.d.ts +0 -92
- package/dist/agent/core/types.js +0 -11
- package/dist/agent/core/types.js.map +0 -1
- package/dist/agent/dependency-resolver.d.ts +0 -90
- package/dist/agent/dependency-resolver.js +0 -366
- package/dist/agent/dependency-resolver.js.map +0 -1
- package/dist/agent/execution/index.d.ts +0 -9
- package/dist/agent/execution/index.js +0 -9
- package/dist/agent/execution/index.js.map +0 -1
- package/dist/agent/execution/tool-executor.d.ts +0 -93
- package/dist/agent/execution/tool-executor.js +0 -552
- package/dist/agent/execution/tool-executor.js.map +0 -1
- package/dist/agent/index.d.ts +0 -14
- package/dist/agent/index.js +0 -145
- package/dist/agent/index.js.map +0 -1
- package/dist/agent/llm-agent.d.ts +0 -368
- package/dist/agent/llm-agent.js +0 -1931
- package/dist/agent/llm-agent.js.map +0 -1
- package/dist/agent/loop-detector.d.ts +0 -72
- package/dist/agent/loop-detector.js +0 -335
- package/dist/agent/loop-detector.js.map +0 -1
- package/dist/agent/parallel-tools.d.ts +0 -69
- package/dist/agent/parallel-tools.js +0 -188
- package/dist/agent/parallel-tools.js.map +0 -1
- package/dist/agent/planning/index.d.ts +0 -9
- package/dist/agent/planning/index.js +0 -9
- package/dist/agent/planning/index.js.map +0 -1
- package/dist/agent/planning/plan-executor.d.ts +0 -79
- package/dist/agent/planning/plan-executor.js +0 -240
- package/dist/agent/planning/plan-executor.js.map +0 -1
- package/dist/agent/progress-tracker.d.ts +0 -94
- package/dist/agent/progress-tracker.js +0 -225
- package/dist/agent/progress-tracker.js.map +0 -1
- package/dist/agent/specialized/analysis-agent.d.ts +0 -11
- package/dist/agent/specialized/analysis-agent.js +0 -24
- package/dist/agent/specialized/analysis-agent.js.map +0 -1
- package/dist/agent/specialized/debug-agent.d.ts +0 -11
- package/dist/agent/specialized/debug-agent.js +0 -46
- package/dist/agent/specialized/debug-agent.js.map +0 -1
- package/dist/agent/specialized/documentation-agent.d.ts +0 -11
- package/dist/agent/specialized/documentation-agent.js +0 -24
- package/dist/agent/specialized/documentation-agent.js.map +0 -1
- package/dist/agent/specialized/index.d.ts +0 -11
- package/dist/agent/specialized/index.js +0 -12
- package/dist/agent/specialized/index.js.map +0 -1
- package/dist/agent/specialized/performance-agent.d.ts +0 -11
- package/dist/agent/specialized/performance-agent.js +0 -24
- package/dist/agent/specialized/performance-agent.js.map +0 -1
- package/dist/agent/specialized/refactoring-agent.d.ts +0 -11
- package/dist/agent/specialized/refactoring-agent.js +0 -24
- package/dist/agent/specialized/refactoring-agent.js.map +0 -1
- package/dist/agent/specialized/testing-agent.d.ts +0 -11
- package/dist/agent/specialized/testing-agent.js +0 -24
- package/dist/agent/specialized/testing-agent.js.map +0 -1
- package/dist/agent/status-reporter.d.ts +0 -114
- package/dist/agent/status-reporter.js +0 -335
- package/dist/agent/status-reporter.js.map +0 -1
- package/dist/agent/streaming/index.d.ts +0 -9
- package/dist/agent/streaming/index.js +0 -9
- package/dist/agent/streaming/index.js.map +0 -1
- package/dist/agent/streaming/stream-handler.d.ts +0 -62
- package/dist/agent/streaming/stream-handler.js +0 -217
- package/dist/agent/streaming/stream-handler.js.map +0 -1
- package/dist/agent/subagent-orchestrator.d.ts +0 -166
- package/dist/agent/subagent-orchestrator.js +0 -487
- package/dist/agent/subagent-orchestrator.js.map +0 -1
- package/dist/agent/subagent-types.d.ts +0 -261
- package/dist/agent/subagent-types.js +0 -257
- package/dist/agent/subagent-types.js.map +0 -1
- package/dist/agent/subagent.d.ts +0 -116
- package/dist/agent/subagent.js +0 -507
- package/dist/agent/subagent.js.map +0 -1
- package/dist/checkpoint/index.d.ts +0 -9
- package/dist/checkpoint/index.js +0 -11
- package/dist/checkpoint/index.js.map +0 -1
- package/dist/checkpoint/manager.d.ts +0 -101
- package/dist/checkpoint/manager.js +0 -407
- package/dist/checkpoint/manager.js.map +0 -1
- package/dist/checkpoint/storage.d.ts +0 -39
- package/dist/checkpoint/storage.js +0 -350
- package/dist/checkpoint/storage.js.map +0 -1
- package/dist/checkpoint/types.d.ts +0 -111
- package/dist/checkpoint/types.js +0 -17
- package/dist/checkpoint/types.js.map +0 -1
- package/dist/commands/cache.d.ts +0 -7
- package/dist/commands/cache.js +0 -284
- package/dist/commands/cache.js.map +0 -1
- package/dist/commands/custom-commands.d.ts +0 -77
- package/dist/commands/custom-commands.js +0 -251
- package/dist/commands/custom-commands.js.map +0 -1
- package/dist/commands/design.d.ts +0 -18
- package/dist/commands/design.js +0 -511
- package/dist/commands/design.js.map +0 -1
- package/dist/commands/doctor.d.ts +0 -6
- package/dist/commands/doctor.js +0 -773
- package/dist/commands/doctor.js.map +0 -1
- package/dist/commands/frontend.d.ts +0 -9
- package/dist/commands/frontend.js +0 -645
- package/dist/commands/frontend.js.map +0 -1
- package/dist/commands/init/wizard.d.ts +0 -55
- package/dist/commands/init/wizard.js +0 -189
- package/dist/commands/init/wizard.js.map +0 -1
- package/dist/commands/init.d.ts +0 -8
- package/dist/commands/init.js +0 -195
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/mcp-migrate.d.ts +0 -9
- package/dist/commands/mcp-migrate.js +0 -175
- package/dist/commands/mcp-migrate.js.map +0 -1
- package/dist/commands/mcp.d.ts +0 -2
- package/dist/commands/mcp.js +0 -1292
- package/dist/commands/mcp.js.map +0 -1
- package/dist/commands/memory.d.ts +0 -6
- package/dist/commands/memory.js +0 -555
- package/dist/commands/memory.js.map +0 -1
- package/dist/commands/models.d.ts +0 -5
- package/dist/commands/models.js +0 -213
- package/dist/commands/models.js.map +0 -1
- package/dist/commands/plan.d.ts +0 -43
- package/dist/commands/plan.js +0 -362
- package/dist/commands/plan.js.map +0 -1
- package/dist/commands/rewind.d.ts +0 -19
- package/dist/commands/rewind.js +0 -221
- package/dist/commands/rewind.js.map +0 -1
- package/dist/commands/setup.d.ts +0 -14
- package/dist/commands/setup.js +0 -733
- package/dist/commands/setup.js.map +0 -1
- package/dist/commands/status.d.ts +0 -7
- package/dist/commands/status.js +0 -437
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/templates.d.ts +0 -5
- package/dist/commands/templates.js +0 -245
- package/dist/commands/templates.js.map +0 -1
- package/dist/commands/update.d.ts +0 -49
- package/dist/commands/update.js +0 -366
- package/dist/commands/update.js.map +0 -1
- package/dist/commands/usage.d.ts +0 -8
- package/dist/commands/usage.js +0 -264
- package/dist/commands/usage.js.map +0 -1
- package/dist/commands/vscode.d.ts +0 -7
- package/dist/commands/vscode.js +0 -419
- package/dist/commands/vscode.js.map +0 -1
- package/dist/constants.d.ts +0 -236
- package/dist/constants.js +0 -288
- package/dist/constants.js.map +0 -1
- package/dist/design/figma-alias.d.ts +0 -170
- package/dist/design/figma-alias.js +0 -577
- package/dist/design/figma-alias.js.map +0 -1
- package/dist/design/figma-audit.d.ts +0 -40
- package/dist/design/figma-audit.js +0 -383
- package/dist/design/figma-audit.js.map +0 -1
- package/dist/design/figma-client.d.ts +0 -131
- package/dist/design/figma-client.js +0 -369
- package/dist/design/figma-client.js.map +0 -1
- package/dist/design/figma-map.d.ts +0 -29
- package/dist/design/figma-map.js +0 -346
- package/dist/design/figma-map.js.map +0 -1
- package/dist/design/figma-tokens.d.ts +0 -73
- package/dist/design/figma-tokens.js +0 -448
- package/dist/design/figma-tokens.js.map +0 -1
- package/dist/design/index.d.ts +0 -13
- package/dist/design/index.js +0 -20
- package/dist/design/index.js.map +0 -1
- package/dist/design/types.d.ts +0 -98
- package/dist/design/types.js +0 -9
- package/dist/design/types.js.map +0 -1
- package/dist/hooks/hook-runner.d.ts +0 -142
- package/dist/hooks/hook-runner.js +0 -436
- package/dist/hooks/hook-runner.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -9
- package/dist/hooks/index.js +0 -10
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/manager.d.ts +0 -84
- package/dist/hooks/manager.js +0 -348
- package/dist/hooks/manager.js.map +0 -1
- package/dist/hooks/types.d.ts +0 -134
- package/dist/hooks/types.js +0 -9
- package/dist/hooks/types.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/ipc/index.d.ts +0 -9
- package/dist/ipc/index.js +0 -10
- package/dist/ipc/index.js.map +0 -1
- package/dist/ipc/vscode-client.d.ts +0 -200
- package/dist/ipc/vscode-client.js +0 -495
- package/dist/ipc/vscode-client.js.map +0 -1
- package/dist/llm/client.d.ts +0 -205
- package/dist/llm/client.js +0 -735
- package/dist/llm/client.js.map +0 -1
- package/dist/llm/tools.d.ts +0 -102
- package/dist/llm/tools.js +0 -275
- package/dist/llm/tools.js.map +0 -1
- package/dist/llm/types.d.ts +0 -428
- package/dist/llm/types.js +0 -194
- package/dist/llm/types.js.map +0 -1
- package/dist/mcp/automatosx-auto-discovery.d.ts +0 -66
- package/dist/mcp/automatosx-auto-discovery.js +0 -169
- package/dist/mcp/automatosx-auto-discovery.js.map +0 -1
- package/dist/mcp/automatosx-loader.d.ts +0 -99
- package/dist/mcp/automatosx-loader.js +0 -250
- package/dist/mcp/automatosx-loader.js.map +0 -1
- package/dist/mcp/cancellation.d.ts +0 -182
- package/dist/mcp/cancellation.js +0 -275
- package/dist/mcp/cancellation.js.map +0 -1
- package/dist/mcp/client-v2.d.ts +0 -500
- package/dist/mcp/client-v2.js +0 -1433
- package/dist/mcp/client-v2.js.map +0 -1
- package/dist/mcp/client.d.ts +0 -170
- package/dist/mcp/client.js +0 -232
- package/dist/mcp/client.js.map +0 -1
- package/dist/mcp/config-detector.d.ts +0 -90
- package/dist/mcp/config-detector.js +0 -250
- package/dist/mcp/config-detector.js.map +0 -1
- package/dist/mcp/config-migrator.d.ts +0 -68
- package/dist/mcp/config-migrator.js +0 -291
- package/dist/mcp/config-migrator.js.map +0 -1
- package/dist/mcp/config.d.ts +0 -24
- package/dist/mcp/config.js +0 -273
- package/dist/mcp/config.js.map +0 -1
- package/dist/mcp/constants.d.ts +0 -66
- package/dist/mcp/constants.js +0 -85
- package/dist/mcp/constants.js.map +0 -1
- package/dist/mcp/content-length-transport.d.ts +0 -106
- package/dist/mcp/content-length-transport.js +0 -413
- package/dist/mcp/content-length-transport.js.map +0 -1
- package/dist/mcp/debug.d.ts +0 -211
- package/dist/mcp/debug.js +0 -404
- package/dist/mcp/debug.js.map +0 -1
- package/dist/mcp/error-formatter.d.ts +0 -40
- package/dist/mcp/error-formatter.js +0 -207
- package/dist/mcp/error-formatter.js.map +0 -1
- package/dist/mcp/error-remediation.d.ts +0 -45
- package/dist/mcp/error-remediation.js +0 -291
- package/dist/mcp/error-remediation.js.map +0 -1
- package/dist/mcp/health.d.ts +0 -120
- package/dist/mcp/health.js +0 -267
- package/dist/mcp/health.js.map +0 -1
- package/dist/mcp/index.d.ts +0 -56
- package/dist/mcp/index.js +0 -89
- package/dist/mcp/index.js.map +0 -1
- package/dist/mcp/invariants.d.ts +0 -141
- package/dist/mcp/invariants.js +0 -243
- package/dist/mcp/invariants.js.map +0 -1
- package/dist/mcp/mutex-safe.d.ts +0 -151
- package/dist/mcp/mutex-safe.js +0 -260
- package/dist/mcp/mutex-safe.js.map +0 -1
- package/dist/mcp/progress.d.ts +0 -155
- package/dist/mcp/progress.js +0 -252
- package/dist/mcp/progress.js.map +0 -1
- package/dist/mcp/prompts.d.ts +0 -68
- package/dist/mcp/prompts.js +0 -129
- package/dist/mcp/prompts.js.map +0 -1
- package/dist/mcp/provider-mcp-loader.d.ts +0 -130
- package/dist/mcp/provider-mcp-loader.js +0 -292
- package/dist/mcp/provider-mcp-loader.js.map +0 -1
- package/dist/mcp/reconnection.d.ts +0 -101
- package/dist/mcp/reconnection.js +0 -253
- package/dist/mcp/reconnection.js.map +0 -1
- package/dist/mcp/registry.d.ts +0 -75
- package/dist/mcp/registry.js +0 -276
- package/dist/mcp/registry.js.map +0 -1
- package/dist/mcp/resources.d.ts +0 -58
- package/dist/mcp/resources.js +0 -144
- package/dist/mcp/resources.js.map +0 -1
- package/dist/mcp/schema-validator.d.ts +0 -82
- package/dist/mcp/schema-validator.js +0 -161
- package/dist/mcp/schema-validator.js.map +0 -1
- package/dist/mcp/ssrf-protection.d.ts +0 -86
- package/dist/mcp/ssrf-protection.js +0 -311
- package/dist/mcp/ssrf-protection.js.map +0 -1
- package/dist/mcp/subscriptions.d.ts +0 -168
- package/dist/mcp/subscriptions.js +0 -248
- package/dist/mcp/subscriptions.js.map +0 -1
- package/dist/mcp/templates.d.ts +0 -52
- package/dist/mcp/templates.js +0 -627
- package/dist/mcp/templates.js.map +0 -1
- package/dist/mcp/transports.d.ts +0 -80
- package/dist/mcp/transports.js +0 -237
- package/dist/mcp/transports.js.map +0 -1
- package/dist/mcp/type-safety.d.ts +0 -225
- package/dist/mcp/type-safety.js +0 -237
- package/dist/mcp/type-safety.js.map +0 -1
- package/dist/mcp/validation.d.ts +0 -29
- package/dist/mcp/validation.js +0 -339
- package/dist/mcp/validation.js.map +0 -1
- package/dist/mcp/zai-detector.d.ts +0 -63
- package/dist/mcp/zai-detector.js +0 -193
- package/dist/mcp/zai-detector.js.map +0 -1
- package/dist/mcp/zai-templates.d.ts +0 -90
- package/dist/mcp/zai-templates.js +0 -157
- package/dist/mcp/zai-templates.js.map +0 -1
- package/dist/memory/context-generator.d.ts +0 -84
- package/dist/memory/context-generator.js +0 -546
- package/dist/memory/context-generator.js.map +0 -1
- package/dist/memory/context-injector.d.ts +0 -97
- package/dist/memory/context-injector.js +0 -159
- package/dist/memory/context-injector.js.map +0 -1
- package/dist/memory/context-store.d.ts +0 -103
- package/dist/memory/context-store.js +0 -264
- package/dist/memory/context-store.js.map +0 -1
- package/dist/memory/index.d.ts +0 -43
- package/dist/memory/index.js +0 -49
- package/dist/memory/index.js.map +0 -1
- package/dist/memory/provider-context-store.d.ts +0 -127
- package/dist/memory/provider-context-store.js +0 -385
- package/dist/memory/provider-context-store.js.map +0 -1
- package/dist/memory/schemas.d.ts +0 -118
- package/dist/memory/schemas.js +0 -106
- package/dist/memory/schemas.js.map +0 -1
- package/dist/memory/stats-collector.d.ts +0 -73
- package/dist/memory/stats-collector.js +0 -170
- package/dist/memory/stats-collector.js.map +0 -1
- package/dist/memory/types.d.ts +0 -177
- package/dist/memory/types.js +0 -73
- package/dist/memory/types.js.map +0 -1
- package/dist/permissions/index.d.ts +0 -6
- package/dist/permissions/index.js +0 -7
- package/dist/permissions/index.js.map +0 -1
- package/dist/permissions/permission-manager.d.ts +0 -149
- package/dist/permissions/permission-manager.js +0 -410
- package/dist/permissions/permission-manager.js.map +0 -1
- package/dist/planner/dependency-resolver.d.ts +0 -72
- package/dist/planner/dependency-resolver.js +0 -272
- package/dist/planner/dependency-resolver.js.map +0 -1
- package/dist/planner/index.d.ts +0 -12
- package/dist/planner/index.js +0 -28
- package/dist/planner/index.js.map +0 -1
- package/dist/planner/plan-generator.d.ts +0 -74
- package/dist/planner/plan-generator.js +0 -244
- package/dist/planner/plan-generator.js.map +0 -1
- package/dist/planner/plan-storage.d.ts +0 -113
- package/dist/planner/plan-storage.js +0 -398
- package/dist/planner/plan-storage.js.map +0 -1
- package/dist/planner/prompts/planning-prompt.d.ts +0 -62
- package/dist/planner/prompts/planning-prompt.js +0 -414
- package/dist/planner/prompts/planning-prompt.js.map +0 -1
- package/dist/planner/task-planner.d.ts +0 -139
- package/dist/planner/task-planner.js +0 -532
- package/dist/planner/task-planner.js.map +0 -1
- package/dist/planner/token-estimator.d.ts +0 -63
- package/dist/planner/token-estimator.js +0 -295
- package/dist/planner/token-estimator.js.map +0 -1
- package/dist/planner/types.d.ts +0 -425
- package/dist/planner/types.js +0 -213
- package/dist/planner/types.js.map +0 -1
- package/dist/provider/config.d.ts +0 -227
- package/dist/provider/config.js +0 -430
- package/dist/provider/config.js.map +0 -1
- package/dist/schemas/api-schemas.d.ts +0 -45
- package/dist/schemas/api-schemas.js +0 -129
- package/dist/schemas/api-schemas.js.map +0 -1
- package/dist/schemas/confirmation-schemas.d.ts +0 -39
- package/dist/schemas/confirmation-schemas.js +0 -48
- package/dist/schemas/confirmation-schemas.js.map +0 -1
- package/dist/schemas/index-unified.d.ts +0 -12
- package/dist/schemas/index-unified.js +0 -17
- package/dist/schemas/index-unified.js.map +0 -1
- package/dist/schemas/index.d.ts +0 -83
- package/dist/schemas/index.js +0 -139
- package/dist/schemas/index.js.map +0 -1
- package/dist/schemas/settings-schemas.d.ts +0 -186
- package/dist/schemas/settings-schemas.js +0 -324
- package/dist/schemas/settings-schemas.js.map +0 -1
- package/dist/schemas/tool-schemas.d.ts +0 -127
- package/dist/schemas/tool-schemas.js +0 -84
- package/dist/schemas/tool-schemas.js.map +0 -1
- package/dist/schemas/yaml-schemas.d.ts +0 -231
- package/dist/schemas/yaml-schemas.js +0 -199
- package/dist/schemas/yaml-schemas.js.map +0 -1
- package/dist/sdk/errors.d.ts +0 -100
- package/dist/sdk/errors.js +0 -138
- package/dist/sdk/errors.js.map +0 -1
- package/dist/sdk/index.d.ts +0 -901
- package/dist/sdk/index.js +0 -1272
- package/dist/sdk/index.js.map +0 -1
- package/dist/sdk/progress-reporter.d.ts +0 -123
- package/dist/sdk/progress-reporter.js +0 -220
- package/dist/sdk/progress-reporter.js.map +0 -1
- package/dist/sdk/testing.d.ts +0 -427
- package/dist/sdk/testing.js +0 -725
- package/dist/sdk/testing.js.map +0 -1
- package/dist/sdk/tool-registry.d.ts +0 -194
- package/dist/sdk/tool-registry.js +0 -326
- package/dist/sdk/tool-registry.js.map +0 -1
- package/dist/sdk/types.d.ts +0 -53
- package/dist/sdk/types.js +0 -8
- package/dist/sdk/types.js.map +0 -1
- package/dist/sdk/unified-logger.d.ts +0 -173
- package/dist/sdk/unified-logger.js +0 -327
- package/dist/sdk/unified-logger.js.map +0 -1
- package/dist/sdk/version.d.ts +0 -163
- package/dist/sdk/version.js +0 -205
- package/dist/sdk/version.js.map +0 -1
- package/dist/tools/ask-user.d.ts +0 -126
- package/dist/tools/ask-user.js +0 -290
- package/dist/tools/ask-user.js.map +0 -1
- package/dist/tools/ax-agent.d.ts +0 -71
- package/dist/tools/ax-agent.js +0 -283
- package/dist/tools/ax-agent.js.map +0 -1
- package/dist/tools/bash-output.d.ts +0 -25
- package/dist/tools/bash-output.js +0 -146
- package/dist/tools/bash-output.js.map +0 -1
- package/dist/tools/bash.d.ts +0 -67
- package/dist/tools/bash.js +0 -522
- package/dist/tools/bash.js.map +0 -1
- package/dist/tools/confirmation-tool.d.ts +0 -16
- package/dist/tools/confirmation-tool.js +0 -76
- package/dist/tools/confirmation-tool.js.map +0 -1
- package/dist/tools/definitions/ask-user.d.ts +0 -8
- package/dist/tools/definitions/ask-user.js +0 -168
- package/dist/tools/definitions/ask-user.js.map +0 -1
- package/dist/tools/definitions/ax-agent.d.ts +0 -8
- package/dist/tools/definitions/ax-agent.js +0 -276
- package/dist/tools/definitions/ax-agent.js.map +0 -1
- package/dist/tools/definitions/bash-output.d.ts +0 -7
- package/dist/tools/definitions/bash-output.js +0 -78
- package/dist/tools/definitions/bash-output.js.map +0 -1
- package/dist/tools/definitions/bash.d.ts +0 -8
- package/dist/tools/definitions/bash.js +0 -152
- package/dist/tools/definitions/bash.js.map +0 -1
- package/dist/tools/definitions/create-file.d.ts +0 -7
- package/dist/tools/definitions/create-file.js +0 -129
- package/dist/tools/definitions/create-file.js.map +0 -1
- package/dist/tools/definitions/design.d.ts +0 -12
- package/dist/tools/definitions/design.js +0 -368
- package/dist/tools/definitions/design.js.map +0 -1
- package/dist/tools/definitions/index.d.ts +0 -49
- package/dist/tools/definitions/index.js +0 -87
- package/dist/tools/definitions/index.js.map +0 -1
- package/dist/tools/definitions/multi-edit.d.ts +0 -7
- package/dist/tools/definitions/multi-edit.js +0 -123
- package/dist/tools/definitions/multi-edit.js.map +0 -1
- package/dist/tools/definitions/search.d.ts +0 -7
- package/dist/tools/definitions/search.js +0 -159
- package/dist/tools/definitions/search.js.map +0 -1
- package/dist/tools/definitions/str-replace-editor.d.ts +0 -7
- package/dist/tools/definitions/str-replace-editor.js +0 -145
- package/dist/tools/definitions/str-replace-editor.js.map +0 -1
- package/dist/tools/definitions/todo.d.ts +0 -8
- package/dist/tools/definitions/todo.js +0 -261
- package/dist/tools/definitions/todo.js.map +0 -1
- package/dist/tools/definitions/view-file.d.ts +0 -7
- package/dist/tools/definitions/view-file.js +0 -111
- package/dist/tools/definitions/view-file.js.map +0 -1
- package/dist/tools/design-tool.d.ts +0 -68
- package/dist/tools/design-tool.js +0 -299
- package/dist/tools/design-tool.js.map +0 -1
- package/dist/tools/format-generators.d.ts +0 -62
- package/dist/tools/format-generators.js +0 -291
- package/dist/tools/format-generators.js.map +0 -1
- package/dist/tools/index.d.ts +0 -8
- package/dist/tools/index.js +0 -11
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/priority-registry.d.ts +0 -124
- package/dist/tools/priority-registry.js +0 -401
- package/dist/tools/priority-registry.js.map +0 -1
- package/dist/tools/priority.d.ts +0 -158
- package/dist/tools/priority.js +0 -350
- package/dist/tools/priority.js.map +0 -1
- package/dist/tools/registry.d.ts +0 -146
- package/dist/tools/registry.js +0 -171
- package/dist/tools/registry.js.map +0 -1
- package/dist/tools/search.d.ts +0 -85
- package/dist/tools/search.js +0 -430
- package/dist/tools/search.js.map +0 -1
- package/dist/tools/text-editor.d.ts +0 -87
- package/dist/tools/text-editor.js +0 -1369
- package/dist/tools/text-editor.js.map +0 -1
- package/dist/tools/todo-tool.d.ts +0 -20
- package/dist/tools/todo-tool.js +0 -186
- package/dist/tools/todo-tool.js.map +0 -1
- package/dist/tools/types.d.ts +0 -175
- package/dist/tools/types.js +0 -11
- package/dist/tools/types.js.map +0 -1
- package/dist/types/index.d.ts +0 -30
- package/dist/types/index.js +0 -2
- package/dist/types/index.js.map +0 -1
- package/dist/types/project-analysis.d.ts +0 -84
- package/dist/types/project-analysis.js +0 -5
- package/dist/types/project-analysis.js.map +0 -1
- package/dist/types/template.d.ts +0 -53
- package/dist/types/template.js +0 -5
- package/dist/types/template.js.map +0 -1
- package/dist/ui/app.d.ts +0 -7
- package/dist/ui/app.js +0 -102
- package/dist/ui/app.js.map +0 -1
- package/dist/ui/components/api-key-input.d.ts +0 -7
- package/dist/ui/components/api-key-input.js +0 -92
- package/dist/ui/components/api-key-input.js.map +0 -1
- package/dist/ui/components/chat-history.d.ts +0 -12
- package/dist/ui/components/chat-history.js +0 -391
- package/dist/ui/components/chat-history.js.map +0 -1
- package/dist/ui/components/chat-input.d.ts +0 -13
- package/dist/ui/components/chat-input.js +0 -179
- package/dist/ui/components/chat-input.js.map +0 -1
- package/dist/ui/components/chat-interface.d.ts +0 -11
- package/dist/ui/components/chat-interface.js +0 -830
- package/dist/ui/components/chat-interface.js.map +0 -1
- package/dist/ui/components/collapsible-tool-result.d.ts +0 -42
- package/dist/ui/components/collapsible-tool-result.js +0 -216
- package/dist/ui/components/collapsible-tool-result.js.map +0 -1
- package/dist/ui/components/command-suggestions.d.ts +0 -29
- package/dist/ui/components/command-suggestions.js +0 -88
- package/dist/ui/components/command-suggestions.js.map +0 -1
- package/dist/ui/components/confirmation-dialog.d.ts +0 -11
- package/dist/ui/components/confirmation-dialog.js +0 -100
- package/dist/ui/components/confirmation-dialog.js.map +0 -1
- package/dist/ui/components/context-breakdown.d.ts +0 -23
- package/dist/ui/components/context-breakdown.js +0 -124
- package/dist/ui/components/context-breakdown.js.map +0 -1
- package/dist/ui/components/diff-renderer.d.ts +0 -13
- package/dist/ui/components/diff-renderer.js +0 -192
- package/dist/ui/components/diff-renderer.js.map +0 -1
- package/dist/ui/components/index.d.ts +0 -18
- package/dist/ui/components/index.js +0 -20
- package/dist/ui/components/index.js.map +0 -1
- package/dist/ui/components/keyboard-help.d.ts +0 -17
- package/dist/ui/components/keyboard-help.js +0 -122
- package/dist/ui/components/keyboard-help.js.map +0 -1
- package/dist/ui/components/keyboard-hints.d.ts +0 -35
- package/dist/ui/components/keyboard-hints.js +0 -142
- package/dist/ui/components/keyboard-hints.js.map +0 -1
- package/dist/ui/components/loading-spinner.d.ts +0 -9
- package/dist/ui/components/loading-spinner.js +0 -120
- package/dist/ui/components/loading-spinner.js.map +0 -1
- package/dist/ui/components/mcp-dashboard.d.ts +0 -15
- package/dist/ui/components/mcp-dashboard.js +0 -520
- package/dist/ui/components/mcp-dashboard.js.map +0 -1
- package/dist/ui/components/mcp-status.d.ts +0 -5
- package/dist/ui/components/mcp-status.js +0 -58
- package/dist/ui/components/mcp-status.js.map +0 -1
- package/dist/ui/components/model-selection.d.ts +0 -12
- package/dist/ui/components/model-selection.js +0 -17
- package/dist/ui/components/model-selection.js.map +0 -1
- package/dist/ui/components/phase-progress.d.ts +0 -21
- package/dist/ui/components/phase-progress.js +0 -185
- package/dist/ui/components/phase-progress.js.map +0 -1
- package/dist/ui/components/question-dialog.d.ts +0 -17
- package/dist/ui/components/question-dialog.js +0 -181
- package/dist/ui/components/question-dialog.js.map +0 -1
- package/dist/ui/components/quick-actions.d.ts +0 -12
- package/dist/ui/components/quick-actions.js +0 -171
- package/dist/ui/components/quick-actions.js.map +0 -1
- package/dist/ui/components/reasoning-display.d.ts +0 -36
- package/dist/ui/components/reasoning-display.js +0 -46
- package/dist/ui/components/reasoning-display.js.map +0 -1
- package/dist/ui/components/status-bar.d.ts +0 -47
- package/dist/ui/components/status-bar.js +0 -310
- package/dist/ui/components/status-bar.js.map +0 -1
- package/dist/ui/components/subagent-monitor.d.ts +0 -41
- package/dist/ui/components/subagent-monitor.js +0 -122
- package/dist/ui/components/subagent-monitor.js.map +0 -1
- package/dist/ui/components/toast-notification.d.ts +0 -197
- package/dist/ui/components/toast-notification.js +0 -190
- package/dist/ui/components/toast-notification.js.map +0 -1
- package/dist/ui/components/tool-group-display.d.ts +0 -19
- package/dist/ui/components/tool-group-display.js +0 -222
- package/dist/ui/components/tool-group-display.js.map +0 -1
- package/dist/ui/components/virtualized-chat-history.d.ts +0 -33
- package/dist/ui/components/virtualized-chat-history.js +0 -182
- package/dist/ui/components/virtualized-chat-history.js.map +0 -1
- package/dist/ui/components/welcome-panel.d.ts +0 -11
- package/dist/ui/components/welcome-panel.js +0 -225
- package/dist/ui/components/welcome-panel.js.map +0 -1
- package/dist/ui/hooks/use-chat-reducer.d.ts +0 -69
- package/dist/ui/hooks/use-chat-reducer.js +0 -118
- package/dist/ui/hooks/use-chat-reducer.js.map +0 -1
- package/dist/ui/hooks/use-enhanced-input.d.ts +0 -53
- package/dist/ui/hooks/use-enhanced-input.js +0 -1275
- package/dist/ui/hooks/use-enhanced-input.js.map +0 -1
- package/dist/ui/hooks/use-input-handler.d.ts +0 -79
- package/dist/ui/hooks/use-input-handler.js +0 -2251
- package/dist/ui/hooks/use-input-handler.js.map +0 -1
- package/dist/ui/hooks/use-input-history.d.ts +0 -9
- package/dist/ui/hooks/use-input-history.js +0 -168
- package/dist/ui/hooks/use-input-history.js.map +0 -1
- package/dist/ui/shared/max-sized-box.d.ts +0 -17
- package/dist/ui/shared/max-sized-box.js +0 -14
- package/dist/ui/shared/max-sized-box.js.map +0 -1
- package/dist/ui/themes/index.d.ts +0 -5
- package/dist/ui/themes/index.js +0 -5
- package/dist/ui/themes/index.js.map +0 -1
- package/dist/ui/themes/theme-registry.d.ts +0 -55
- package/dist/ui/themes/theme-registry.js +0 -202
- package/dist/ui/themes/theme-registry.js.map +0 -1
- package/dist/ui/utils/bracketed-paste-handler.d.ts +0 -97
- package/dist/ui/utils/bracketed-paste-handler.js +0 -322
- package/dist/ui/utils/bracketed-paste-handler.js.map +0 -1
- package/dist/ui/utils/change-summarizer.d.ts +0 -20
- package/dist/ui/utils/change-summarizer.js +0 -282
- package/dist/ui/utils/change-summarizer.js.map +0 -1
- package/dist/ui/utils/code-colorizer.d.ts +0 -9
- package/dist/ui/utils/code-colorizer.js +0 -13
- package/dist/ui/utils/code-colorizer.js.map +0 -1
- package/dist/ui/utils/colors.d.ts +0 -41
- package/dist/ui/utils/colors.js +0 -80
- package/dist/ui/utils/colors.js.map +0 -1
- package/dist/ui/utils/image-handler.d.ts +0 -29
- package/dist/ui/utils/image-handler.js +0 -129
- package/dist/ui/utils/image-handler.js.map +0 -1
- package/dist/ui/utils/markdown-renderer.d.ts +0 -4
- package/dist/ui/utils/markdown-renderer.js +0 -40
- package/dist/ui/utils/markdown-renderer.js.map +0 -1
- package/dist/ui/utils/semantic-action-detector.d.ts +0 -49
- package/dist/ui/utils/semantic-action-detector.js +0 -339
- package/dist/ui/utils/semantic-action-detector.js.map +0 -1
- package/dist/ui/utils/tool-grouper.d.ts +0 -94
- package/dist/ui/utils/tool-grouper.js +0 -618
- package/dist/ui/utils/tool-grouper.js.map +0 -1
- package/dist/utils/api-error.d.ts +0 -61
- package/dist/utils/api-error.js +0 -176
- package/dist/utils/api-error.js.map +0 -1
- package/dist/utils/audit-logger.d.ts +0 -206
- package/dist/utils/audit-logger.js +0 -286
- package/dist/utils/audit-logger.js.map +0 -1
- package/dist/utils/auto-accept-logger.d.ts +0 -175
- package/dist/utils/auto-accept-logger.js +0 -423
- package/dist/utils/auto-accept-logger.js.map +0 -1
- package/dist/utils/automatosx-detector.d.ts +0 -19
- package/dist/utils/automatosx-detector.js +0 -52
- package/dist/utils/automatosx-detector.js.map +0 -1
- package/dist/utils/background-task-manager.d.ts +0 -114
- package/dist/utils/background-task-manager.js +0 -470
- package/dist/utils/background-task-manager.js.map +0 -1
- package/dist/utils/cache.d.ts +0 -77
- package/dist/utils/cache.js +0 -180
- package/dist/utils/cache.js.map +0 -1
- package/dist/utils/command-security.d.ts +0 -85
- package/dist/utils/command-security.js +0 -210
- package/dist/utils/command-security.js.map +0 -1
- package/dist/utils/config-loader.d.ts +0 -190
- package/dist/utils/config-loader.js +0 -108
- package/dist/utils/config-loader.js.map +0 -1
- package/dist/utils/confirmation-service.d.ts +0 -51
- package/dist/utils/confirmation-service.js +0 -220
- package/dist/utils/confirmation-service.js.map +0 -1
- package/dist/utils/console-messenger.d.ts +0 -80
- package/dist/utils/console-messenger.js +0 -142
- package/dist/utils/console-messenger.js.map +0 -1
- package/dist/utils/custom-instructions.d.ts +0 -1
- package/dist/utils/custom-instructions.js +0 -24
- package/dist/utils/custom-instructions.js.map +0 -1
- package/dist/utils/encryption.d.ts +0 -86
- package/dist/utils/encryption.js +0 -236
- package/dist/utils/encryption.js.map +0 -1
- package/dist/utils/enhanced-error-messages.d.ts +0 -33
- package/dist/utils/enhanced-error-messages.js +0 -440
- package/dist/utils/enhanced-error-messages.js.map +0 -1
- package/dist/utils/error-handler.d.ts +0 -65
- package/dist/utils/error-handler.js +0 -148
- package/dist/utils/error-handler.js.map +0 -1
- package/dist/utils/error-translator.d.ts +0 -25
- package/dist/utils/error-translator.js +0 -203
- package/dist/utils/error-translator.js.map +0 -1
- package/dist/utils/external-editor.d.ts +0 -47
- package/dist/utils/external-editor.js +0 -179
- package/dist/utils/external-editor.js.map +0 -1
- package/dist/utils/file-cache.d.ts +0 -148
- package/dist/utils/file-cache.js +0 -413
- package/dist/utils/file-cache.js.map +0 -1
- package/dist/utils/file-lock.d.ts +0 -141
- package/dist/utils/file-lock.js +0 -554
- package/dist/utils/file-lock.js.map +0 -1
- package/dist/utils/file-mentions.d.ts +0 -68
- package/dist/utils/file-mentions.js +0 -225
- package/dist/utils/file-mentions.js.map +0 -1
- package/dist/utils/history-manager.d.ts +0 -52
- package/dist/utils/history-manager.js +0 -211
- package/dist/utils/history-manager.js.map +0 -1
- package/dist/utils/history-migration.d.ts +0 -9
- package/dist/utils/history-migration.js +0 -37
- package/dist/utils/history-migration.js.map +0 -1
- package/dist/utils/image-processor.d.ts +0 -33
- package/dist/utils/image-processor.js +0 -124
- package/dist/utils/image-processor.js.map +0 -1
- package/dist/utils/index.d.ts +0 -92
- package/dist/utils/index.js +0 -111
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/init-previewer.d.ts +0 -56
- package/dist/utils/init-previewer.js +0 -239
- package/dist/utils/init-previewer.js.map +0 -1
- package/dist/utils/init-validator.d.ts +0 -65
- package/dist/utils/init-validator.js +0 -252
- package/dist/utils/init-validator.js.map +0 -1
- package/dist/utils/input-sanitizer.d.ts +0 -210
- package/dist/utils/input-sanitizer.js +0 -362
- package/dist/utils/input-sanitizer.js.map +0 -1
- package/dist/utils/instruction-generator.d.ts +0 -21
- package/dist/utils/instruction-generator.js +0 -233
- package/dist/utils/instruction-generator.js.map +0 -1
- package/dist/utils/json-utils.d.ts +0 -72
- package/dist/utils/json-utils.js +0 -226
- package/dist/utils/json-utils.js.map +0 -1
- package/dist/utils/llm-optimized-instruction-generator.d.ts +0 -36
- package/dist/utils/llm-optimized-instruction-generator.js +0 -365
- package/dist/utils/llm-optimized-instruction-generator.js.map +0 -1
- package/dist/utils/message-optimizer.d.ts +0 -100
- package/dist/utils/message-optimizer.js +0 -297
- package/dist/utils/message-optimizer.js.map +0 -1
- package/dist/utils/onboarding-manager.d.ts +0 -45
- package/dist/utils/onboarding-manager.js +0 -131
- package/dist/utils/onboarding-manager.js.map +0 -1
- package/dist/utils/parallel-analyzer.d.ts +0 -123
- package/dist/utils/parallel-analyzer.js +0 -241
- package/dist/utils/parallel-analyzer.js.map +0 -1
- package/dist/utils/paste-utils.d.ts +0 -99
- package/dist/utils/paste-utils.js +0 -295
- package/dist/utils/paste-utils.js.map +0 -1
- package/dist/utils/path-helpers.d.ts +0 -8
- package/dist/utils/path-helpers.js +0 -35
- package/dist/utils/path-helpers.js.map +0 -1
- package/dist/utils/path-security.d.ts +0 -92
- package/dist/utils/path-security.js +0 -300
- package/dist/utils/path-security.js.map +0 -1
- package/dist/utils/path-utils.d.ts +0 -83
- package/dist/utils/path-utils.js +0 -122
- package/dist/utils/path-utils.js.map +0 -1
- package/dist/utils/path-validator.d.ts +0 -66
- package/dist/utils/path-validator.js +0 -141
- package/dist/utils/path-validator.js.map +0 -1
- package/dist/utils/performance.d.ts +0 -74
- package/dist/utils/performance.js +0 -133
- package/dist/utils/performance.js.map +0 -1
- package/dist/utils/process-pool.d.ts +0 -109
- package/dist/utils/process-pool.js +0 -332
- package/dist/utils/process-pool.js.map +0 -1
- package/dist/utils/progress-tracker.d.ts +0 -51
- package/dist/utils/progress-tracker.js +0 -152
- package/dist/utils/progress-tracker.js.map +0 -1
- package/dist/utils/project-analyzer.d.ts +0 -49
- package/dist/utils/project-analyzer.js +0 -396
- package/dist/utils/project-analyzer.js.map +0 -1
- package/dist/utils/prompt-builder.d.ts +0 -14
- package/dist/utils/prompt-builder.js +0 -100
- package/dist/utils/prompt-builder.js.map +0 -1
- package/dist/utils/provider-context.d.ts +0 -243
- package/dist/utils/provider-context.js +0 -421
- package/dist/utils/provider-context.js.map +0 -1
- package/dist/utils/provider-file-cache.d.ts +0 -91
- package/dist/utils/provider-file-cache.js +0 -165
- package/dist/utils/provider-file-cache.js.map +0 -1
- package/dist/utils/provider-settings.d.ts +0 -181
- package/dist/utils/provider-settings.js +0 -450
- package/dist/utils/provider-settings.js.map +0 -1
- package/dist/utils/rate-limiter.d.ts +0 -222
- package/dist/utils/rate-limiter.js +0 -338
- package/dist/utils/rate-limiter.js.map +0 -1
- package/dist/utils/retry-helper.d.ts +0 -81
- package/dist/utils/retry-helper.js +0 -244
- package/dist/utils/retry-helper.js.map +0 -1
- package/dist/utils/safety-rules.d.ts +0 -64
- package/dist/utils/safety-rules.js +0 -225
- package/dist/utils/safety-rules.js.map +0 -1
- package/dist/utils/settings-manager.d.ts +0 -256
- package/dist/utils/settings-manager.js +0 -967
- package/dist/utils/settings-manager.js.map +0 -1
- package/dist/utils/setup-validator.d.ts +0 -47
- package/dist/utils/setup-validator.js +0 -304
- package/dist/utils/setup-validator.js.map +0 -1
- package/dist/utils/string-utils.d.ts +0 -19
- package/dist/utils/string-utils.js +0 -28
- package/dist/utils/string-utils.js.map +0 -1
- package/dist/utils/template-manager.d.ts +0 -62
- package/dist/utils/template-manager.js +0 -366
- package/dist/utils/template-manager.js.map +0 -1
- package/dist/utils/text-utils.d.ts +0 -82
- package/dist/utils/text-utils.js +0 -203
- package/dist/utils/text-utils.js.map +0 -1
- package/dist/utils/token-counter.d.ts +0 -76
- package/dist/utils/token-counter.js +0 -231
- package/dist/utils/token-counter.js.map +0 -1
- package/dist/utils/usage-tracker.d.ts +0 -78
- package/dist/utils/usage-tracker.js +0 -126
- package/dist/utils/usage-tracker.js.map +0 -1
- package/dist/utils/version.d.ts +0 -14
- package/dist/utils/version.js +0 -70
- package/dist/utils/version.js.map +0 -1
|
@@ -1,967 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, chmodSync } from "fs";
|
|
2
|
-
import { dirname } from "path";
|
|
3
|
-
import { UserSettingsSchema, ProjectSettingsSchema } from "../schemas/settings-schemas.js";
|
|
4
|
-
import { ModelIdSchema } from '@defai.digital/ax-schemas';
|
|
5
|
-
import { parseJsonFile, writeJsonFile } from "./json-utils.js";
|
|
6
|
-
import { encrypt, decrypt } from "./encryption.js";
|
|
7
|
-
import { extractErrorMessage } from "./error-handler.js";
|
|
8
|
-
import { CONFIG_PATHS, TIMEOUT_CONFIG } from "../constants.js";
|
|
9
|
-
/**
|
|
10
|
-
* Helper to get config with defaults
|
|
11
|
-
* Reduces repetition in getXxxConfig() methods
|
|
12
|
-
* Always returns a new object to prevent mutation of defaults
|
|
13
|
-
*/
|
|
14
|
-
function getConfigWithDefaults(userConfig, defaults) {
|
|
15
|
-
if (!userConfig) {
|
|
16
|
-
// Return a shallow copy to prevent mutation of the defaults object
|
|
17
|
-
return { ...defaults };
|
|
18
|
-
}
|
|
19
|
-
// Merge user config with defaults (user config takes precedence)
|
|
20
|
-
return Object.keys(defaults).reduce((result, key) => {
|
|
21
|
-
const k = key;
|
|
22
|
-
result[k] = userConfig[k] ?? defaults[k];
|
|
23
|
-
return result;
|
|
24
|
-
}, {});
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Default values for user settings
|
|
28
|
-
* Note: These are minimal defaults. Users should run 'ax-cli setup' to configure properly.
|
|
29
|
-
*/
|
|
30
|
-
const DEFAULT_USER_SETTINGS = {
|
|
31
|
-
// No hardcoded defaults - users must configure via setup command
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Default values for project settings
|
|
35
|
-
*/
|
|
36
|
-
const DEFAULT_PROJECT_SETTINGS = {
|
|
37
|
-
// Project settings inherit from user settings, no hardcoded defaults
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Unified settings manager that handles both user-level and project-level settings
|
|
41
|
-
*/
|
|
42
|
-
export class SettingsManager {
|
|
43
|
-
static instance;
|
|
44
|
-
userSettingsPath;
|
|
45
|
-
projectSettingsPath;
|
|
46
|
-
// Cache for settings to avoid repeated file I/O
|
|
47
|
-
userSettingsCache = null;
|
|
48
|
-
projectSettingsCache = null;
|
|
49
|
-
cacheTimestamp = {
|
|
50
|
-
user: 0,
|
|
51
|
-
project: 0
|
|
52
|
-
};
|
|
53
|
-
CACHE_TTL = TIMEOUT_CONFIG.SETTINGS_CACHE_TTL;
|
|
54
|
-
constructor() {
|
|
55
|
-
// User settings path: ~/.ax-cli/config.json
|
|
56
|
-
this.userSettingsPath = CONFIG_PATHS.USER_CONFIG;
|
|
57
|
-
// Project settings path: .ax-cli/settings.json
|
|
58
|
-
this.projectSettingsPath = CONFIG_PATHS.PROJECT_SETTINGS;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Get singleton instance
|
|
62
|
-
*/
|
|
63
|
-
static getInstance() {
|
|
64
|
-
if (!SettingsManager.instance) {
|
|
65
|
-
SettingsManager.instance = new SettingsManager();
|
|
66
|
-
}
|
|
67
|
-
return SettingsManager.instance;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Ensure directory exists for a given file path
|
|
71
|
-
*/
|
|
72
|
-
ensureDirectoryExists(filePath) {
|
|
73
|
-
const dir = dirname(filePath);
|
|
74
|
-
if (!existsSync(dir)) {
|
|
75
|
-
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Load user settings from ~/.ax-cli/config.json
|
|
80
|
-
*/
|
|
81
|
-
loadUserSettings() {
|
|
82
|
-
// Check cache first
|
|
83
|
-
const now = Date.now();
|
|
84
|
-
if (this.userSettingsCache && (now - this.cacheTimestamp.user) < this.CACHE_TTL) {
|
|
85
|
-
return this.userSettingsCache;
|
|
86
|
-
}
|
|
87
|
-
try {
|
|
88
|
-
if (!existsSync(this.userSettingsPath)) {
|
|
89
|
-
// Create default user settings if file doesn't exist
|
|
90
|
-
this.saveUserSettings(DEFAULT_USER_SETTINGS);
|
|
91
|
-
const defaultSettings = { ...DEFAULT_USER_SETTINGS };
|
|
92
|
-
// Update cache after creating file
|
|
93
|
-
this.userSettingsCache = defaultSettings;
|
|
94
|
-
this.cacheTimestamp.user = Date.now();
|
|
95
|
-
return defaultSettings;
|
|
96
|
-
}
|
|
97
|
-
// Use json-utils for consistent JSON handling
|
|
98
|
-
const parseResult = parseJsonFile(this.userSettingsPath, UserSettingsSchema);
|
|
99
|
-
if (!parseResult.success) {
|
|
100
|
-
console.warn("Failed to load user settings:", parseResult.error);
|
|
101
|
-
const defaultSettings = { ...DEFAULT_USER_SETTINGS };
|
|
102
|
-
// Cache defaults even on parse failure to avoid repeated file reads
|
|
103
|
-
this.userSettingsCache = defaultSettings;
|
|
104
|
-
this.cacheTimestamp.user = Date.now();
|
|
105
|
-
return defaultSettings;
|
|
106
|
-
}
|
|
107
|
-
// REQ-SEC-003: Handle API key encryption migration
|
|
108
|
-
// Priority: apiKeyEncrypted > apiKey (plain-text)
|
|
109
|
-
let decryptedApiKey;
|
|
110
|
-
if (parseResult.data.apiKeyEncrypted) {
|
|
111
|
-
// Already encrypted - decrypt it
|
|
112
|
-
try {
|
|
113
|
-
decryptedApiKey = decrypt(parseResult.data.apiKeyEncrypted);
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
console.error('Failed to decrypt API key:', error instanceof Error ? error.message : 'Unknown error');
|
|
117
|
-
// Fall back to plain-text if decryption fails
|
|
118
|
-
if (parseResult.data.apiKey && typeof parseResult.data.apiKey === 'string') {
|
|
119
|
-
decryptedApiKey = parseResult.data.apiKey;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
else if (parseResult.data.apiKey && typeof parseResult.data.apiKey === 'string') {
|
|
124
|
-
// Plain-text API key found - needs migration
|
|
125
|
-
decryptedApiKey = parseResult.data.apiKey;
|
|
126
|
-
// Migrate to encrypted format
|
|
127
|
-
console.log('🔒 Detected plain-text API key - migrating to encrypted format...');
|
|
128
|
-
try {
|
|
129
|
-
if (!decryptedApiKey) {
|
|
130
|
-
throw new Error('API key is empty');
|
|
131
|
-
}
|
|
132
|
-
const encrypted = encrypt(decryptedApiKey);
|
|
133
|
-
// Update the config file: add apiKeyEncrypted, remove apiKey
|
|
134
|
-
const migratedConfig = {
|
|
135
|
-
...parseResult.data,
|
|
136
|
-
apiKeyEncrypted: encrypted,
|
|
137
|
-
apiKey: undefined, // Clear plain-text field
|
|
138
|
-
};
|
|
139
|
-
// Save the migrated config
|
|
140
|
-
const writeResult = writeJsonFile(this.userSettingsPath, migratedConfig, UserSettingsSchema, true // pretty
|
|
141
|
-
);
|
|
142
|
-
if (writeResult.success) {
|
|
143
|
-
console.log('✅ API key encrypted and saved successfully');
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
console.warn('⚠️ Failed to save encrypted API key:', writeResult.error);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
catch (error) {
|
|
150
|
-
console.warn('⚠️ Failed to encrypt API key:', error instanceof Error ? error.message : 'Unknown error');
|
|
151
|
-
// Continue with plain-text for now, will retry on next load
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
// Build settings object with decrypted API key
|
|
155
|
-
const settings = {
|
|
156
|
-
...DEFAULT_USER_SETTINGS,
|
|
157
|
-
...parseResult.data,
|
|
158
|
-
apiKey: decryptedApiKey, // Always use decrypted value in memory
|
|
159
|
-
apiKeyEncrypted: undefined, // Don't keep encrypted version in memory
|
|
160
|
-
};
|
|
161
|
-
this.userSettingsCache = settings;
|
|
162
|
-
this.cacheTimestamp.user = Date.now();
|
|
163
|
-
return settings;
|
|
164
|
-
}
|
|
165
|
-
catch (error) {
|
|
166
|
-
console.warn("Failed to load user settings:", error instanceof Error ? error.message : "Unknown error");
|
|
167
|
-
const defaultSettings = { ...DEFAULT_USER_SETTINGS };
|
|
168
|
-
this.userSettingsCache = defaultSettings;
|
|
169
|
-
this.cacheTimestamp.user = Date.now();
|
|
170
|
-
return defaultSettings;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Save user settings to ~/.ax-cli/config.json
|
|
175
|
-
*/
|
|
176
|
-
saveUserSettings(settings) {
|
|
177
|
-
try {
|
|
178
|
-
this.ensureDirectoryExists(this.userSettingsPath);
|
|
179
|
-
// Read existing settings directly to avoid recursion
|
|
180
|
-
let existingSettings = { ...DEFAULT_USER_SETTINGS };
|
|
181
|
-
if (existsSync(this.userSettingsPath)) {
|
|
182
|
-
const parseResult = parseJsonFile(this.userSettingsPath);
|
|
183
|
-
if (parseResult.success) {
|
|
184
|
-
// Decrypt API key if encrypted, but only if caller isn't providing a new one
|
|
185
|
-
// If caller provides new apiKey, we don't need to preserve the old one
|
|
186
|
-
let apiKey;
|
|
187
|
-
if (settings.apiKey) {
|
|
188
|
-
// Caller is providing a new API key - use that instead of old one
|
|
189
|
-
apiKey = undefined; // Will be overwritten by settings.apiKey in merge
|
|
190
|
-
}
|
|
191
|
-
else if (parseResult.data.apiKeyEncrypted) {
|
|
192
|
-
try {
|
|
193
|
-
apiKey = decrypt(parseResult.data.apiKeyEncrypted);
|
|
194
|
-
}
|
|
195
|
-
catch (error) {
|
|
196
|
-
// CRITICAL: Don't continue if we can't decrypt existing data - fail fast to prevent data loss
|
|
197
|
-
throw new Error(`Cannot save settings: failed to decrypt existing API key. This would result in data loss. ${extractErrorMessage(error)}`);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
else if (parseResult.data.apiKey) {
|
|
201
|
-
apiKey = parseResult.data.apiKey;
|
|
202
|
-
}
|
|
203
|
-
existingSettings = {
|
|
204
|
-
...DEFAULT_USER_SETTINGS,
|
|
205
|
-
...parseResult.data,
|
|
206
|
-
apiKey, // Use decrypted value (or undefined if caller provides new key)
|
|
207
|
-
apiKeyEncrypted: undefined, // Don't keep encrypted in memory
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
// If file is corrupted, throw error instead of silently discarding user data
|
|
212
|
-
throw new Error(`Cannot save settings: existing file is corrupted. ${parseResult.error || 'Unknown parse error'}`);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
const mergedSettings = { ...existingSettings, ...settings };
|
|
216
|
-
// REQ-SEC-003: Encrypt API key into apiKeyEncrypted field
|
|
217
|
-
const settingsToSave = { ...mergedSettings };
|
|
218
|
-
if (settingsToSave.apiKey) {
|
|
219
|
-
// Encrypt the API key
|
|
220
|
-
settingsToSave.apiKeyEncrypted = encrypt(settingsToSave.apiKey);
|
|
221
|
-
// Clear the plain-text field
|
|
222
|
-
delete settingsToSave.apiKey;
|
|
223
|
-
}
|
|
224
|
-
// Use json-utils for consistent writing with schema validation
|
|
225
|
-
const writeResult = writeJsonFile(this.userSettingsPath, settingsToSave, UserSettingsSchema, // validate before writing
|
|
226
|
-
true // pretty
|
|
227
|
-
);
|
|
228
|
-
if (!writeResult.success) {
|
|
229
|
-
throw new Error(`Failed to write settings: ${writeResult.error}`);
|
|
230
|
-
}
|
|
231
|
-
// Set secure permissions for API key
|
|
232
|
-
chmodSync(this.userSettingsPath, 0o600);
|
|
233
|
-
// Update cache with new settings instead of invalidating
|
|
234
|
-
// This improves performance and prevents race conditions
|
|
235
|
-
this.userSettingsCache = mergedSettings;
|
|
236
|
-
this.cacheTimestamp.user = Date.now();
|
|
237
|
-
}
|
|
238
|
-
catch (error) {
|
|
239
|
-
console.error("Failed to save user settings:", error instanceof Error ? error.message : "Unknown error");
|
|
240
|
-
throw error;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Update a specific user setting
|
|
245
|
-
*/
|
|
246
|
-
updateUserSetting(key, value) {
|
|
247
|
-
const settings = { [key]: value };
|
|
248
|
-
this.saveUserSettings(settings);
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Get a specific user setting
|
|
252
|
-
*/
|
|
253
|
-
getUserSetting(key) {
|
|
254
|
-
const settings = this.loadUserSettings();
|
|
255
|
-
return settings[key];
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Load project settings from .ax-cli/settings.json
|
|
259
|
-
*/
|
|
260
|
-
loadProjectSettings() {
|
|
261
|
-
// Check cache first
|
|
262
|
-
const now = Date.now();
|
|
263
|
-
if (this.projectSettingsCache && (now - this.cacheTimestamp.project) < this.CACHE_TTL) {
|
|
264
|
-
return this.projectSettingsCache;
|
|
265
|
-
}
|
|
266
|
-
try {
|
|
267
|
-
if (!existsSync(this.projectSettingsPath)) {
|
|
268
|
-
// Create default project settings if file doesn't exist
|
|
269
|
-
this.saveProjectSettings(DEFAULT_PROJECT_SETTINGS);
|
|
270
|
-
const defaultSettings = { ...DEFAULT_PROJECT_SETTINGS };
|
|
271
|
-
// Update cache after creating file
|
|
272
|
-
this.projectSettingsCache = defaultSettings;
|
|
273
|
-
this.cacheTimestamp.project = Date.now();
|
|
274
|
-
return defaultSettings;
|
|
275
|
-
}
|
|
276
|
-
// Use json-utils for consistent JSON handling
|
|
277
|
-
const parseResult = parseJsonFile(this.projectSettingsPath, ProjectSettingsSchema);
|
|
278
|
-
if (!parseResult.success) {
|
|
279
|
-
console.warn("Failed to load project settings:", parseResult.error);
|
|
280
|
-
const defaultSettings = { ...DEFAULT_PROJECT_SETTINGS };
|
|
281
|
-
// Cache defaults even on parse failure to avoid repeated file reads
|
|
282
|
-
this.projectSettingsCache = defaultSettings;
|
|
283
|
-
this.cacheTimestamp.project = Date.now();
|
|
284
|
-
return defaultSettings;
|
|
285
|
-
}
|
|
286
|
-
// Merge with defaults
|
|
287
|
-
const settings = { ...DEFAULT_PROJECT_SETTINGS, ...parseResult.data };
|
|
288
|
-
this.projectSettingsCache = settings;
|
|
289
|
-
this.cacheTimestamp.project = Date.now();
|
|
290
|
-
return settings;
|
|
291
|
-
}
|
|
292
|
-
catch (error) {
|
|
293
|
-
console.warn("Failed to load project settings:", error instanceof Error ? error.message : "Unknown error");
|
|
294
|
-
const defaultSettings = { ...DEFAULT_PROJECT_SETTINGS };
|
|
295
|
-
this.projectSettingsCache = defaultSettings;
|
|
296
|
-
this.cacheTimestamp.project = Date.now();
|
|
297
|
-
return defaultSettings;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Save project settings to .ax-cli/settings.json
|
|
302
|
-
*/
|
|
303
|
-
saveProjectSettings(settings) {
|
|
304
|
-
try {
|
|
305
|
-
this.ensureDirectoryExists(this.projectSettingsPath);
|
|
306
|
-
// Read existing settings directly to avoid recursion
|
|
307
|
-
let existingSettings = { ...DEFAULT_PROJECT_SETTINGS };
|
|
308
|
-
if (existsSync(this.projectSettingsPath)) {
|
|
309
|
-
const parseResult = parseJsonFile(this.projectSettingsPath);
|
|
310
|
-
if (parseResult.success) {
|
|
311
|
-
existingSettings = { ...DEFAULT_PROJECT_SETTINGS, ...parseResult.data };
|
|
312
|
-
}
|
|
313
|
-
else {
|
|
314
|
-
// BUG FIX: Throw error on corruption instead of silently discarding data
|
|
315
|
-
// This is consistent with saveUserSettings behavior and prevents data loss
|
|
316
|
-
throw new Error(`Cannot save settings: existing project settings file is corrupted. ${parseResult.error || 'Unknown parse error'}`);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
const mergedSettings = { ...existingSettings, ...settings };
|
|
320
|
-
// Use json-utils for consistent writing with schema validation
|
|
321
|
-
const writeResult = writeJsonFile(this.projectSettingsPath, mergedSettings, ProjectSettingsSchema, // validate before writing
|
|
322
|
-
true // pretty
|
|
323
|
-
);
|
|
324
|
-
if (!writeResult.success) {
|
|
325
|
-
throw new Error(`Failed to write settings: ${writeResult.error}`);
|
|
326
|
-
}
|
|
327
|
-
// Update cache with new settings instead of invalidating
|
|
328
|
-
// This improves performance and prevents race conditions
|
|
329
|
-
this.projectSettingsCache = mergedSettings;
|
|
330
|
-
this.cacheTimestamp.project = Date.now();
|
|
331
|
-
}
|
|
332
|
-
catch (error) {
|
|
333
|
-
console.error("Failed to save project settings:", error instanceof Error ? error.message : "Unknown error");
|
|
334
|
-
throw error;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Update a specific project setting
|
|
339
|
-
*/
|
|
340
|
-
updateProjectSetting(key, value) {
|
|
341
|
-
const settings = { [key]: value };
|
|
342
|
-
this.saveProjectSettings(settings);
|
|
343
|
-
}
|
|
344
|
-
/**
|
|
345
|
-
* Get a specific project setting
|
|
346
|
-
*/
|
|
347
|
-
getProjectSetting(key) {
|
|
348
|
-
const settings = this.loadProjectSettings();
|
|
349
|
-
return settings[key];
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* Phase 3: Get paste settings with proper defaults
|
|
353
|
-
* Priority: Project settings > User settings > Schema defaults
|
|
354
|
-
* v3.8.0: Now includes bracketed paste mode settings
|
|
355
|
-
*/
|
|
356
|
-
getPasteSettings() {
|
|
357
|
-
const userPaste = this.getUserSetting("paste");
|
|
358
|
-
const projectPaste = this.getProjectSetting("paste");
|
|
359
|
-
const merged = { ...(userPaste || {}), ...(projectPaste || {}) };
|
|
360
|
-
return {
|
|
361
|
-
allowLargePaste: merged.allowLargePaste ?? true, // Changed to true - allow large pastes by default
|
|
362
|
-
maxPasteLength: merged.maxPasteLength ?? 50000, // Increased from 5000 to 50000
|
|
363
|
-
warningThreshold: merged.warningThreshold ?? 10000, // Increased from 1000 to 10000
|
|
364
|
-
// v3.8.0: Bracketed paste mode settings
|
|
365
|
-
enableBracketedPaste: merged.enableBracketedPaste ?? true,
|
|
366
|
-
showPasteIndicator: merged.showPasteIndicator ?? true,
|
|
367
|
-
maxPasteSize: merged.maxPasteSize ?? (100 * 1024 * 1024),
|
|
368
|
-
pasteTimeout: merged.pasteTimeout ?? 30000,
|
|
369
|
-
enableFallback: merged.enableFallback ?? true,
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
/**
|
|
373
|
-
* Get the current model with proper fallback logic:
|
|
374
|
-
* 1. Project-specific model setting
|
|
375
|
-
* 2. User's default model
|
|
376
|
-
* 3. Undefined (user must configure)
|
|
377
|
-
*/
|
|
378
|
-
getCurrentModel() {
|
|
379
|
-
const projectModel = this.getProjectSetting("model");
|
|
380
|
-
if (projectModel) {
|
|
381
|
-
return projectModel;
|
|
382
|
-
}
|
|
383
|
-
const userDefaultModel = this.getUserSetting("defaultModel");
|
|
384
|
-
if (userDefaultModel) {
|
|
385
|
-
return userDefaultModel;
|
|
386
|
-
}
|
|
387
|
-
return undefined; // No hardcoded fallback - user must run setup
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Set the current model for the project
|
|
391
|
-
*/
|
|
392
|
-
setCurrentModel(model) {
|
|
393
|
-
const result = ModelIdSchema.safeParse(model);
|
|
394
|
-
if (!result.success) {
|
|
395
|
-
throw new Error(`Invalid model ID: ${model}. ${result.error.message}`);
|
|
396
|
-
}
|
|
397
|
-
this.updateProjectSetting("model", result.data);
|
|
398
|
-
}
|
|
399
|
-
/**
|
|
400
|
-
* Get available models list from user settings
|
|
401
|
-
*/
|
|
402
|
-
getAvailableModels() {
|
|
403
|
-
const models = this.getUserSetting("models");
|
|
404
|
-
return models || [];
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* Get API key from user settings or environment
|
|
408
|
-
*/
|
|
409
|
-
getApiKey() {
|
|
410
|
-
// First check environment variable
|
|
411
|
-
const envApiKey = process.env.YOUR_API_KEY ||
|
|
412
|
-
process.env.AI_API_KEY ||
|
|
413
|
-
process.env.Z_AI_API_KEY ||
|
|
414
|
-
process.env.GLM_API_KEY;
|
|
415
|
-
if (envApiKey) {
|
|
416
|
-
return envApiKey;
|
|
417
|
-
}
|
|
418
|
-
// Then check user settings
|
|
419
|
-
return this.getUserSetting("apiKey");
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* Get base URL from user settings or environment
|
|
423
|
-
*/
|
|
424
|
-
getBaseURL() {
|
|
425
|
-
// First check environment variable
|
|
426
|
-
const envBaseURL = process.env.AI_BASE_URL;
|
|
427
|
-
if (envBaseURL) {
|
|
428
|
-
return envBaseURL;
|
|
429
|
-
}
|
|
430
|
-
// Then check user settings
|
|
431
|
-
const userBaseURL = this.getUserSetting("baseURL");
|
|
432
|
-
return userBaseURL; // No hardcoded fallback - user must run setup
|
|
433
|
-
}
|
|
434
|
-
/**
|
|
435
|
-
* Get sampling settings with proper fallback logic:
|
|
436
|
-
* 1. Environment variables (AI_DO_SAMPLE, AI_SEED, AI_TOP_P)
|
|
437
|
-
* 2. Project-specific sampling settings
|
|
438
|
-
* 3. User's default sampling settings
|
|
439
|
-
* 4. Undefined (default behavior - sampling enabled)
|
|
440
|
-
*
|
|
441
|
-
* @returns Merged sampling settings or undefined for default behavior
|
|
442
|
-
*/
|
|
443
|
-
getSamplingSettings() {
|
|
444
|
-
// Start with user settings as base
|
|
445
|
-
const userSampling = this.getUserSetting("sampling");
|
|
446
|
-
const projectSampling = this.getProjectSetting("sampling");
|
|
447
|
-
// Merge project settings over user settings
|
|
448
|
-
const baseSampling = { ...(userSampling || {}), ...(projectSampling || {}) };
|
|
449
|
-
// Environment variables take highest priority
|
|
450
|
-
const envDoSample = process.env.AI_DO_SAMPLE;
|
|
451
|
-
const envSeed = process.env.AI_SEED;
|
|
452
|
-
const envTopP = process.env.AI_TOP_P;
|
|
453
|
-
const result = { ...baseSampling };
|
|
454
|
-
if (envDoSample !== undefined) {
|
|
455
|
-
result.doSample = envDoSample.toLowerCase() === "true";
|
|
456
|
-
}
|
|
457
|
-
if (envSeed !== undefined) {
|
|
458
|
-
const seedNum = parseInt(envSeed, 10);
|
|
459
|
-
if (Number.isFinite(seedNum) && seedNum >= 0) {
|
|
460
|
-
result.seed = seedNum;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
if (envTopP !== undefined) {
|
|
464
|
-
const topPNum = parseFloat(envTopP);
|
|
465
|
-
if (Number.isFinite(topPNum) && topPNum >= 0 && topPNum <= 1) {
|
|
466
|
-
result.topP = topPNum;
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
// Return undefined if no settings were configured (use defaults)
|
|
470
|
-
if (Object.keys(result).length === 0) {
|
|
471
|
-
return undefined;
|
|
472
|
-
}
|
|
473
|
-
return result;
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
* Check if deterministic mode is enabled
|
|
477
|
-
* Returns true if do_sample is explicitly set to false
|
|
478
|
-
*/
|
|
479
|
-
isDeterministicMode() {
|
|
480
|
-
const sampling = this.getSamplingSettings();
|
|
481
|
-
return sampling?.doSample === false;
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* Get thinking settings with proper fallback logic:
|
|
485
|
-
* 1. Environment variable (AI_THINK)
|
|
486
|
-
* 2. Project-specific thinking settings
|
|
487
|
-
* 3. User's default thinking settings
|
|
488
|
-
* 4. Undefined (default behavior - thinking disabled)
|
|
489
|
-
*
|
|
490
|
-
* @returns Thinking settings or undefined for default behavior
|
|
491
|
-
*/
|
|
492
|
-
getThinkingSettings() {
|
|
493
|
-
// Start with user settings as base
|
|
494
|
-
const userThinking = this.getUserSetting("thinking");
|
|
495
|
-
const projectThinking = this.getProjectSetting("thinking");
|
|
496
|
-
// Merge project settings over user settings
|
|
497
|
-
const baseThinking = { ...(userThinking || {}), ...(projectThinking || {}) };
|
|
498
|
-
// Environment variable takes highest priority
|
|
499
|
-
const envThink = process.env.AI_THINK;
|
|
500
|
-
const result = { ...baseThinking };
|
|
501
|
-
if (envThink !== undefined) {
|
|
502
|
-
result.enabled = envThink.toLowerCase() === "true";
|
|
503
|
-
}
|
|
504
|
-
// Return undefined if no settings were configured (use defaults)
|
|
505
|
-
if (Object.keys(result).length === 0) {
|
|
506
|
-
return undefined;
|
|
507
|
-
}
|
|
508
|
-
return result;
|
|
509
|
-
}
|
|
510
|
-
/**
|
|
511
|
-
* Get merged agent-first settings with priority:
|
|
512
|
-
* 1. Project settings (highest priority)
|
|
513
|
-
* 2. User settings
|
|
514
|
-
* 3. Defaults (enabled: true, confidenceThreshold: 0.6)
|
|
515
|
-
*/
|
|
516
|
-
getAgentFirstSettings() {
|
|
517
|
-
const userSettings = this.getUserSetting("agentFirst");
|
|
518
|
-
const projectSettings = this.getProjectSetting("agentFirst");
|
|
519
|
-
// Merge with project settings taking priority
|
|
520
|
-
const merged = { ...(userSettings || {}), ...(projectSettings || {}) };
|
|
521
|
-
return {
|
|
522
|
-
enabled: merged.enabled ?? true,
|
|
523
|
-
confidenceThreshold: merged.confidenceThreshold ?? 0.6,
|
|
524
|
-
showAgentIndicator: merged.showAgentIndicator ?? true,
|
|
525
|
-
defaultAgent: merged.defaultAgent ?? 'standard',
|
|
526
|
-
excludedAgents: merged.excludedAgents ?? [],
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
|
-
/**
|
|
530
|
-
* Get the actual user settings path being used
|
|
531
|
-
*/
|
|
532
|
-
getUserSettingsPath() {
|
|
533
|
-
return this.userSettingsPath;
|
|
534
|
-
}
|
|
535
|
-
/**
|
|
536
|
-
* Get the actual project settings path being used
|
|
537
|
-
*/
|
|
538
|
-
getProjectSettingsPath() {
|
|
539
|
-
return this.projectSettingsPath;
|
|
540
|
-
}
|
|
541
|
-
// ==================== Phase 1: Input Configuration ====================
|
|
542
|
-
/**
|
|
543
|
-
* Get input configuration with proper defaults
|
|
544
|
-
* Priority: User settings > Schema defaults
|
|
545
|
-
*/
|
|
546
|
-
getInputConfig() {
|
|
547
|
-
const userSettings = this.loadUserSettings();
|
|
548
|
-
// Return schema defaults if no user config exists
|
|
549
|
-
// FIX: Using 'submit' mode - Enter submits, Shift+Enter inserts newline
|
|
550
|
-
// This is simpler and more reliable than smart mode
|
|
551
|
-
if (!userSettings.input) {
|
|
552
|
-
return {
|
|
553
|
-
enterBehavior: 'submit',
|
|
554
|
-
submitKeys: ['enter'],
|
|
555
|
-
multilineIndicator: '│ ',
|
|
556
|
-
smartDetection: {
|
|
557
|
-
enabled: true,
|
|
558
|
-
checkBrackets: true,
|
|
559
|
-
checkOperators: true,
|
|
560
|
-
checkStatements: true,
|
|
561
|
-
},
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
// Merge user config with defaults
|
|
565
|
-
return {
|
|
566
|
-
enterBehavior: userSettings.input.enterBehavior || 'submit',
|
|
567
|
-
submitKeys: userSettings.input.submitKeys || ['enter'],
|
|
568
|
-
multilineIndicator: userSettings.input.multilineIndicator || '│ ',
|
|
569
|
-
smartDetection: {
|
|
570
|
-
enabled: userSettings.input.smartDetection?.enabled ?? true,
|
|
571
|
-
checkBrackets: userSettings.input.smartDetection?.checkBrackets ?? true,
|
|
572
|
-
checkOperators: userSettings.input.smartDetection?.checkOperators ?? true,
|
|
573
|
-
checkStatements: userSettings.input.smartDetection?.checkStatements ?? true,
|
|
574
|
-
},
|
|
575
|
-
};
|
|
576
|
-
}
|
|
577
|
-
/**
|
|
578
|
-
* Update input configuration
|
|
579
|
-
* Merges with existing config and saves to user settings
|
|
580
|
-
*/
|
|
581
|
-
updateInputConfig(config) {
|
|
582
|
-
const userSettings = this.loadUserSettings();
|
|
583
|
-
const currentConfig = this.getInputConfig();
|
|
584
|
-
// Deep merge for nested smartDetection object
|
|
585
|
-
// BUG FIX: Use optional chaining instead of non-null assertion on Partial<T> parameter
|
|
586
|
-
const currentSmart = currentConfig?.smartDetection ?? {};
|
|
587
|
-
const configSmart = config?.smartDetection;
|
|
588
|
-
// Spread operator handles the merge cleanly
|
|
589
|
-
const newConfig = {
|
|
590
|
-
...currentConfig,
|
|
591
|
-
...config,
|
|
592
|
-
smartDetection: configSmart ? { ...currentSmart, ...configSmart } : currentSmart,
|
|
593
|
-
};
|
|
594
|
-
this.saveUserSettings({ ...userSettings, input: newConfig });
|
|
595
|
-
}
|
|
596
|
-
// ==================== Phase 1: Shortcuts Configuration ====================
|
|
597
|
-
/**
|
|
598
|
-
* Get shortcuts configuration with proper defaults
|
|
599
|
-
* Priority: User settings > Schema defaults
|
|
600
|
-
*/
|
|
601
|
-
getShortcutsConfig() {
|
|
602
|
-
const userSettings = this.loadUserSettings();
|
|
603
|
-
// Return schema defaults if no user config exists
|
|
604
|
-
if (!userSettings.shortcuts) {
|
|
605
|
-
return {
|
|
606
|
-
showOnStartup: false,
|
|
607
|
-
hintTimeout: 3000,
|
|
608
|
-
customBindings: {},
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
// Merge user config with defaults
|
|
612
|
-
return {
|
|
613
|
-
showOnStartup: userSettings.shortcuts.showOnStartup ?? false,
|
|
614
|
-
hintTimeout: userSettings.shortcuts.hintTimeout ?? 3000,
|
|
615
|
-
customBindings: userSettings.shortcuts.customBindings || {},
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
|
-
/**
|
|
619
|
-
* Update shortcuts configuration
|
|
620
|
-
* Merges with existing config and saves to user settings
|
|
621
|
-
*/
|
|
622
|
-
updateShortcutsConfig(config) {
|
|
623
|
-
const userSettings = this.loadUserSettings();
|
|
624
|
-
const currentConfig = this.getShortcutsConfig();
|
|
625
|
-
// Deep merge for nested customBindings object
|
|
626
|
-
// getShortcutsConfig() always returns a valid config with customBindings
|
|
627
|
-
const currentBindings = currentConfig?.customBindings ?? {};
|
|
628
|
-
const configBindings = config?.customBindings;
|
|
629
|
-
// Spread operator handles the merge cleanly
|
|
630
|
-
const newConfig = {
|
|
631
|
-
...currentConfig,
|
|
632
|
-
...config,
|
|
633
|
-
customBindings: configBindings ? { ...currentBindings, ...configBindings } : currentBindings,
|
|
634
|
-
};
|
|
635
|
-
this.saveUserSettings({ ...userSettings, shortcuts: newConfig });
|
|
636
|
-
}
|
|
637
|
-
// ==================== Phase 1: Paste Configuration ====================
|
|
638
|
-
/**
|
|
639
|
-
* Get paste configuration with proper defaults
|
|
640
|
-
* Priority: User settings > Schema defaults
|
|
641
|
-
*/
|
|
642
|
-
getPasteConfig() {
|
|
643
|
-
const userSettings = this.loadUserSettings();
|
|
644
|
-
// Return schema defaults if no user config exists
|
|
645
|
-
if (!userSettings.paste) {
|
|
646
|
-
return {
|
|
647
|
-
autoCollapse: true,
|
|
648
|
-
collapseThreshold: 20,
|
|
649
|
-
characterThreshold: 500,
|
|
650
|
-
maxCollapsedBlocks: 50,
|
|
651
|
-
showLineCount: true,
|
|
652
|
-
showPreview: true,
|
|
653
|
-
previewLines: 2,
|
|
654
|
-
enableHistory: true,
|
|
655
|
-
maxHistoryItems: 10,
|
|
656
|
-
// v3.8.0: Bracketed paste mode settings
|
|
657
|
-
enableBracketedPaste: true,
|
|
658
|
-
showPasteIndicator: true,
|
|
659
|
-
maxPasteSize: 100 * 1024 * 1024, // 100MB
|
|
660
|
-
pasteTimeout: 30000, // 30 seconds
|
|
661
|
-
enableFallback: true,
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
// Merge user config with defaults
|
|
665
|
-
return {
|
|
666
|
-
autoCollapse: userSettings.paste.autoCollapse ?? true,
|
|
667
|
-
collapseThreshold: userSettings.paste.collapseThreshold ?? 20,
|
|
668
|
-
characterThreshold: userSettings.paste.characterThreshold ?? 500,
|
|
669
|
-
maxCollapsedBlocks: userSettings.paste.maxCollapsedBlocks ?? 50,
|
|
670
|
-
showLineCount: userSettings.paste.showLineCount ?? true,
|
|
671
|
-
showPreview: userSettings.paste.showPreview ?? true,
|
|
672
|
-
previewLines: userSettings.paste.previewLines ?? 2,
|
|
673
|
-
enableHistory: userSettings.paste.enableHistory ?? true,
|
|
674
|
-
maxHistoryItems: userSettings.paste.maxHistoryItems ?? 10,
|
|
675
|
-
// v3.8.0: Bracketed paste mode settings
|
|
676
|
-
enableBracketedPaste: userSettings.paste.enableBracketedPaste ?? true,
|
|
677
|
-
showPasteIndicator: userSettings.paste.showPasteIndicator ?? true,
|
|
678
|
-
maxPasteSize: userSettings.paste.maxPasteSize ?? (100 * 1024 * 1024),
|
|
679
|
-
pasteTimeout: userSettings.paste.pasteTimeout ?? 30000,
|
|
680
|
-
enableFallback: userSettings.paste.enableFallback ?? true,
|
|
681
|
-
};
|
|
682
|
-
}
|
|
683
|
-
/**
|
|
684
|
-
* Update paste configuration
|
|
685
|
-
* Merges with existing config and saves to user settings
|
|
686
|
-
*/
|
|
687
|
-
updatePasteConfig(config) {
|
|
688
|
-
const userSettings = this.loadUserSettings();
|
|
689
|
-
const currentConfig = this.getPasteConfig();
|
|
690
|
-
// Spread operator handles the merge cleanly
|
|
691
|
-
const newConfig = {
|
|
692
|
-
...currentConfig,
|
|
693
|
-
...config,
|
|
694
|
-
};
|
|
695
|
-
this.saveUserSettings({ ...userSettings, paste: newConfig });
|
|
696
|
-
}
|
|
697
|
-
// ==================== UI Configuration (Theme, Verbosity, etc.) ====================
|
|
698
|
-
/** Default UI configuration */
|
|
699
|
-
static UI_DEFAULTS = {
|
|
700
|
-
verbosityLevel: 'quiet',
|
|
701
|
-
groupToolCalls: true,
|
|
702
|
-
maxGroupSize: 20,
|
|
703
|
-
groupTimeWindow: 500,
|
|
704
|
-
theme: 'default',
|
|
705
|
-
};
|
|
706
|
-
/**
|
|
707
|
-
* Get UI configuration with proper defaults
|
|
708
|
-
* Priority: User settings > Schema defaults
|
|
709
|
-
*/
|
|
710
|
-
getUIConfig() {
|
|
711
|
-
const userSettings = this.loadUserSettings();
|
|
712
|
-
return getConfigWithDefaults(userSettings.ui, SettingsManager.UI_DEFAULTS);
|
|
713
|
-
}
|
|
714
|
-
/**
|
|
715
|
-
* Update UI configuration
|
|
716
|
-
* Merges with existing config and saves to user settings
|
|
717
|
-
*/
|
|
718
|
-
updateUIConfig(config) {
|
|
719
|
-
const userSettings = this.loadUserSettings();
|
|
720
|
-
const currentConfig = this.getUIConfig();
|
|
721
|
-
const newConfig = {
|
|
722
|
-
...currentConfig,
|
|
723
|
-
...config,
|
|
724
|
-
};
|
|
725
|
-
this.saveUserSettings({ ...userSettings, ui: newConfig });
|
|
726
|
-
}
|
|
727
|
-
// ==================== Phase 2: Status Bar Configuration ====================
|
|
728
|
-
/** Default status bar configuration */
|
|
729
|
-
static STATUS_BAR_DEFAULTS = {
|
|
730
|
-
enabled: true,
|
|
731
|
-
compact: true,
|
|
732
|
-
showCost: true,
|
|
733
|
-
showTokens: true,
|
|
734
|
-
showContext: true,
|
|
735
|
-
showSession: true,
|
|
736
|
-
showModes: true,
|
|
737
|
-
updateInterval: 1000,
|
|
738
|
-
position: 'top',
|
|
739
|
-
};
|
|
740
|
-
/**
|
|
741
|
-
* Get status bar configuration with proper defaults
|
|
742
|
-
* Priority: User settings > Schema defaults
|
|
743
|
-
*/
|
|
744
|
-
getStatusBarConfig() {
|
|
745
|
-
const userSettings = this.loadUserSettings();
|
|
746
|
-
return getConfigWithDefaults(userSettings.statusBar, SettingsManager.STATUS_BAR_DEFAULTS);
|
|
747
|
-
}
|
|
748
|
-
/**
|
|
749
|
-
* Update status bar configuration
|
|
750
|
-
* Merges with existing config and saves to user settings
|
|
751
|
-
*/
|
|
752
|
-
updateStatusBarConfig(config) {
|
|
753
|
-
const userSettings = this.loadUserSettings();
|
|
754
|
-
const currentConfig = this.getStatusBarConfig();
|
|
755
|
-
// Spread operator handles the merge cleanly
|
|
756
|
-
const newConfig = {
|
|
757
|
-
...currentConfig,
|
|
758
|
-
...config,
|
|
759
|
-
};
|
|
760
|
-
this.saveUserSettings({ ...userSettings, statusBar: newConfig });
|
|
761
|
-
}
|
|
762
|
-
// ==================== Phase 2: Auto-accept Configuration ====================
|
|
763
|
-
/**
|
|
764
|
-
* Get auto-accept configuration with proper defaults
|
|
765
|
-
* Priority: User settings > Schema defaults
|
|
766
|
-
*/
|
|
767
|
-
getAutoAcceptConfig() {
|
|
768
|
-
const userSettings = this.loadUserSettings();
|
|
769
|
-
// Return schema defaults if no user config exists
|
|
770
|
-
if (!userSettings.autoAccept) {
|
|
771
|
-
return {
|
|
772
|
-
enabled: false,
|
|
773
|
-
persistAcrossSessions: false,
|
|
774
|
-
alwaysConfirm: ['git_push_main', 'mass_delete', 'rm_rf', 'npm_publish'],
|
|
775
|
-
scope: 'session',
|
|
776
|
-
auditLog: {
|
|
777
|
-
enabled: true,
|
|
778
|
-
maxEntries: 1000,
|
|
779
|
-
filepath: undefined,
|
|
780
|
-
},
|
|
781
|
-
};
|
|
782
|
-
}
|
|
783
|
-
// Merge user config with defaults
|
|
784
|
-
return {
|
|
785
|
-
enabled: userSettings.autoAccept.enabled ?? false,
|
|
786
|
-
persistAcrossSessions: userSettings.autoAccept.persistAcrossSessions ?? false,
|
|
787
|
-
alwaysConfirm: userSettings.autoAccept.alwaysConfirm || ['git_push_main', 'mass_delete', 'rm_rf', 'npm_publish'],
|
|
788
|
-
scope: userSettings.autoAccept.scope ?? 'session',
|
|
789
|
-
auditLog: {
|
|
790
|
-
enabled: userSettings.autoAccept.auditLog?.enabled ?? true,
|
|
791
|
-
maxEntries: userSettings.autoAccept.auditLog?.maxEntries ?? 1000,
|
|
792
|
-
filepath: userSettings.autoAccept.auditLog?.filepath,
|
|
793
|
-
},
|
|
794
|
-
};
|
|
795
|
-
}
|
|
796
|
-
/**
|
|
797
|
-
* Update auto-accept configuration
|
|
798
|
-
* Merges with existing config and saves to user settings
|
|
799
|
-
*/
|
|
800
|
-
updateAutoAcceptConfig(config) {
|
|
801
|
-
if (!config)
|
|
802
|
-
return; // Early exit if no config provided
|
|
803
|
-
const userSettings = this.loadUserSettings();
|
|
804
|
-
const currentConfig = this.getAutoAcceptConfig();
|
|
805
|
-
// Deep merge for nested auditLog object
|
|
806
|
-
// Note: currentConfig.auditLog is guaranteed by getAutoAcceptConfig() defaults
|
|
807
|
-
const currentAuditLog = currentConfig?.auditLog ?? {
|
|
808
|
-
enabled: false,
|
|
809
|
-
path: '.ax-cli/audit.log',
|
|
810
|
-
maxSize: 10,
|
|
811
|
-
retentionDays: 30,
|
|
812
|
-
};
|
|
813
|
-
const configAuditLog = config?.auditLog;
|
|
814
|
-
// Spread operator handles the merge cleanly
|
|
815
|
-
const newConfig = {
|
|
816
|
-
...currentConfig,
|
|
817
|
-
...config,
|
|
818
|
-
auditLog: configAuditLog ? { ...currentAuditLog, ...configAuditLog } : currentAuditLog,
|
|
819
|
-
};
|
|
820
|
-
this.saveUserSettings({ ...userSettings, autoAccept: newConfig });
|
|
821
|
-
}
|
|
822
|
-
// ==================== Phase 2: External Editor Configuration ====================
|
|
823
|
-
/** Default external editor configuration */
|
|
824
|
-
static EXTERNAL_EDITOR_DEFAULTS = {
|
|
825
|
-
enabled: true,
|
|
826
|
-
editor: undefined,
|
|
827
|
-
shortcut: 'ctrl+g',
|
|
828
|
-
tempDir: undefined,
|
|
829
|
-
confirmBeforeSubmit: true,
|
|
830
|
-
syntaxHighlighting: true,
|
|
831
|
-
};
|
|
832
|
-
/**
|
|
833
|
-
* Get external editor configuration with proper defaults
|
|
834
|
-
* Priority: User settings > Schema defaults
|
|
835
|
-
*/
|
|
836
|
-
getExternalEditorConfig() {
|
|
837
|
-
const userSettings = this.loadUserSettings();
|
|
838
|
-
return getConfigWithDefaults(userSettings.externalEditor, SettingsManager.EXTERNAL_EDITOR_DEFAULTS);
|
|
839
|
-
}
|
|
840
|
-
/**
|
|
841
|
-
* Update external editor configuration
|
|
842
|
-
* Merges with existing config and saves to user settings
|
|
843
|
-
*/
|
|
844
|
-
updateExternalEditorConfig(config) {
|
|
845
|
-
const userSettings = this.loadUserSettings();
|
|
846
|
-
const currentConfig = this.getExternalEditorConfig();
|
|
847
|
-
// Spread operator handles the merge cleanly
|
|
848
|
-
const newConfig = {
|
|
849
|
-
...currentConfig,
|
|
850
|
-
...config,
|
|
851
|
-
};
|
|
852
|
-
this.saveUserSettings({ ...userSettings, externalEditor: newConfig });
|
|
853
|
-
}
|
|
854
|
-
// ==================== Phase 2: Thinking Mode Configuration ====================
|
|
855
|
-
/** Default thinking mode configuration */
|
|
856
|
-
static THINKING_MODE_DEFAULTS = {
|
|
857
|
-
enabled: false,
|
|
858
|
-
quickToggle: true,
|
|
859
|
-
showInStatusBar: true,
|
|
860
|
-
budgetTokens: undefined,
|
|
861
|
-
};
|
|
862
|
-
/**
|
|
863
|
-
* Get thinking mode configuration with proper defaults
|
|
864
|
-
* Priority: User settings > Schema defaults
|
|
865
|
-
*/
|
|
866
|
-
getThinkingModeConfig() {
|
|
867
|
-
const userSettings = this.loadUserSettings();
|
|
868
|
-
return getConfigWithDefaults(userSettings.thinkingMode, SettingsManager.THINKING_MODE_DEFAULTS);
|
|
869
|
-
}
|
|
870
|
-
/**
|
|
871
|
-
* Update thinking mode configuration
|
|
872
|
-
* Merges with existing config and saves to user settings
|
|
873
|
-
*/
|
|
874
|
-
updateThinkingModeConfig(config) {
|
|
875
|
-
const userSettings = this.loadUserSettings();
|
|
876
|
-
const currentConfig = this.getThinkingModeConfig();
|
|
877
|
-
// Spread operator handles the merge cleanly
|
|
878
|
-
const newConfig = {
|
|
879
|
-
...currentConfig,
|
|
880
|
-
...config,
|
|
881
|
-
};
|
|
882
|
-
this.saveUserSettings({ ...userSettings, thinkingMode: newConfig });
|
|
883
|
-
}
|
|
884
|
-
// ==================== Auto-Update Configuration ====================
|
|
885
|
-
/** Default auto-update configuration */
|
|
886
|
-
static AUTO_UPDATE_DEFAULTS = {
|
|
887
|
-
enabled: true,
|
|
888
|
-
checkIntervalHours: 24,
|
|
889
|
-
lastCheckTimestamp: undefined,
|
|
890
|
-
autoInstall: false,
|
|
891
|
-
};
|
|
892
|
-
/**
|
|
893
|
-
* Get auto-update configuration with proper defaults
|
|
894
|
-
* Priority: User settings > Schema defaults
|
|
895
|
-
*/
|
|
896
|
-
getAutoUpdateConfig() {
|
|
897
|
-
const userSettings = this.loadUserSettings();
|
|
898
|
-
return getConfigWithDefaults(userSettings.autoUpdate, SettingsManager.AUTO_UPDATE_DEFAULTS);
|
|
899
|
-
}
|
|
900
|
-
/**
|
|
901
|
-
* Update auto-update configuration
|
|
902
|
-
* Merges with existing config and saves to user settings
|
|
903
|
-
*/
|
|
904
|
-
updateAutoUpdateConfig(config) {
|
|
905
|
-
const userSettings = this.loadUserSettings();
|
|
906
|
-
const currentConfig = this.getAutoUpdateConfig();
|
|
907
|
-
// Spread operator handles the merge cleanly
|
|
908
|
-
const newConfig = {
|
|
909
|
-
...currentConfig,
|
|
910
|
-
...config,
|
|
911
|
-
};
|
|
912
|
-
this.saveUserSettings({ ...userSettings, autoUpdate: newConfig });
|
|
913
|
-
}
|
|
914
|
-
/**
|
|
915
|
-
* Check if enough time has passed since the last update check
|
|
916
|
-
* @returns true if an update check should be performed
|
|
917
|
-
*/
|
|
918
|
-
shouldCheckForUpdates() {
|
|
919
|
-
const config = this.getAutoUpdateConfig();
|
|
920
|
-
// If config is undefined, use defaults (enabled by default)
|
|
921
|
-
if (!config) {
|
|
922
|
-
return true;
|
|
923
|
-
}
|
|
924
|
-
// Auto-update disabled
|
|
925
|
-
if (config.enabled === false) {
|
|
926
|
-
return false;
|
|
927
|
-
}
|
|
928
|
-
// No interval set (always check)
|
|
929
|
-
if (config.checkIntervalHours === 0) {
|
|
930
|
-
return true;
|
|
931
|
-
}
|
|
932
|
-
// No previous check recorded
|
|
933
|
-
if (!config.lastCheckTimestamp) {
|
|
934
|
-
return true;
|
|
935
|
-
}
|
|
936
|
-
// Check if enough time has passed
|
|
937
|
-
const lastCheck = new Date(config.lastCheckTimestamp).getTime();
|
|
938
|
-
// If lastCheckTimestamp is invalid, check for updates
|
|
939
|
-
if (Number.isNaN(lastCheck)) {
|
|
940
|
-
return true;
|
|
941
|
-
}
|
|
942
|
-
const now = Date.now();
|
|
943
|
-
const intervalMs = (config.checkIntervalHours ?? 24) * 60 * 60 * 1000;
|
|
944
|
-
return (now - lastCheck) >= intervalMs;
|
|
945
|
-
}
|
|
946
|
-
/**
|
|
947
|
-
* Record that an update check was performed
|
|
948
|
-
* Silently fails if settings cannot be saved
|
|
949
|
-
*/
|
|
950
|
-
recordUpdateCheck() {
|
|
951
|
-
try {
|
|
952
|
-
this.updateAutoUpdateConfig({
|
|
953
|
-
lastCheckTimestamp: new Date().toISOString(),
|
|
954
|
-
});
|
|
955
|
-
}
|
|
956
|
-
catch {
|
|
957
|
-
// Silently ignore - don't crash CLI if we can't save timestamp
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
/**
|
|
962
|
-
* Convenience function to get the singleton instance
|
|
963
|
-
*/
|
|
964
|
-
export function getSettingsManager() {
|
|
965
|
-
return SettingsManager.getInstance();
|
|
966
|
-
}
|
|
967
|
-
//# sourceMappingURL=settings-manager.js.map
|