@qlingzzy/qling 1.0.0
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/CHANGELOG.md +122 -0
- package/LICENSE +21 -0
- package/README.en.md +129 -0
- package/README.md +416 -0
- package/dist/agent/subtask.d.ts +21 -0
- package/dist/agent/subtask.d.ts.map +1 -0
- package/dist/agent/subtask.js +55 -0
- package/dist/agent-loop.d.ts +151 -0
- package/dist/agent-loop.d.ts.map +1 -0
- package/dist/agent-loop.js +1498 -0
- package/dist/agents/isolation-policy.d.ts +14 -0
- package/dist/agents/isolation-policy.d.ts.map +1 -0
- package/dist/agents/isolation-policy.js +52 -0
- package/dist/channels/console-channel.d.ts +15 -0
- package/dist/channels/console-channel.d.ts.map +1 -0
- package/dist/channels/console-channel.js +66 -0
- package/dist/channels/registry.d.ts +10 -0
- package/dist/channels/registry.d.ts.map +1 -0
- package/dist/channels/registry.js +25 -0
- package/dist/channels/slack-channel.d.ts +35 -0
- package/dist/channels/slack-channel.d.ts.map +1 -0
- package/dist/channels/slack-channel.js +232 -0
- package/dist/channels/telegram-channel.d.ts +32 -0
- package/dist/channels/telegram-channel.d.ts.map +1 -0
- package/dist/channels/telegram-channel.js +167 -0
- package/dist/channels/types.d.ts +31 -0
- package/dist/channels/types.d.ts.map +1 -0
- package/dist/channels/types.js +4 -0
- package/dist/cli/bootstrap.d.ts +39 -0
- package/dist/cli/bootstrap.d.ts.map +1 -0
- package/dist/cli/bootstrap.js +138 -0
- package/dist/cli/channel-bootstrap.d.ts +23 -0
- package/dist/cli/channel-bootstrap.d.ts.map +1 -0
- package/dist/cli/channel-bootstrap.js +46 -0
- package/dist/cli/daemon-control.d.ts +31 -0
- package/dist/cli/daemon-control.d.ts.map +1 -0
- package/dist/cli/daemon-control.js +177 -0
- package/dist/cli/guidance-panel.d.ts +11 -0
- package/dist/cli/guidance-panel.d.ts.map +1 -0
- package/dist/cli/guidance-panel.js +16 -0
- package/dist/cli/mcp-control.d.ts +7 -0
- package/dist/cli/mcp-control.d.ts.map +1 -0
- package/dist/cli/mcp-control.js +119 -0
- package/dist/cli/mission-views.d.ts +13 -0
- package/dist/cli/mission-views.d.ts.map +1 -0
- package/dist/cli/mission-views.js +82 -0
- package/dist/cli/setup.d.ts +9 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +140 -0
- package/dist/cli/startup-contract.d.ts +23 -0
- package/dist/cli/startup-contract.d.ts.map +1 -0
- package/dist/cli/startup-contract.js +694 -0
- package/dist/commands/agents.d.ts +3 -0
- package/dist/commands/agents.d.ts.map +1 -0
- package/dist/commands/agents.js +44 -0
- package/dist/commands/checkpoint.d.ts +3 -0
- package/dist/commands/checkpoint.d.ts.map +1 -0
- package/dist/commands/checkpoint.js +52 -0
- package/dist/commands/claude-style.d.ts +12 -0
- package/dist/commands/claude-style.d.ts.map +1 -0
- package/dist/commands/claude-style.js +560 -0
- package/dist/commands/clear.d.ts +3 -0
- package/dist/commands/clear.d.ts.map +1 -0
- package/dist/commands/clear.js +20 -0
- package/dist/commands/compact.d.ts +3 -0
- package/dist/commands/compact.d.ts.map +1 -0
- package/dist/commands/compact.js +23 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +22 -0
- package/dist/commands/connect.d.ts +3 -0
- package/dist/commands/connect.d.ts.map +1 -0
- package/dist/commands/connect.js +102 -0
- package/dist/commands/context.d.ts +3 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +13 -0
- package/dist/commands/dashboard.d.ts +3 -0
- package/dist/commands/dashboard.d.ts.map +1 -0
- package/dist/commands/dashboard.js +22 -0
- package/dist/commands/detach.d.ts +3 -0
- package/dist/commands/detach.d.ts.map +1 -0
- package/dist/commands/detach.js +44 -0
- package/dist/commands/distill.d.ts +3 -0
- package/dist/commands/distill.d.ts.map +1 -0
- package/dist/commands/distill.js +23 -0
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +13 -0
- package/dist/commands/dream.d.ts +3 -0
- package/dist/commands/dream.d.ts.map +1 -0
- package/dist/commands/dream.js +59 -0
- package/dist/commands/export.d.ts +3 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +18 -0
- package/dist/commands/exports.d.ts +3 -0
- package/dist/commands/exports.d.ts.map +1 -0
- package/dist/commands/exports.js +15 -0
- package/dist/commands/goal.d.ts +3 -0
- package/dist/commands/goal.d.ts.map +1 -0
- package/dist/commands/goal.js +147 -0
- package/dist/commands/help.d.ts +4 -0
- package/dist/commands/help.d.ts.map +1 -0
- package/dist/commands/help.js +75 -0
- package/dist/commands/hooks.d.ts +3 -0
- package/dist/commands/hooks.d.ts.map +1 -0
- package/dist/commands/hooks.js +14 -0
- package/dist/commands/index.d.ts +29 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +417 -0
- package/dist/commands/knowledge.d.ts +8 -0
- package/dist/commands/knowledge.d.ts.map +1 -0
- package/dist/commands/knowledge.js +191 -0
- package/dist/commands/loop.d.ts +3 -0
- package/dist/commands/loop.d.ts.map +1 -0
- package/dist/commands/loop.js +138 -0
- package/dist/commands/mcp.d.ts +3 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +57 -0
- package/dist/commands/memory.d.ts +3 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/memory.js +215 -0
- package/dist/commands/mission.d.ts +3 -0
- package/dist/commands/mission.d.ts.map +1 -0
- package/dist/commands/mission.js +129 -0
- package/dist/commands/permissions.d.ts +3 -0
- package/dist/commands/permissions.d.ts.map +1 -0
- package/dist/commands/permissions.js +82 -0
- package/dist/commands/privacy.d.ts +3 -0
- package/dist/commands/privacy.d.ts.map +1 -0
- package/dist/commands/privacy.js +13 -0
- package/dist/commands/recap.d.ts +3 -0
- package/dist/commands/recap.d.ts.map +1 -0
- package/dist/commands/recap.js +11 -0
- package/dist/commands/repomap.d.ts +3 -0
- package/dist/commands/repomap.d.ts.map +1 -0
- package/dist/commands/repomap.js +146 -0
- package/dist/commands/resume.d.ts +3 -0
- package/dist/commands/resume.d.ts.map +1 -0
- package/dist/commands/resume.js +42 -0
- package/dist/commands/runtime.d.ts +61 -0
- package/dist/commands/runtime.d.ts.map +1 -0
- package/dist/commands/runtime.js +20 -0
- package/dist/commands/sessions.d.ts +3 -0
- package/dist/commands/sessions.d.ts.map +1 -0
- package/dist/commands/sessions.js +34 -0
- package/dist/commands/shortcuts.d.ts +3 -0
- package/dist/commands/shortcuts.d.ts.map +1 -0
- package/dist/commands/shortcuts.js +12 -0
- package/dist/commands/skill.d.ts +3 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +20 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +31 -0
- package/dist/commands/statusline.d.ts +3 -0
- package/dist/commands/statusline.d.ts.map +1 -0
- package/dist/commands/statusline.js +40 -0
- package/dist/commands/storage.d.ts +3 -0
- package/dist/commands/storage.d.ts.map +1 -0
- package/dist/commands/storage.js +122 -0
- package/dist/commands/tasks.d.ts +3 -0
- package/dist/commands/tasks.d.ts.map +1 -0
- package/dist/commands/tasks.js +117 -0
- package/dist/commands/types.d.ts +14 -0
- package/dist/commands/types.d.ts.map +1 -0
- package/dist/commands/types.js +1 -0
- package/dist/commands/verify.d.ts +3 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +86 -0
- package/dist/config-report.d.ts +35 -0
- package/dist/config-report.d.ts.map +1 -0
- package/dist/config-report.js +100 -0
- package/dist/config.d.ts +217 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +690 -0
- package/dist/context-compactor.d.ts +27 -0
- package/dist/context-compactor.d.ts.map +1 -0
- package/dist/context-compactor.js +489 -0
- package/dist/context-report.d.ts +35 -0
- package/dist/context-report.d.ts.map +1 -0
- package/dist/context-report.js +172 -0
- package/dist/daemon.d.ts +2 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +316 -0
- package/dist/dashboard-server.d.ts +18 -0
- package/dist/dashboard-server.d.ts.map +1 -0
- package/dist/dashboard-server.js +325 -0
- package/dist/discovery-registry.d.ts +28 -0
- package/dist/discovery-registry.d.ts.map +1 -0
- package/dist/discovery-registry.js +106 -0
- package/dist/discovery-types.d.ts +54 -0
- package/dist/discovery-types.d.ts.map +1 -0
- package/dist/discovery-types.js +5 -0
- package/dist/doctor.d.ts +31 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/doctor.js +343 -0
- package/dist/eval/runner.d.ts +10 -0
- package/dist/eval/runner.d.ts.map +1 -0
- package/dist/eval/runner.js +78 -0
- package/dist/eval/tasks.d.ts +3 -0
- package/dist/eval/tasks.d.ts.map +1 -0
- package/dist/eval/tasks.js +179 -0
- package/dist/eval/types.d.ts +31 -0
- package/dist/eval/types.d.ts.map +1 -0
- package/dist/eval/types.js +4 -0
- package/dist/git/auto-commit.d.ts +28 -0
- package/dist/git/auto-commit.d.ts.map +1 -0
- package/dist/git/auto-commit.js +112 -0
- package/dist/guard/approval.d.ts +16 -0
- package/dist/guard/approval.d.ts.map +1 -0
- package/dist/guard/approval.js +68 -0
- package/dist/guard/content-filter.d.ts +15 -0
- package/dist/guard/content-filter.d.ts.map +1 -0
- package/dist/guard/content-filter.js +102 -0
- package/dist/guard/permissions.d.ts +17 -0
- package/dist/guard/permissions.d.ts.map +1 -0
- package/dist/guard/permissions.js +54 -0
- package/dist/guard/rate-limit.d.ts +14 -0
- package/dist/guard/rate-limit.d.ts.map +1 -0
- package/dist/guard/rate-limit.js +47 -0
- package/dist/guard.d.ts +21 -0
- package/dist/guard.d.ts.map +1 -0
- package/dist/guard.js +144 -0
- package/dist/help-topics.d.ts +19 -0
- package/dist/help-topics.d.ts.map +1 -0
- package/dist/help-topics.js +391 -0
- package/dist/hooks-report.d.ts +23 -0
- package/dist/hooks-report.d.ts.map +1 -0
- package/dist/hooks-report.js +44 -0
- package/dist/i18n/index.d.ts +5 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +4 -0
- package/dist/i18n/zh-cn.d.ts +180 -0
- package/dist/i18n/zh-cn.d.ts.map +1 -0
- package/dist/i18n/zh-cn.js +184 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1157 -0
- package/dist/knowledge-agent.d.ts +47 -0
- package/dist/knowledge-agent.d.ts.map +1 -0
- package/dist/knowledge-agent.js +320 -0
- package/dist/local-status-report.d.ts +23 -0
- package/dist/local-status-report.d.ts.map +1 -0
- package/dist/local-status-report.js +63 -0
- package/dist/local-storage-report.d.ts +32 -0
- package/dist/local-storage-report.d.ts.map +1 -0
- package/dist/local-storage-report.js +171 -0
- package/dist/mcp/bridge.d.ts +11 -0
- package/dist/mcp/bridge.d.ts.map +1 -0
- package/dist/mcp/bridge.js +37 -0
- package/dist/mcp/client.d.ts +26 -0
- package/dist/mcp/client.d.ts.map +1 -0
- package/dist/mcp/client.js +209 -0
- package/dist/mcp/http-transport.d.ts +21 -0
- package/dist/mcp/http-transport.d.ts.map +1 -0
- package/dist/mcp/http-transport.js +126 -0
- package/dist/mcp/presets.d.ts +22 -0
- package/dist/mcp/presets.d.ts.map +1 -0
- package/dist/mcp/presets.js +80 -0
- package/dist/mcp/registry.d.ts +23 -0
- package/dist/mcp/registry.d.ts.map +1 -0
- package/dist/mcp/registry.js +85 -0
- package/dist/mcp/stdio-transport.d.ts +25 -0
- package/dist/mcp/stdio-transport.d.ts.map +1 -0
- package/dist/mcp/stdio-transport.js +92 -0
- package/dist/mcp/store.d.ts +41 -0
- package/dist/mcp/store.d.ts.map +1 -0
- package/dist/mcp/store.js +100 -0
- package/dist/mcp/types.d.ts +40 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +4 -0
- package/dist/mcp-report.d.ts +30 -0
- package/dist/mcp-report.d.ts.map +1 -0
- package/dist/mcp-report.js +104 -0
- package/dist/memory/cognitive-index.d.ts +56 -0
- package/dist/memory/cognitive-index.d.ts.map +1 -0
- package/dist/memory/cognitive-index.js +265 -0
- package/dist/memory/compactor.d.ts +28 -0
- package/dist/memory/compactor.d.ts.map +1 -0
- package/dist/memory/compactor.js +92 -0
- package/dist/memory/consolidation.d.ts +13 -0
- package/dist/memory/consolidation.d.ts.map +1 -0
- package/dist/memory/consolidation.js +77 -0
- package/dist/memory/embedding.d.ts +15 -0
- package/dist/memory/embedding.d.ts.map +1 -0
- package/dist/memory/embedding.js +59 -0
- package/dist/memory/memory-llm-dream.d.ts +3 -0
- package/dist/memory/memory-llm-dream.d.ts.map +1 -0
- package/dist/memory/memory-llm-dream.js +59 -0
- package/dist/memory/projection-worker.d.ts +30 -0
- package/dist/memory/projection-worker.d.ts.map +1 -0
- package/dist/memory/projection-worker.js +92 -0
- package/dist/memory/semantic-index.d.ts +18 -0
- package/dist/memory/semantic-index.d.ts.map +1 -0
- package/dist/memory/semantic-index.js +86 -0
- package/dist/memory/wal.d.ts +33 -0
- package/dist/memory/wal.d.ts.map +1 -0
- package/dist/memory/wal.js +131 -0
- package/dist/memory-report.d.ts +120 -0
- package/dist/memory-report.d.ts.map +1 -0
- package/dist/memory-report.js +726 -0
- package/dist/memory.d.ts +149 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +632 -0
- package/dist/metrics/agent-telemetry.d.ts +14 -0
- package/dist/metrics/agent-telemetry.d.ts.map +1 -0
- package/dist/metrics/agent-telemetry.js +44 -0
- package/dist/metrics/collector.d.ts +17 -0
- package/dist/metrics/collector.d.ts.map +1 -0
- package/dist/metrics/collector.js +137 -0
- package/dist/metrics/types.d.ts +14 -0
- package/dist/metrics/types.d.ts.map +1 -0
- package/dist/metrics/types.js +4 -0
- package/dist/mission/manager.d.ts +28 -0
- package/dist/mission/manager.d.ts.map +1 -0
- package/dist/mission/manager.js +208 -0
- package/dist/mission/types.d.ts +37 -0
- package/dist/mission/types.d.ts.map +1 -0
- package/dist/mission/types.js +5 -0
- package/dist/onboarding/tutorial.d.ts +33 -0
- package/dist/onboarding/tutorial.d.ts.map +1 -0
- package/dist/onboarding/tutorial.js +96 -0
- package/dist/output-style.d.ts +14 -0
- package/dist/output-style.d.ts.map +1 -0
- package/dist/output-style.js +29 -0
- package/dist/package-version.d.ts +12 -0
- package/dist/package-version.d.ts.map +1 -0
- package/dist/package-version.js +42 -0
- package/dist/permissions-report.d.ts +42 -0
- package/dist/permissions-report.d.ts.map +1 -0
- package/dist/permissions-report.js +120 -0
- package/dist/pipeline/consistency-checker.d.ts +8 -0
- package/dist/pipeline/consistency-checker.d.ts.map +1 -0
- package/dist/pipeline/consistency-checker.js +40 -0
- package/dist/pipeline/example-generator.d.ts +4 -0
- package/dist/pipeline/example-generator.d.ts.map +1 -0
- package/dist/pipeline/example-generator.js +64 -0
- package/dist/pipeline/hooks.d.ts +68 -0
- package/dist/pipeline/hooks.d.ts.map +1 -0
- package/dist/pipeline/hooks.js +377 -0
- package/dist/pipeline/sections.d.ts +41 -0
- package/dist/pipeline/sections.d.ts.map +1 -0
- package/dist/pipeline/sections.js +244 -0
- package/dist/pipeline/verification.d.ts +12 -0
- package/dist/pipeline/verification.d.ts.map +1 -0
- package/dist/pipeline/verification.js +138 -0
- package/dist/privacy-report.d.ts +24 -0
- package/dist/privacy-report.d.ts.map +1 -0
- package/dist/privacy-report.js +78 -0
- package/dist/providers/presets.d.ts +25 -0
- package/dist/providers/presets.d.ts.map +1 -0
- package/dist/providers/presets.js +205 -0
- package/dist/recap.d.ts +38 -0
- package/dist/recap.d.ts.map +1 -0
- package/dist/recap.js +154 -0
- package/dist/repl.d.ts +41 -0
- package/dist/repl.d.ts.map +1 -0
- package/dist/repl.js +396 -0
- package/dist/runtime-paths.d.ts +32 -0
- package/dist/runtime-paths.d.ts.map +1 -0
- package/dist/runtime-paths.js +134 -0
- package/dist/sdk.d.ts +12 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +18 -0
- package/dist/session/daemon-session-api.d.ts +22 -0
- package/dist/session/daemon-session-api.d.ts.map +1 -0
- package/dist/session/daemon-session-api.js +48 -0
- package/dist/session/durable-session-supervisor.d.ts +24 -0
- package/dist/session/durable-session-supervisor.d.ts.map +1 -0
- package/dist/session/durable-session-supervisor.js +195 -0
- package/dist/session/goal-controller.d.ts +43 -0
- package/dist/session/goal-controller.d.ts.map +1 -0
- package/dist/session/goal-controller.js +77 -0
- package/dist/session/goal-evaluator.d.ts +29 -0
- package/dist/session/goal-evaluator.d.ts.map +1 -0
- package/dist/session/goal-evaluator.js +100 -0
- package/dist/session/loop-prompt.d.ts +14 -0
- package/dist/session/loop-prompt.d.ts.map +1 -0
- package/dist/session/loop-prompt.js +49 -0
- package/dist/session/session-goal-manager.d.ts +51 -0
- package/dist/session/session-goal-manager.d.ts.map +1 -0
- package/dist/session/session-goal-manager.js +118 -0
- package/dist/session/session-registry.d.ts +40 -0
- package/dist/session/session-registry.d.ts.map +1 -0
- package/dist/session/session-registry.js +124 -0
- package/dist/session/session-scheduler.d.ts +59 -0
- package/dist/session/session-scheduler.d.ts.map +1 -0
- package/dist/session/session-scheduler.js +170 -0
- package/dist/session-checkpoint-report.d.ts +22 -0
- package/dist/session-checkpoint-report.d.ts.map +1 -0
- package/dist/session-checkpoint-report.js +99 -0
- package/dist/session-export-index.d.ts +23 -0
- package/dist/session-export-index.d.ts.map +1 -0
- package/dist/session-export-index.js +96 -0
- package/dist/session-export.d.ts +28 -0
- package/dist/session-export.d.ts.map +1 -0
- package/dist/session-export.js +99 -0
- package/dist/session-goal-report.d.ts +37 -0
- package/dist/session-goal-report.d.ts.map +1 -0
- package/dist/session-goal-report.js +219 -0
- package/dist/session-list-report.d.ts +16 -0
- package/dist/session-list-report.d.ts.map +1 -0
- package/dist/session-list-report.js +60 -0
- package/dist/session-task-report.d.ts +23 -0
- package/dist/session-task-report.d.ts.map +1 -0
- package/dist/session-task-report.js +183 -0
- package/dist/shortcuts.d.ts +2 -0
- package/dist/shortcuts.d.ts.map +1 -0
- package/dist/shortcuts.js +32 -0
- package/dist/skills/registry.d.ts +8 -0
- package/dist/skills/registry.d.ts.map +1 -0
- package/dist/skills/registry.js +119 -0
- package/dist/skills/types.d.ts +7 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +4 -0
- package/dist/statusline.d.ts +37 -0
- package/dist/statusline.d.ts.map +1 -0
- package/dist/statusline.js +207 -0
- package/dist/tools/bash.d.ts +10 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +278 -0
- package/dist/tools/browser-fetch.d.ts +7 -0
- package/dist/tools/browser-fetch.d.ts.map +1 -0
- package/dist/tools/browser-fetch.js +133 -0
- package/dist/tools/error-utils.d.ts +9 -0
- package/dist/tools/error-utils.d.ts.map +1 -0
- package/dist/tools/error-utils.js +35 -0
- package/dist/tools/index.d.ts +27 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +86 -0
- package/dist/tools/patch.d.ts +22 -0
- package/dist/tools/patch.d.ts.map +1 -0
- package/dist/tools/patch.js +458 -0
- package/dist/tools/planner.d.ts +7 -0
- package/dist/tools/planner.d.ts.map +1 -0
- package/dist/tools/planner.js +148 -0
- package/dist/tools/read.d.ts +8 -0
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/read.js +114 -0
- package/dist/tools/search.d.ts +11 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +636 -0
- package/dist/tools/skill.d.ts +8 -0
- package/dist/tools/skill.d.ts.map +1 -0
- package/dist/tools/skill.js +181 -0
- package/dist/tools/subtask.d.ts +9 -0
- package/dist/tools/subtask.d.ts.map +1 -0
- package/dist/tools/subtask.js +120 -0
- package/dist/tools/todo.d.ts +8 -0
- package/dist/tools/todo.d.ts.map +1 -0
- package/dist/tools/todo.js +170 -0
- package/dist/tools/url-fetch.d.ts +11 -0
- package/dist/tools/url-fetch.d.ts.map +1 -0
- package/dist/tools/url-fetch.js +208 -0
- package/dist/tools/vision-analyze.d.ts +9 -0
- package/dist/tools/vision-analyze.d.ts.map +1 -0
- package/dist/tools/vision-analyze.js +179 -0
- package/dist/tools/write.d.ts +7 -0
- package/dist/tools/write.d.ts.map +1 -0
- package/dist/tools/write.js +128 -0
- package/dist/tui/chrome.d.ts +7 -0
- package/dist/tui/chrome.d.ts.map +1 -0
- package/dist/tui/chrome.js +22 -0
- package/dist/tui/input-buffer.d.ts +37 -0
- package/dist/tui/input-buffer.d.ts.map +1 -0
- package/dist/tui/input-buffer.js +228 -0
- package/dist/tui/input-history.d.ts +11 -0
- package/dist/tui/input-history.d.ts.map +1 -0
- package/dist/tui/input-history.js +69 -0
- package/dist/tui/input-queue.d.ts +27 -0
- package/dist/tui/input-queue.d.ts.map +1 -0
- package/dist/tui/input-queue.js +85 -0
- package/dist/tui/markdown.d.ts +10 -0
- package/dist/tui/markdown.d.ts.map +1 -0
- package/dist/tui/markdown.js +396 -0
- package/dist/tui/progress.d.ts +3 -0
- package/dist/tui/progress.d.ts.map +1 -0
- package/dist/tui/progress.js +13 -0
- package/dist/tui/shell.d.ts +67 -0
- package/dist/tui/shell.d.ts.map +1 -0
- package/dist/tui/shell.js +271 -0
- package/dist/tui/streaming-repl.d.ts +39 -0
- package/dist/tui/streaming-repl.d.ts.map +1 -0
- package/dist/tui/streaming-repl.js +460 -0
- package/dist/tui/streaming-tui.d.ts +174 -0
- package/dist/tui/streaming-tui.d.ts.map +1 -0
- package/dist/tui/streaming-tui.js +1049 -0
- package/dist/types.d.ts +221 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +37 -0
- package/dist/utils/symbol-extractor.d.ts +8 -0
- package/dist/utils/symbol-extractor.d.ts.map +1 -0
- package/dist/utils/symbol-extractor.js +190 -0
- package/dist/workflow-runtime.d.ts +45 -0
- package/dist/workflow-runtime.d.ts.map +1 -0
- package/dist/workflow-runtime.js +146 -0
- package/dist/workflow-types.d.ts +73 -0
- package/dist/workflow-types.d.ts.map +1 -0
- package/dist/workflow-types.js +34 -0
- package/docs/docker.md +66 -0
- package/docs/install.md +159 -0
- package/docs/sdk.md +67 -0
- package/docs/skills.md +51 -0
- package/package.json +102 -0
- package/scripts/bootstrap.mjs +63 -0
- package/scripts/check_image.ps1 +18 -0
- package/scripts/clean-dist.mjs +18 -0
- package/scripts/copy_image.ps1 +5 -0
- package/scripts/eval-smoke.mjs +17 -0
- package/skills/examples/repo-triage/SKILL.md +50 -0
- package/skills/qling.md +42 -0
- package/skills/templates/SKILL.md +37 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { guardConfigFromEnv } from "../config.js";
|
|
2
|
+
import { buildLocalHooksReport, formatLocalHooksReport } from "../hooks-report.js";
|
|
3
|
+
export const hooksCommand = {
|
|
4
|
+
name: "/hooks",
|
|
5
|
+
aliases: ["/钩子"],
|
|
6
|
+
description: "查看本地 hooks/guard 配置摘要",
|
|
7
|
+
usage: "/hooks",
|
|
8
|
+
execute: async (_args, context) => {
|
|
9
|
+
const report = buildLocalHooksReport(guardConfigFromEnv(process.env));
|
|
10
|
+
for (const line of formatLocalHooksReport(report)) {
|
|
11
|
+
context.writeLine(line);
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SlashCommand } from "./types.js";
|
|
2
|
+
import { SlashCommandContext } from "./runtime.js";
|
|
3
|
+
export declare const COMMANDS: SlashCommand[];
|
|
4
|
+
interface SlashSuggestion {
|
|
5
|
+
command: string;
|
|
6
|
+
topic: string;
|
|
7
|
+
score: number;
|
|
8
|
+
}
|
|
9
|
+
export interface SlashCommandCatalogItem {
|
|
10
|
+
name: string;
|
|
11
|
+
aliases: string[];
|
|
12
|
+
description: string;
|
|
13
|
+
usage: string;
|
|
14
|
+
category: string;
|
|
15
|
+
argumentHint: string;
|
|
16
|
+
availability: "local" | "unsupported";
|
|
17
|
+
examples: string[];
|
|
18
|
+
claudeCompatibleName?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function getSlashCommandCatalog(): SlashCommandCatalogItem[];
|
|
21
|
+
export declare function findSlashCommandSuggestions(input: string, limit?: number): SlashSuggestion[];
|
|
22
|
+
export declare function findSlashCompletion(prefix: string, limit?: number): SlashCommandCatalogItem[];
|
|
23
|
+
export declare function formatSlashCompletionHint(prefix: string, width?: number): string[];
|
|
24
|
+
export declare function formatSlashCommandPanel(prefix: string, selectedIndex?: number, width?: number, limit?: number): string[];
|
|
25
|
+
export declare function formatGroupedSlashPanel(width?: number): string[];
|
|
26
|
+
export declare function formatUnknownSlashCommandMessage(cmdName: string): string;
|
|
27
|
+
export declare function handleSlashCommand(input: string, contextOrAgentLoop: SlashCommandContext | Record<string, any>): Promise<boolean>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAoC1C,OAAO,EAAE,mBAAmB,EAAsB,MAAM,cAAc,CAAC;AAqBvE,eAAO,MAAM,QAAQ,EAAE,YAAY,EA8ClC,CAAC;AAMF,UAAU,eAAe;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,OAAO,GAAG,aAAa,CAAC;IACtC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAyDD,wBAAgB,sBAAsB,IAAI,uBAAuB,EAAE,CAalE;AA4CD,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,eAAe,EAAE,CAsBvF;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,uBAAuB,EAAE,CAyBxF;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,SAAK,GAAG,MAAM,EAAE,CAO9E;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,aAAa,SAAI,EAAE,KAAK,SAAK,EAAE,KAAK,SAAI,GAAG,MAAM,EAAE,CAyB1G;AAoBD,wBAAgB,uBAAuB,CAAC,KAAK,SAAK,GAAG,MAAM,EAAE,CAwC5D;AASD,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAuBxE;AAED,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EACb,kBAAkB,EAAE,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC5D,OAAO,CAAC,OAAO,CAAC,CAgClB"}
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import { helpCommand } from "./help.js";
|
|
2
|
+
import { clearCommand } from "./clear.js";
|
|
3
|
+
import { statusCommand } from "./status.js";
|
|
4
|
+
import { skillCommand } from "./skill.js";
|
|
5
|
+
import { dashboardCommand } from "./dashboard.js";
|
|
6
|
+
import { configCommand } from "./config.js";
|
|
7
|
+
import { detachCommand } from "./detach.js";
|
|
8
|
+
import { compactCommand } from "./compact.js";
|
|
9
|
+
import { goalCommand } from "./goal.js";
|
|
10
|
+
import { loopCommand } from "./loop.js";
|
|
11
|
+
import { tasksCommand } from "./tasks.js";
|
|
12
|
+
import { sessionsCommand } from "./sessions.js";
|
|
13
|
+
import { resumeCommand } from "./resume.js";
|
|
14
|
+
import { checkpointCommand } from "./checkpoint.js";
|
|
15
|
+
import { permissionsCommand } from "./permissions.js";
|
|
16
|
+
import { statuslineCommand } from "./statusline.js";
|
|
17
|
+
import { doctorCommand } from "./doctor.js";
|
|
18
|
+
import { contextCommand } from "./context.js";
|
|
19
|
+
import { recapCommand } from "./recap.js";
|
|
20
|
+
import { privacyCommand } from "./privacy.js";
|
|
21
|
+
import { shortcutsCommand } from "./shortcuts.js";
|
|
22
|
+
import { exportCommand } from "./export.js";
|
|
23
|
+
import { exportsCommand } from "./exports.js";
|
|
24
|
+
import { memoryCommand } from "./memory.js";
|
|
25
|
+
import { repomapCommand } from "./repomap.js";
|
|
26
|
+
import { dreamCommand } from "./dream.js";
|
|
27
|
+
import { distillCommand } from "./distill.js";
|
|
28
|
+
import { knowledgeCommand } from "./knowledge.js";
|
|
29
|
+
import { connectCommand } from "./connect.js";
|
|
30
|
+
import { storageCommand } from "./storage.js";
|
|
31
|
+
import { mcpCommand } from "./mcp.js";
|
|
32
|
+
import { hooksCommand } from "./hooks.js";
|
|
33
|
+
import { agentsCommand } from "./agents.js";
|
|
34
|
+
import { missionCommand } from "./mission.js";
|
|
35
|
+
import { verifyCommand } from "./verify.js";
|
|
36
|
+
import { withDefaultWriters } from "./runtime.js";
|
|
37
|
+
import { formatFocusedHelp } from "../help-topics.js";
|
|
38
|
+
import { formatLocalGuidancePanel } from "../cli/guidance-panel.js";
|
|
39
|
+
import { getLocalizedText } from "../i18n/index.js";
|
|
40
|
+
import { commitCommand, copyCommand, diffCommand, expandCommand, initCommand, modelCommand, planCommand, rewindCommand, unavailableClaudeCommands, usageCommand, } from "./claude-style.js";
|
|
41
|
+
import { getSkillDirs, runSkill } from "../tools/skill.js";
|
|
42
|
+
import { listSkills } from "../skills/registry.js";
|
|
43
|
+
import { existsSync, readdirSync } from "fs";
|
|
44
|
+
import { basename } from "path";
|
|
45
|
+
export const COMMANDS = [
|
|
46
|
+
helpCommand,
|
|
47
|
+
initCommand,
|
|
48
|
+
sessionsCommand,
|
|
49
|
+
resumeCommand,
|
|
50
|
+
rewindCommand,
|
|
51
|
+
checkpointCommand,
|
|
52
|
+
clearCommand,
|
|
53
|
+
statusCommand,
|
|
54
|
+
usageCommand,
|
|
55
|
+
modelCommand,
|
|
56
|
+
planCommand,
|
|
57
|
+
expandCommand,
|
|
58
|
+
diffCommand,
|
|
59
|
+
commitCommand,
|
|
60
|
+
copyCommand,
|
|
61
|
+
skillCommand,
|
|
62
|
+
dashboardCommand,
|
|
63
|
+
configCommand,
|
|
64
|
+
detachCommand,
|
|
65
|
+
compactCommand,
|
|
66
|
+
goalCommand,
|
|
67
|
+
loopCommand,
|
|
68
|
+
tasksCommand,
|
|
69
|
+
permissionsCommand,
|
|
70
|
+
statuslineCommand,
|
|
71
|
+
recapCommand,
|
|
72
|
+
privacyCommand,
|
|
73
|
+
shortcutsCommand,
|
|
74
|
+
exportCommand,
|
|
75
|
+
exportsCommand,
|
|
76
|
+
memoryCommand,
|
|
77
|
+
repomapCommand,
|
|
78
|
+
knowledgeCommand,
|
|
79
|
+
connectCommand,
|
|
80
|
+
verifyCommand,
|
|
81
|
+
dreamCommand,
|
|
82
|
+
distillCommand,
|
|
83
|
+
storageCommand,
|
|
84
|
+
agentsCommand,
|
|
85
|
+
missionCommand,
|
|
86
|
+
mcpCommand,
|
|
87
|
+
hooksCommand,
|
|
88
|
+
doctorCommand,
|
|
89
|
+
contextCommand,
|
|
90
|
+
...unavailableClaudeCommands,
|
|
91
|
+
];
|
|
92
|
+
function isCommandContext(value) {
|
|
93
|
+
return Boolean(value && typeof value === "object" && "agentLoop" in value);
|
|
94
|
+
}
|
|
95
|
+
function normalizeSlashName(value) {
|
|
96
|
+
return value.trim().replace(/^\/+/, "").toLowerCase();
|
|
97
|
+
}
|
|
98
|
+
function isSlashHelpFlag(value) {
|
|
99
|
+
return value === "--help" || value === "-h";
|
|
100
|
+
}
|
|
101
|
+
function writeFocusedSlashHelp(topic, context) {
|
|
102
|
+
for (const line of formatFocusedHelp(topic, { surface: "slash" })) {
|
|
103
|
+
context.writeLine(line);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function levenshteinDistance(left, right) {
|
|
107
|
+
if (left === right)
|
|
108
|
+
return 0;
|
|
109
|
+
if (!left)
|
|
110
|
+
return right.length;
|
|
111
|
+
if (!right)
|
|
112
|
+
return left.length;
|
|
113
|
+
let previous = Array.from({ length: right.length + 1 }, (_, index) => index);
|
|
114
|
+
for (let i = 0; i < left.length; i++) {
|
|
115
|
+
const current = [i + 1];
|
|
116
|
+
for (let j = 0; j < right.length; j++) {
|
|
117
|
+
const substitutionCost = left[i] === right[j] ? 0 : 1;
|
|
118
|
+
current[j + 1] = Math.min(current[j] + 1, previous[j + 1] + 1, previous[j] + substitutionCost);
|
|
119
|
+
}
|
|
120
|
+
previous = current;
|
|
121
|
+
}
|
|
122
|
+
return previous[right.length];
|
|
123
|
+
}
|
|
124
|
+
function scoreSlashCandidate(input, candidate) {
|
|
125
|
+
const normalizedInput = normalizeSlashName(input);
|
|
126
|
+
const normalizedCandidate = normalizeSlashName(candidate);
|
|
127
|
+
if (!normalizedInput || !normalizedCandidate)
|
|
128
|
+
return null;
|
|
129
|
+
if (normalizedCandidate === normalizedInput)
|
|
130
|
+
return 100;
|
|
131
|
+
if (normalizedCandidate.startsWith(normalizedInput) || normalizedInput.startsWith(normalizedCandidate)) {
|
|
132
|
+
return 80 - Math.abs(normalizedCandidate.length - normalizedInput.length);
|
|
133
|
+
}
|
|
134
|
+
if (normalizedCandidate.includes(normalizedInput) || normalizedInput.includes(normalizedCandidate)) {
|
|
135
|
+
return 60 - Math.abs(normalizedCandidate.length - normalizedInput.length);
|
|
136
|
+
}
|
|
137
|
+
const distance = levenshteinDistance(normalizedInput, normalizedCandidate);
|
|
138
|
+
const maxLength = Math.max(normalizedInput.length, normalizedCandidate.length);
|
|
139
|
+
const allowedDistance = maxLength <= 5 ? 1 : 2;
|
|
140
|
+
if (distance > allowedDistance)
|
|
141
|
+
return null;
|
|
142
|
+
const endingBoost = normalizedInput.endsWith("s") && normalizedCandidate.endsWith("s") ? 12 : 0;
|
|
143
|
+
return 45 - distance * 8 - Math.abs(normalizedCandidate.length - normalizedInput.length) + endingBoost;
|
|
144
|
+
}
|
|
145
|
+
export function getSlashCommandCatalog() {
|
|
146
|
+
const commands = COMMANDS.map((command) => ({
|
|
147
|
+
name: command.name,
|
|
148
|
+
aliases: [...(command.aliases ?? [])],
|
|
149
|
+
description: command.description,
|
|
150
|
+
usage: command.usage,
|
|
151
|
+
category: command.category ?? "local",
|
|
152
|
+
argumentHint: command.argumentHint ?? "",
|
|
153
|
+
availability: command.availability ?? "local",
|
|
154
|
+
examples: [...(command.examples ?? [])],
|
|
155
|
+
claudeCompatibleName: command.claudeCompatibleName,
|
|
156
|
+
}));
|
|
157
|
+
return [...commands, ...getLocalSkillCatalogItems(commands)];
|
|
158
|
+
}
|
|
159
|
+
function getSlashCommandNames(item) {
|
|
160
|
+
return [item.name, ...item.aliases];
|
|
161
|
+
}
|
|
162
|
+
function getLocalSkillCatalogItems(existing) {
|
|
163
|
+
const builtinNames = new Set(existing.flatMap(getSlashCommandNames).map(normalizeSlashName));
|
|
164
|
+
const items = [];
|
|
165
|
+
for (const dir of getSkillDirs()) {
|
|
166
|
+
if (!existsSync(dir))
|
|
167
|
+
continue;
|
|
168
|
+
let entries;
|
|
169
|
+
try {
|
|
170
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
for (const entry of entries) {
|
|
176
|
+
const skillName = entry.isDirectory()
|
|
177
|
+
? entry.name
|
|
178
|
+
: entry.isFile() && entry.name.toLowerCase().endsWith(".md")
|
|
179
|
+
? basename(entry.name, ".md")
|
|
180
|
+
: "";
|
|
181
|
+
const normalized = normalizeSlashName(skillName);
|
|
182
|
+
if (!normalized || normalized === "skill" || normalized === "index")
|
|
183
|
+
continue;
|
|
184
|
+
if (builtinNames.has(normalized))
|
|
185
|
+
continue;
|
|
186
|
+
const slashName = `/${skillName}`;
|
|
187
|
+
if (items.some((item) => item.name === slashName))
|
|
188
|
+
continue;
|
|
189
|
+
items.push({
|
|
190
|
+
name: slashName,
|
|
191
|
+
aliases: [],
|
|
192
|
+
description: "本地 skill 直接调用",
|
|
193
|
+
usage: slashName,
|
|
194
|
+
category: "skill",
|
|
195
|
+
argumentHint: "",
|
|
196
|
+
availability: "local",
|
|
197
|
+
examples: [slashName, `/skill ${skillName}`],
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return items;
|
|
202
|
+
}
|
|
203
|
+
export function findSlashCommandSuggestions(input, limit = 3) {
|
|
204
|
+
const suggestions = [];
|
|
205
|
+
for (const item of getSlashCommandCatalog()) {
|
|
206
|
+
for (const name of getSlashCommandNames(item)) {
|
|
207
|
+
const score = scoreSlashCandidate(input, name);
|
|
208
|
+
if (score === null || score < 20)
|
|
209
|
+
continue;
|
|
210
|
+
suggestions.push({
|
|
211
|
+
command: name,
|
|
212
|
+
topic: normalizeSlashName(name),
|
|
213
|
+
score,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return suggestions
|
|
218
|
+
.sort((left, right) => right.score - left.score
|
|
219
|
+
|| normalizeSlashName(right.command).length - normalizeSlashName(left.command).length
|
|
220
|
+
|| left.command.localeCompare(right.command))
|
|
221
|
+
.filter((suggestion, index, sorted) => sorted.findIndex((item) => item.command === suggestion.command) === index)
|
|
222
|
+
.slice(0, limit);
|
|
223
|
+
}
|
|
224
|
+
export function findSlashCompletion(prefix, limit = 5) {
|
|
225
|
+
const rawPrefix = prefix.trim();
|
|
226
|
+
if (!rawPrefix.startsWith("/") || /\s/.test(rawPrefix))
|
|
227
|
+
return [];
|
|
228
|
+
const normalizedPrefix = normalizeSlashName(rawPrefix);
|
|
229
|
+
const catalog = getSlashCommandCatalog();
|
|
230
|
+
const matched = catalog
|
|
231
|
+
.map((item, index) => {
|
|
232
|
+
const names = getSlashCommandNames(item);
|
|
233
|
+
const bestScore = names.reduce((best, name) => {
|
|
234
|
+
const normalizedName = normalizeSlashName(name);
|
|
235
|
+
if (!normalizedName)
|
|
236
|
+
return best;
|
|
237
|
+
if (!normalizedPrefix)
|
|
238
|
+
return Math.max(best, 1);
|
|
239
|
+
if (normalizedName === normalizedPrefix)
|
|
240
|
+
return Math.max(best, 100);
|
|
241
|
+
if (normalizedName.startsWith(normalizedPrefix)) {
|
|
242
|
+
return Math.max(best, 80 - Math.abs(normalizedName.length - normalizedPrefix.length));
|
|
243
|
+
}
|
|
244
|
+
return best;
|
|
245
|
+
}, 0);
|
|
246
|
+
return { item, index, score: bestScore };
|
|
247
|
+
})
|
|
248
|
+
.filter((entry) => entry.score > 0)
|
|
249
|
+
.sort((left, right) => right.score - left.score || left.index - right.index)
|
|
250
|
+
.map((entry) => entry.item);
|
|
251
|
+
return matched.slice(0, Math.max(0, limit));
|
|
252
|
+
}
|
|
253
|
+
export function formatSlashCompletionHint(prefix, width = 80) {
|
|
254
|
+
const matches = findSlashCompletion(prefix, 5);
|
|
255
|
+
if (matches.length === 0)
|
|
256
|
+
return [];
|
|
257
|
+
const commandList = matches.map((item) => item.name).join(" ");
|
|
258
|
+
const line = `补全 : ${commandList} Tab 补全`;
|
|
259
|
+
const safeWidth = Math.max(30, Math.floor(Number(width) || 80));
|
|
260
|
+
return [line.length > safeWidth ? line.slice(0, safeWidth - 1) + "…" : line];
|
|
261
|
+
}
|
|
262
|
+
export function formatSlashCommandPanel(prefix, selectedIndex = 0, width = 80, limit = 8) {
|
|
263
|
+
const t = getLocalizedText();
|
|
264
|
+
const matches = findSlashCompletion(prefix, limit);
|
|
265
|
+
const safeWidth = Math.max(30, Math.floor(Number(width) || 80));
|
|
266
|
+
if (matches.length > 0) {
|
|
267
|
+
const lines = matches.map((item, index) => {
|
|
268
|
+
const marker = index === selectedIndex ? ">" : " ";
|
|
269
|
+
const args = item.argumentHint ? ` ${item.argumentHint}` : "";
|
|
270
|
+
const cat = item.category || "local";
|
|
271
|
+
const cnCat = getChineseCategory(cat, t);
|
|
272
|
+
return truncatePanelLine(`${marker} ${item.name}${args} [${cnCat}] ${item.description}`, safeWidth);
|
|
273
|
+
});
|
|
274
|
+
const panelHint = t.tui?.hints?.panel || "提示 : ↑/↓ 选择 · Tab 补全 · Enter 执行当前输入";
|
|
275
|
+
lines.push(truncatePanelLine(panelHint, safeWidth));
|
|
276
|
+
return lines;
|
|
277
|
+
}
|
|
278
|
+
const hint = findExactSlashCommandForArgumentHint(prefix);
|
|
279
|
+
if (!hint)
|
|
280
|
+
return [];
|
|
281
|
+
const arg = hint.argumentHint || hint.usage.replace(hint.name, "").trim();
|
|
282
|
+
const contHint = t.tui?.hints?.continueInput || "提示 : 继续输入参数 · Enter 执行当前输入";
|
|
283
|
+
return [
|
|
284
|
+
truncatePanelLine(`参数 : ${hint.name}${arg ? ` ${arg}` : ""} ${hint.description}`, safeWidth),
|
|
285
|
+
truncatePanelLine(contHint, safeWidth),
|
|
286
|
+
];
|
|
287
|
+
}
|
|
288
|
+
function truncatePanelLine(line, width) {
|
|
289
|
+
return line.length > width ? line.slice(0, width - 1) + "…" : line;
|
|
290
|
+
}
|
|
291
|
+
function getChineseCategory(cat, t) {
|
|
292
|
+
const cats = t.tui?.slashCategories || {};
|
|
293
|
+
const map = {
|
|
294
|
+
local: cats.common || "常用",
|
|
295
|
+
core: cats.common || "常用",
|
|
296
|
+
session: cats.context || "上下文",
|
|
297
|
+
git: cats.git || "Git",
|
|
298
|
+
memory: cats.memory || "记忆",
|
|
299
|
+
cloud: cats.connectors || "连接器",
|
|
300
|
+
skill: cats.advanced || "高级",
|
|
301
|
+
};
|
|
302
|
+
return cats[cat] || map[cat] || cat;
|
|
303
|
+
}
|
|
304
|
+
export function formatGroupedSlashPanel(width = 80) {
|
|
305
|
+
const t = getLocalizedText();
|
|
306
|
+
const catalog = getSlashCommandCatalog();
|
|
307
|
+
const safeWidth = Math.max(30, Math.floor(Number(width) || 80));
|
|
308
|
+
const groups = {};
|
|
309
|
+
for (const item of catalog) {
|
|
310
|
+
const cat = item.category || "local";
|
|
311
|
+
if (!groups[cat])
|
|
312
|
+
groups[cat] = [];
|
|
313
|
+
groups[cat].push(item);
|
|
314
|
+
}
|
|
315
|
+
const order = ["local", "core", "session", "git", "memory", "cloud", "skill"];
|
|
316
|
+
const lines = [];
|
|
317
|
+
const panelHint = t.tui?.hints?.panel || "提示 : ↑/↓ 选择 · Tab 补全 · Enter 执行当前输入";
|
|
318
|
+
const merged = {};
|
|
319
|
+
for (const key of order) {
|
|
320
|
+
const items = groups[key];
|
|
321
|
+
if (!items || items.length === 0)
|
|
322
|
+
continue;
|
|
323
|
+
const cn = getChineseCategory(key, t);
|
|
324
|
+
if (!merged[cn])
|
|
325
|
+
merged[cn] = [];
|
|
326
|
+
merged[cn].push(...items);
|
|
327
|
+
}
|
|
328
|
+
lines.push(truncatePanelLine("轻灵命令面板 (按 / + Tab 过滤)", safeWidth));
|
|
329
|
+
lines.push(truncatePanelLine("─".repeat(Math.min(safeWidth, 60)), safeWidth));
|
|
330
|
+
for (const [cn, items] of Object.entries(merged)) {
|
|
331
|
+
lines.push(truncatePanelLine(`【${cn}】`, safeWidth));
|
|
332
|
+
for (const item of items.slice(0, 5)) {
|
|
333
|
+
const args = item.argumentHint ? ` ${item.argumentHint}` : "";
|
|
334
|
+
const desc = item.description.length > 30 ? item.description.slice(0, 28) + "…" : item.description;
|
|
335
|
+
lines.push(truncatePanelLine(` ${item.name}${args} ${desc}`, safeWidth));
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
lines.push(truncatePanelLine("─".repeat(Math.min(safeWidth, 60)), safeWidth));
|
|
339
|
+
lines.push(truncatePanelLine(panelHint, safeWidth));
|
|
340
|
+
return lines;
|
|
341
|
+
}
|
|
342
|
+
function findExactSlashCommandForArgumentHint(input) {
|
|
343
|
+
if (!input.startsWith("/") || !/\s$/.test(input))
|
|
344
|
+
return null;
|
|
345
|
+
const cmd = input.trim().split(/\s+/)[0] ?? "";
|
|
346
|
+
if (!cmd)
|
|
347
|
+
return null;
|
|
348
|
+
return getSlashCommandCatalog().find((item) => getSlashCommandNames(item).some((name) => name === cmd)) ?? null;
|
|
349
|
+
}
|
|
350
|
+
export function formatUnknownSlashCommandMessage(cmdName) {
|
|
351
|
+
const t = getLocalizedText();
|
|
352
|
+
const suggestions = findSlashCommandSuggestions(cmdName);
|
|
353
|
+
const normalizedInput = cmdName.replace(/^\/+/, "");
|
|
354
|
+
if (!suggestions.length) {
|
|
355
|
+
return formatLocalGuidancePanel({
|
|
356
|
+
title: `❌ 未知指令: ${cmdName}。`,
|
|
357
|
+
reason: "当前输入不是已注册的 slash 命令。",
|
|
358
|
+
next: "查看全部: /help",
|
|
359
|
+
example: `普通输入: ${normalizedInput}`,
|
|
360
|
+
boundary: t.boundaries.slashCorrection,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
const commands = suggestions.map((suggestion) => suggestion.command).join(", ");
|
|
364
|
+
const primary = suggestions[0];
|
|
365
|
+
return formatLocalGuidancePanel({
|
|
366
|
+
title: `❌ 未知指令: ${cmdName}。`,
|
|
367
|
+
reason: "输入看起来像 slash 命令,但没有精确命中命令目录。",
|
|
368
|
+
next: `你是不是想用: ${commands};可执行: ${primary.command}`,
|
|
369
|
+
example: `查看用法: /help ${primary.topic};普通输入: ${normalizedInput}`,
|
|
370
|
+
boundary: t.boundaries.slashCorrection,
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
export async function handleSlashCommand(input, contextOrAgentLoop) {
|
|
374
|
+
if (!input.startsWith("/"))
|
|
375
|
+
return false;
|
|
376
|
+
const context = isCommandContext(contextOrAgentLoop)
|
|
377
|
+
? withDefaultWriters(contextOrAgentLoop)
|
|
378
|
+
: withDefaultWriters({ agentLoop: contextOrAgentLoop });
|
|
379
|
+
const parts = input.split(/\s+/);
|
|
380
|
+
const cmdName = parts[0].toLowerCase();
|
|
381
|
+
const args = parts.slice(1);
|
|
382
|
+
const hasHelpFlag = args.some(isSlashHelpFlag);
|
|
383
|
+
const cmd = COMMANDS.find(c => c.name === cmdName || c.aliases?.includes(cmdName));
|
|
384
|
+
if (cmd) {
|
|
385
|
+
if (cmd.name !== helpCommand.name && hasHelpFlag) {
|
|
386
|
+
writeFocusedSlashHelp(normalizeSlashName(cmd.name), context);
|
|
387
|
+
return true;
|
|
388
|
+
}
|
|
389
|
+
await cmd.execute(args, context);
|
|
390
|
+
return true;
|
|
391
|
+
}
|
|
392
|
+
if (await tryRunDirectSkill(cmdName, context)) {
|
|
393
|
+
return true;
|
|
394
|
+
}
|
|
395
|
+
if (hasHelpFlag) {
|
|
396
|
+
writeFocusedSlashHelp(normalizeSlashName(cmdName), context);
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
context.writeError(formatUnknownSlashCommandMessage(cmdName));
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
async function tryRunDirectSkill(cmdName, context) {
|
|
403
|
+
const name = normalizeSlashName(cmdName);
|
|
404
|
+
if (!/^[a-z0-9_@/-]+$/i.test(name))
|
|
405
|
+
return false;
|
|
406
|
+
const skills = await listSkills(getSkillDirs());
|
|
407
|
+
if (!skills.some((skill) => normalizeSlashName(skill.name) === name))
|
|
408
|
+
return false;
|
|
409
|
+
const result = await runSkill({ name });
|
|
410
|
+
if (result.is_error) {
|
|
411
|
+
context.writeError(result.output);
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
context.writeLine(result.output);
|
|
415
|
+
}
|
|
416
|
+
return true;
|
|
417
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SlashCommand } from "./types.js";
|
|
2
|
+
export declare function chineseChunk(text: string, maxLen?: number): string[];
|
|
3
|
+
export declare function simpleIndex(dir: string, maxFiles?: number): {
|
|
4
|
+
file: string;
|
|
5
|
+
chunks: string[];
|
|
6
|
+
}[];
|
|
7
|
+
export declare const knowledgeCommand: SlashCommand;
|
|
8
|
+
//# sourceMappingURL=knowledge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"knowledge.d.ts","sourceRoot":"","sources":["../../src/commands/knowledge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA+B1C,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,SAAM,GAAG,MAAM,EAAE,CAoBjE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,SAAK,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,EAAE,CAyB5F;AAED,eAAO,MAAM,gBAAgB,EAAE,YAkH9B,CAAC"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { join } from "path";
|
|
2
|
+
import { readdirSync, readFileSync, statSync } from "fs";
|
|
3
|
+
import { searchLocalMemoryEntries, } from "../memory-report.js";
|
|
4
|
+
function resolveStateDirForKnowledge(context) {
|
|
5
|
+
const agentLoop = context?.agentLoop;
|
|
6
|
+
if (agentLoop?.getRuntimeRootDir) {
|
|
7
|
+
try {
|
|
8
|
+
const root = agentLoop.getRuntimeRootDir();
|
|
9
|
+
if (root)
|
|
10
|
+
return root;
|
|
11
|
+
}
|
|
12
|
+
catch { }
|
|
13
|
+
}
|
|
14
|
+
const envDir = process.env.QLING_FILE_STATE_DIR;
|
|
15
|
+
if (envDir)
|
|
16
|
+
return envDir;
|
|
17
|
+
const ctxState = context?.stateDir || context?.workspaceDir;
|
|
18
|
+
if (ctxState)
|
|
19
|
+
return ctxState;
|
|
20
|
+
return join(require("os").homedir(), ".qling");
|
|
21
|
+
}
|
|
22
|
+
// P3 完善:中文知识库/RAG 最小闭环
|
|
23
|
+
// - 中文友好 chunk(按句/段落)
|
|
24
|
+
// - 本地文件索引(递归简单扫描)
|
|
25
|
+
// - 搜索 + 引用展示(置信度 + 来源片段)
|
|
26
|
+
// - 推荐中文模型
|
|
27
|
+
// 复用 memory 搜索能力;无重型向量DB
|
|
28
|
+
export function chineseChunk(text, maxLen = 400) {
|
|
29
|
+
const chunks = [];
|
|
30
|
+
// 优先按段落,其次中文句子
|
|
31
|
+
let parts = text.split(/\n\s*\n/);
|
|
32
|
+
if (parts.length < 2) {
|
|
33
|
+
parts = text.split(/[。!?;\n]+/).filter(Boolean);
|
|
34
|
+
}
|
|
35
|
+
let current = "";
|
|
36
|
+
for (const p of parts) {
|
|
37
|
+
const s = p.trim();
|
|
38
|
+
if (!s)
|
|
39
|
+
continue;
|
|
40
|
+
if ((current + s).length > maxLen && current) {
|
|
41
|
+
chunks.push(current.trim());
|
|
42
|
+
current = s + "。";
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
current += (current ? " " : "") + s + "。";
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (current.trim())
|
|
49
|
+
chunks.push(current.trim());
|
|
50
|
+
return chunks.length ? chunks : [text.slice(0, maxLen)];
|
|
51
|
+
}
|
|
52
|
+
export function simpleIndex(dir, maxFiles = 20) {
|
|
53
|
+
const results = [];
|
|
54
|
+
try {
|
|
55
|
+
const entries = readdirSync(dir);
|
|
56
|
+
let count = 0;
|
|
57
|
+
for (const e of entries) {
|
|
58
|
+
if (count >= maxFiles)
|
|
59
|
+
break;
|
|
60
|
+
const full = join(dir, e);
|
|
61
|
+
try {
|
|
62
|
+
const st = statSync(full);
|
|
63
|
+
if (st.isDirectory()) {
|
|
64
|
+
// 递归一层
|
|
65
|
+
const sub = simpleIndex(full, Math.max(1, maxFiles - count));
|
|
66
|
+
results.push(...sub);
|
|
67
|
+
count += sub.length;
|
|
68
|
+
}
|
|
69
|
+
else if (/\.(md|txt|ts|js|py|json)$/i.test(e)) {
|
|
70
|
+
const content = readFileSync(full, "utf8").slice(0, 8000);
|
|
71
|
+
const chunks = chineseChunk(content);
|
|
72
|
+
results.push({ file: e, chunks });
|
|
73
|
+
count++;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch { }
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
catch { }
|
|
80
|
+
return results;
|
|
81
|
+
}
|
|
82
|
+
export const knowledgeCommand = {
|
|
83
|
+
name: "/knowledge",
|
|
84
|
+
aliases: ["/知", "/kb", "/rag"],
|
|
85
|
+
description: "本地知识库搜索(中文友好 chunk + 引用)",
|
|
86
|
+
usage: "/knowledge <查询> | /knowledge index <路径>",
|
|
87
|
+
execute: async (args, context) => {
|
|
88
|
+
const sub = (args[0] || "").toLowerCase();
|
|
89
|
+
const queryParts = args.slice(1);
|
|
90
|
+
const query = queryParts.join(" ").trim();
|
|
91
|
+
const t = context.i18n || null; // 未来可接 i18n
|
|
92
|
+
context.writeLine("");
|
|
93
|
+
context.writeLine("📚 【轻灵知识库】本地优先 · 中文 RAG");
|
|
94
|
+
context.writeLine("-----------------------------------------");
|
|
95
|
+
if (!query && sub !== "index" && sub !== "索引") {
|
|
96
|
+
context.writeLine("用法: /knowledge <问题> 或 /knowledge index <目录>");
|
|
97
|
+
context.writeLine("默认模型推荐: DeepSeek / Qwen / GLM + 中文 embedding");
|
|
98
|
+
context.writeLine("边界: 仅本地索引,不上传,不默认联网。");
|
|
99
|
+
context.writeLine("-----------------------------------------");
|
|
100
|
+
context.writeLine("");
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const agentLoop = context.agentLoop;
|
|
104
|
+
const memoryStore = agentLoop?.getMemoryStore?.();
|
|
105
|
+
if (sub === "embed" || sub === "embedding" || sub === "调优") {
|
|
106
|
+
context.writeLine("Embedding 调优 (P3 RAG 细节):");
|
|
107
|
+
context.writeLine(`当前推荐模型: ${process.env.QLING_MEMORY_SEMANTIC_MODEL || "text-embedding-3-small"}`);
|
|
108
|
+
context.writeLine("可用调优: 设置 QLING_MEMORY_SEMANTIC_MODEL=你的模型");
|
|
109
|
+
context.writeLine("维度: dimensions 可在 EmbeddingClient 配置");
|
|
110
|
+
context.writeLine("测试: /knowledge embed test <文本>");
|
|
111
|
+
context.writeLine("边界: 需要 API key 和支持 embeddings 的 endpoint");
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (sub === "index" || sub === "索引") {
|
|
115
|
+
const target = query || process.cwd();
|
|
116
|
+
context.writeLine(`正在索引: ${target} (中文 chunk 策略:按句/段落,max~400字)`);
|
|
117
|
+
const indexed = simpleIndex(target);
|
|
118
|
+
let totalChunks = 0;
|
|
119
|
+
for (const item of indexed) {
|
|
120
|
+
totalChunks += item.chunks.length;
|
|
121
|
+
if (memoryStore && item.chunks.length) {
|
|
122
|
+
try {
|
|
123
|
+
for (const ch of item.chunks.slice(0, 3)) {
|
|
124
|
+
memoryStore.add(`[知识库] ${item.file}: ${ch}`, "knowledge", 0.75, false);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
catch { }
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (memoryStore && typeof memoryStore.saveToDisk === "function") {
|
|
131
|
+
try {
|
|
132
|
+
await memoryStore.saveToDisk();
|
|
133
|
+
}
|
|
134
|
+
catch { }
|
|
135
|
+
}
|
|
136
|
+
context.writeLine(`索引完成:${indexed.length} 个文件,${totalChunks} 个 chunk。`);
|
|
137
|
+
context.writeLine("已尝试合并到本地 memory。使用 /knowledge <问题> 查询。");
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
context.writeLine(`查询: ${query}`);
|
|
141
|
+
context.writeLine("结果 (引用片段 + 置信):");
|
|
142
|
+
let usedRealSearch = false;
|
|
143
|
+
const stateDir = resolveStateDirForKnowledge(context);
|
|
144
|
+
if (stateDir) {
|
|
145
|
+
try {
|
|
146
|
+
const report = await searchLocalMemoryEntries(stateDir, { query, count: 5 });
|
|
147
|
+
if (report.entries && report.entries.length > 0) {
|
|
148
|
+
usedRealSearch = true;
|
|
149
|
+
report.entries.forEach((e, i) => {
|
|
150
|
+
const src = e.source || "memory";
|
|
151
|
+
const conf = (e.score ?? 0.7).toFixed(2);
|
|
152
|
+
const snippet = (e.content || e.preview || "").slice(0, 120).replace(/\n/g, " ");
|
|
153
|
+
const chain = e.metadata?.chain || e.source || src;
|
|
154
|
+
context.writeLine(` ${i + 1}. [${src}] ${snippet}... (置信 ${conf}) 链路: ${chain}`);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
catch { }
|
|
159
|
+
}
|
|
160
|
+
if (!usedRealSearch && memoryStore && typeof memoryStore.search === "function") {
|
|
161
|
+
try {
|
|
162
|
+
const hits = await memoryStore.search(query, 5) || [];
|
|
163
|
+
if (hits.length) {
|
|
164
|
+
usedRealSearch = true;
|
|
165
|
+
hits.slice(0, 5).forEach((h, i) => {
|
|
166
|
+
const src = h.source || "memory";
|
|
167
|
+
const conf = (h.score ?? h.confidence ?? 0.7).toFixed(2);
|
|
168
|
+
const snippet = (h.content || h.entry?.content || "").slice(0, 120).replace(/\n/g, " ");
|
|
169
|
+
const chain = h.metadata?.chain || h.source || src;
|
|
170
|
+
context.writeLine(` ${i + 1}. [${src}] ${snippet}... (置信 ${conf}) 链路: ${chain}`);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch { }
|
|
175
|
+
}
|
|
176
|
+
if (!usedRealSearch) {
|
|
177
|
+
// 演示友好回退 + 模拟 chunk 结果
|
|
178
|
+
const demoChunks = chineseChunk("本地知识库示例:轻灵支持中文 chunk,按段落或标点切分。推荐搭配 Qwen/DeepSeek 使用本地 embedding。");
|
|
179
|
+
context.writeLine(` 1. [demo-chunk] ${demoChunks[0].slice(0, 100)}... (置信 0.65)`);
|
|
180
|
+
context.writeLine(" (提示:运行 /knowledge index . 建立真实索引后重试;启用 semantic_memory 获得真实向量搜索)");
|
|
181
|
+
}
|
|
182
|
+
context.writeLine("");
|
|
183
|
+
context.writeLine("引用: 以上来自本机 memory / 文件索引。");
|
|
184
|
+
context.writeLine("建议模型: Qwen / DeepSeek / GLM (中文理解强) + Ollama 离线");
|
|
185
|
+
context.writeLine("提示: 设置 QLING_FEATURES_SEMANTIC_MEMORY=true 可启用真实 semantic search");
|
|
186
|
+
}
|
|
187
|
+
context.writeLine("-----------------------------------------");
|
|
188
|
+
context.writeLine("离线/私有化: Ollama + 本地 embedding 完全可行。无云上传。");
|
|
189
|
+
context.writeLine("");
|
|
190
|
+
},
|
|
191
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/commands/loop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAiC1C,eAAO,MAAM,WAAW,EAAE,YAgGzB,CAAC"}
|