@cortex-agent/server 2026.5.19-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/defaults/.claude/settings.json +13 -0
- package/defaults/CORTEX.md +15 -0
- package/defaults/config/budget.json +4 -0
- package/defaults/config/session-hooks.json +7 -0
- package/defaults/config/thread-templates.json +528 -0
- package/defaults/context/CORTEX.md +40 -0
- package/defaults/context/decisions/DR-0012.md +54 -0
- package/defaults/context/ideas/CORTEX.md +10 -0
- package/defaults/context/projects/CORTEX.md +25 -0
- package/defaults/context/scans/CORTEX.md +13 -0
- package/defaults/context/user/CORTEX.md +21 -0
- package/defaults/data/schedules.json +52 -0
- package/defaults/gitignore +44 -0
- package/defaults/hooks/ask-user-question-hook.mjs +66 -0
- package/defaults/hooks/cortex-md-injector.mjs +237 -0
- package/defaults/hooks/exit-plan-mode-hook.mjs +84 -0
- package/defaults/hooks/memory-ref-tracker.mjs +154 -0
- package/defaults/hooks/new-session-hook.mjs +83 -0
- package/defaults/hooks/post-task-hook.mjs +63 -0
- package/defaults/hooks/rules-loader.mjs +212 -0
- package/defaults/hooks/sensitive-file-edit.mjs +84 -0
- package/defaults/hooks/session-activity-tracker.mjs +254 -0
- package/defaults/hooks/task-status-check.mjs +218 -0
- package/defaults/hooks/tasks-yaml-guard.mjs +230 -0
- package/defaults/plugins/cortex-coder/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-coder/skills/cli-standards/SKILL.md +208 -0
- package/defaults/plugins/cortex-coder/skills/code-standards/SKILL.md +146 -0
- package/defaults/plugins/cortex-coder/skills/develop/SKILL.md +164 -0
- package/defaults/plugins/cortex-common/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-common/skills/compound/SKILL.md +349 -0
- package/defaults/plugins/cortex-common/skills/compound-simple/SKILL.md +104 -0
- package/defaults/plugins/cortex-common/skills/critique/SKILL.md +88 -0
- package/defaults/plugins/cortex-common/skills/debug-campaign/SKILL.md +508 -0
- package/defaults/plugins/cortex-common/skills/diagnose/SKILL.md +169 -0
- package/defaults/plugins/cortex-common/skills/postmortem/SKILL.md +135 -0
- package/defaults/plugins/cortex-common/skills/solution-design/SKILL.md +183 -0
- package/defaults/plugins/cortex-common/skills/synthesize/SKILL.md +120 -0
- package/defaults/plugins/cortex-stage-gate/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-stage-gate/skills/need-approval/SKILL.md +89 -0
- package/defaults/plugins/cortex-stage-gate/skills/reorient/SKILL.md +163 -0
- package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +425 -0
- package/defaults/plugins/cortex-system/.claude-plugin/plugin.json +5 -0
- package/defaults/plugins/cortex-system/skills/approval/SKILL.md +84 -0
- package/defaults/plugins/cortex-system/skills/client-manage/SKILL.md +199 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/CORTEX.md +8 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/SKILL.md +201 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/CORTEX.md +8 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/extract_session.py +165 -0
- package/defaults/plugins/cortex-system/skills/deep-retrospective/scripts/scan_logs.py +402 -0
- package/defaults/plugins/cortex-system/skills/evolve/SKILL.md +115 -0
- package/defaults/plugins/cortex-system/skills/feedback/SKILL.md +262 -0
- package/defaults/plugins/cortex-system/skills/gravity/SKILL.md +125 -0
- package/defaults/plugins/cortex-system/skills/orient/SKILL.md +310 -0
- package/defaults/plugins/cortex-system/skills/orient-project/SKILL.md +85 -0
- package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +167 -0
- package/defaults/plugins/cortex-system/skills/refresh-skills/SKILL.md +153 -0
- package/defaults/plugins/cortex-system/skills/schedule/SKILL.md +209 -0
- package/defaults/plugins/cortex-system/skills/thread/SKILL.md +478 -0
- package/defaults/plugins/cortex-system/skills/user-learn/SKILL.md +95 -0
- package/defaults/prompts/directives/coder-reviewer.md +106 -0
- package/defaults/prompts/directives/coder.md +90 -0
- package/defaults/prompts/directives/director.md +97 -0
- package/defaults/prompts/directives/doc-reviewer.md +93 -0
- package/defaults/prompts/directives/doc-writer.md +85 -0
- package/defaults/prompts/directives/executor-reviewer.md +96 -0
- package/defaults/prompts/directives/executor.md +85 -0
- package/defaults/prompts/directives/milestone-executor.md +119 -0
- package/defaults/prompts/directives/milestone-reviewer.md +108 -0
- package/defaults/prompts/directives/plan-executor.md +121 -0
- package/defaults/prompts/directives/plan-reviewer.md +99 -0
- package/defaults/prompts/systemPrompts/coder.md +64 -0
- package/defaults/prompts/systemPrompts/direct.md +92 -0
- package/defaults/prompts/systemPrompts/web-opus-4-6.md +68 -0
- package/defaults/prompts/systemPrompts/web-sonnet-4-6.md +76 -0
- package/defaults/prompts/systemPrompts/web.md +50 -0
- package/defaults/prompts/systemPrompts/worker.md +67 -0
- package/defaults/rules/correction-propagation.md +31 -0
- package/defaults/rules/decision-records.md +49 -0
- package/defaults/rules/experiment-format.md +165 -0
- package/defaults/rules/issues-md.md +37 -0
- package/defaults/rules/meta-conventions.md +45 -0
- package/defaults/rules/mission-md.md +47 -0
- package/defaults/rules/overview-md.md +41 -0
- package/defaults/rules/roadmap-md.md +55 -0
- package/defaults/rules/status-md.md +49 -0
- package/defaults/rules/task-system.md +53 -0
- package/dist/agent-adapter/capabilities.d.ts +12 -0
- package/dist/agent-adapter/capabilities.js +52 -0
- package/dist/agent-adapter/claude/adapter-tui.d.ts +140 -0
- package/dist/agent-adapter/claude/adapter-tui.js +422 -0
- package/dist/agent-adapter/claude/adapter.d.ts +85 -0
- package/dist/agent-adapter/claude/adapter.js +771 -0
- package/dist/agent-adapter/claude/cost-from-usage.d.ts +62 -0
- package/dist/agent-adapter/claude/cost-from-usage.js +97 -0
- package/dist/agent-adapter/claude/defaults.d.ts +30 -0
- package/dist/agent-adapter/claude/defaults.js +49 -0
- package/dist/agent-adapter/claude/event-parser.d.ts +28 -0
- package/dist/agent-adapter/claude/event-parser.js +173 -0
- package/dist/agent-adapter/claude/hooks-builder.d.ts +36 -0
- package/dist/agent-adapter/claude/hooks-builder.js +57 -0
- package/dist/agent-adapter/claude/jsonl-tail.d.ts +68 -0
- package/dist/agent-adapter/claude/jsonl-tail.js +344 -0
- package/dist/agent-adapter/claude/spawn-args.d.ts +38 -0
- package/dist/agent-adapter/claude/spawn-args.js +83 -0
- package/dist/agent-adapter/claude/tmux-control.d.ts +69 -0
- package/dist/agent-adapter/claude/tmux-control.js +127 -0
- package/dist/agent-adapter/claude/tool-summarizers.d.ts +2 -0
- package/dist/agent-adapter/claude/tool-summarizers.js +24 -0
- package/dist/agent-adapter/codex/adapter.d.ts +42 -0
- package/dist/agent-adapter/codex/adapter.js +916 -0
- package/dist/agent-adapter/codex/event-parser.d.ts +17 -0
- package/dist/agent-adapter/codex/event-parser.js +41 -0
- package/dist/agent-adapter/codex/spawn-args.d.ts +6 -0
- package/dist/agent-adapter/codex/spawn-args.js +30 -0
- package/dist/agent-adapter/index.d.ts +8 -0
- package/dist/agent-adapter/index.js +33 -0
- package/dist/agent-adapter/normalize/event-stream.d.ts +6 -0
- package/dist/agent-adapter/normalize/event-stream.js +47 -0
- package/dist/agent-adapter/normalize/event-types.d.ts +58 -0
- package/dist/agent-adapter/normalize/event-types.js +5 -0
- package/dist/agent-adapter/normalize/hooks.d.ts +26 -0
- package/dist/agent-adapter/normalize/hooks.js +5 -0
- package/dist/agent-adapter/normalize/prompt-builder.d.ts +6 -0
- package/dist/agent-adapter/normalize/prompt-builder.js +23 -0
- package/dist/agent-adapter/normalize/tool-names.d.ts +6 -0
- package/dist/agent-adapter/normalize/tool-names.js +73 -0
- package/dist/agent-adapter/pi/adapter.d.ts +60 -0
- package/dist/agent-adapter/pi/adapter.js +626 -0
- package/dist/agent-adapter/pi/agent-dir.d.ts +11 -0
- package/dist/agent-adapter/pi/agent-dir.js +34 -0
- package/dist/agent-adapter/pi/event-parser.d.ts +26 -0
- package/dist/agent-adapter/pi/event-parser.js +313 -0
- package/dist/agent-adapter/pi/framing.d.ts +6 -0
- package/dist/agent-adapter/pi/framing.js +35 -0
- package/dist/agent-adapter/pi/hook-bridge.d.ts +59 -0
- package/dist/agent-adapter/pi/hook-bridge.js +233 -0
- package/dist/agent-adapter/pi/mcp-bridge.d.ts +26 -0
- package/dist/agent-adapter/pi/mcp-bridge.js +140 -0
- package/dist/agent-adapter/pi/pi-ext-types.d.ts +90 -0
- package/dist/agent-adapter/pi/pi-ext-types.js +5 -0
- package/dist/agent-adapter/pi/spawn-args.d.ts +20 -0
- package/dist/agent-adapter/pi/spawn-args.js +54 -0
- package/dist/agent-adapter/pi/tool-shims.d.ts +2 -0
- package/dist/agent-adapter/pi/tool-shims.js +181 -0
- package/dist/agent-adapter/types.d.ts +94 -0
- package/dist/agent-adapter/types.js +5 -0
- package/dist/core/async-mutex.d.ts +6 -0
- package/dist/core/async-mutex.js +36 -0
- package/dist/core/cli-utils.d.ts +37 -0
- package/dist/core/cli-utils.js +69 -0
- package/dist/core/config-generator.d.ts +9 -0
- package/dist/core/config-generator.js +58 -0
- package/dist/core/gateway-generator.d.ts +46 -0
- package/dist/core/gateway-generator.js +336 -0
- package/dist/core/log.d.ts +7 -0
- package/dist/core/log.js +103 -0
- package/dist/core/paths.d.ts +32 -0
- package/dist/core/paths.js +49 -0
- package/dist/core/profile-generator.d.ts +65 -0
- package/dist/core/profile-generator.js +310 -0
- package/dist/core/running-executions.d.ts +88 -0
- package/dist/core/running-executions.js +186 -0
- package/dist/core/status-format.d.ts +18 -0
- package/dist/core/status-format.js +31 -0
- package/dist/core/task-parser.d.ts +69 -0
- package/dist/core/task-parser.js +423 -0
- package/dist/core/types/agent-types.d.ts +31 -0
- package/dist/core/types/agent-types.js +5 -0
- package/dist/core/types/thread-types.d.ts +261 -0
- package/dist/core/types/thread-types.js +5 -0
- package/dist/core/utils.d.ts +29 -0
- package/dist/core/utils.js +98 -0
- package/dist/core/version.d.ts +3 -0
- package/dist/core/version.js +12 -0
- package/dist/domain/agents/config.d.ts +58 -0
- package/dist/domain/agents/config.js +313 -0
- package/dist/domain/agents/facade.d.ts +52 -0
- package/dist/domain/agents/facade.js +264 -0
- package/dist/domain/agents/index.d.ts +2 -0
- package/dist/domain/agents/index.js +4 -0
- package/dist/domain/agents/profile-manager.d.ts +54 -0
- package/dist/domain/agents/profile-manager.js +161 -0
- package/dist/domain/costs/codex-event-format.d.ts +4 -0
- package/dist/domain/costs/codex-event-format.js +66 -0
- package/dist/domain/costs/codex-usage-monitor.d.ts +7 -0
- package/dist/domain/costs/codex-usage-monitor.js +72 -0
- package/dist/domain/costs/cost-tracker.d.ts +115 -0
- package/dist/domain/costs/cost-tracker.js +327 -0
- package/dist/domain/costs/gateway-manager.d.ts +6 -0
- package/dist/domain/costs/gateway-manager.js +228 -0
- package/dist/domain/costs/rate-limit-parser.d.ts +11 -0
- package/dist/domain/costs/rate-limit-parser.js +87 -0
- package/dist/domain/costs/rate-limit-throttle.d.ts +32 -0
- package/dist/domain/costs/rate-limit-throttle.js +129 -0
- package/dist/domain/executions/registry.d.ts +20 -0
- package/dist/domain/executions/registry.js +124 -0
- package/dist/domain/mcp/core-server.d.ts +2 -0
- package/dist/domain/mcp/core-server.js +34 -0
- package/dist/domain/mcp/server.d.ts +3 -0
- package/dist/domain/mcp/server.js +78 -0
- package/dist/domain/mcp/tools/context.d.ts +23 -0
- package/dist/domain/mcp/tools/context.js +51 -0
- package/dist/domain/mcp/tools/cortex-md.d.ts +17 -0
- package/dist/domain/mcp/tools/cortex-md.js +36 -0
- package/dist/domain/mcp/tools/cost.d.ts +2 -0
- package/dist/domain/mcp/tools/cost.js +54 -0
- package/dist/domain/mcp/tools/executions.d.ts +2 -0
- package/dist/domain/mcp/tools/executions.js +94 -0
- package/dist/domain/mcp/tools/schedule.d.ts +23 -0
- package/dist/domain/mcp/tools/schedule.js +245 -0
- package/dist/domain/mcp/tools/slack.d.ts +21 -0
- package/dist/domain/mcp/tools/slack.js +124 -0
- package/dist/domain/mcp/tools/task-ops.d.ts +2 -0
- package/dist/domain/mcp/tools/task-ops.js +509 -0
- package/dist/domain/mcp/tools/tui-ask.d.ts +31 -0
- package/dist/domain/mcp/tools/tui-ask.js +108 -0
- package/dist/domain/mcp/tools/tui-plan.d.ts +28 -0
- package/dist/domain/mcp/tools/tui-plan.js +118 -0
- package/dist/domain/mcp/tui-server.d.ts +2 -0
- package/dist/domain/mcp/tui-server.js +69 -0
- package/dist/domain/memory/consolidate.d.ts +55 -0
- package/dist/domain/memory/consolidate.js +471 -0
- package/dist/domain/memory/cortex-md-injector.d.ts +30 -0
- package/dist/domain/memory/cortex-md-injector.js +123 -0
- package/dist/domain/memory/cortex-md-scanner.d.ts +9 -0
- package/dist/domain/memory/cortex-md-scanner.js +67 -0
- package/dist/domain/memory/index-regen.d.ts +19 -0
- package/dist/domain/memory/index-regen.js +398 -0
- package/dist/domain/memory/rules-loader.d.ts +27 -0
- package/dist/domain/memory/rules-loader.js +97 -0
- package/dist/domain/memory/skill-scanner.d.ts +5 -0
- package/dist/domain/memory/skill-scanner.js +132 -0
- package/dist/domain/memory/user-context.d.ts +5 -0
- package/dist/domain/memory/user-context.js +34 -0
- package/dist/domain/memory/watcher.d.ts +2 -0
- package/dist/domain/memory/watcher.js +81 -0
- package/dist/domain/monitor/disk-monitor.d.ts +20 -0
- package/dist/domain/monitor/disk-monitor.js +97 -0
- package/dist/domain/monitor/gpu-monitor.d.ts +26 -0
- package/dist/domain/monitor/gpu-monitor.js +135 -0
- package/dist/domain/remote/client-bootstrap.d.ts +1 -0
- package/dist/domain/remote/client-bootstrap.js +139 -0
- package/dist/domain/remote/client-hot-reload.d.ts +18 -0
- package/dist/domain/remote/client-hot-reload.js +142 -0
- package/dist/domain/remote/client-manager.d.ts +50 -0
- package/dist/domain/remote/client-manager.js +452 -0
- package/dist/domain/remote/cortex-client.d.ts +1 -0
- package/dist/domain/remote/cortex-client.js +704 -0
- package/dist/domain/scheduling/job-registry.d.ts +31 -0
- package/dist/domain/scheduling/job-registry.js +34 -0
- package/dist/domain/scheduling/jobs/_shared.d.ts +14 -0
- package/dist/domain/scheduling/jobs/_shared.js +45 -0
- package/dist/domain/scheduling/jobs/memory-index-regen.d.ts +1 -0
- package/dist/domain/scheduling/jobs/memory-index-regen.js +16 -0
- package/dist/domain/scheduling/jobs/scheduled-task.d.ts +11 -0
- package/dist/domain/scheduling/jobs/scheduled-task.js +186 -0
- package/dist/domain/scheduling/jobs/target-dispatch.d.ts +41 -0
- package/dist/domain/scheduling/jobs/target-dispatch.js +48 -0
- package/dist/domain/scheduling/jobs/task-archive.d.ts +1 -0
- package/dist/domain/scheduling/jobs/task-archive.js +19 -0
- package/dist/domain/scheduling/jobs/task-dispatch.d.ts +12 -0
- package/dist/domain/scheduling/jobs/task-dispatch.js +214 -0
- package/dist/domain/scheduling/runner.d.ts +13 -0
- package/dist/domain/scheduling/runner.js +24 -0
- package/dist/domain/scheduling/schedule-cli.d.ts +16 -0
- package/dist/domain/scheduling/schedule-cli.js +268 -0
- package/dist/domain/scheduling/schedule-command.d.ts +4 -0
- package/dist/domain/scheduling/schedule-command.js +274 -0
- package/dist/domain/scheduling/scheduler.d.ts +86 -0
- package/dist/domain/scheduling/scheduler.js +544 -0
- package/dist/domain/sessions/session-backup.d.ts +49 -0
- package/dist/domain/sessions/session-backup.js +217 -0
- package/dist/domain/sessions/session-hooks.d.ts +103 -0
- package/dist/domain/sessions/session-hooks.js +311 -0
- package/dist/domain/sessions/session-registry.d.ts +21 -0
- package/dist/domain/sessions/session-registry.js +31 -0
- package/dist/domain/sessions/session.d.ts +3 -0
- package/dist/domain/sessions/session.js +14 -0
- package/dist/domain/tasks/archiver.d.ts +9 -0
- package/dist/domain/tasks/archiver.js +123 -0
- package/dist/domain/tasks/dispatch-utils.d.ts +37 -0
- package/dist/domain/tasks/dispatch-utils.js +143 -0
- package/dist/domain/tasks/dispatcher.d.ts +48 -0
- package/dist/domain/tasks/dispatcher.js +285 -0
- package/dist/domain/tasks/lint.d.ts +12 -0
- package/dist/domain/tasks/lint.js +102 -0
- package/dist/domain/tasks/mutator.d.ts +21 -0
- package/dist/domain/tasks/mutator.js +208 -0
- package/dist/domain/tasks/parser.d.ts +1 -0
- package/dist/domain/tasks/parser.js +6 -0
- package/dist/domain/tasks/pending-tracker.d.ts +67 -0
- package/dist/domain/tasks/pending-tracker.js +163 -0
- package/dist/domain/tasks/recommendation/extractor.d.ts +12 -0
- package/dist/domain/tasks/recommendation/extractor.js +563 -0
- package/dist/domain/tasks/recommendation/patterns.d.ts +11 -0
- package/dist/domain/tasks/recommendation/patterns.js +99 -0
- package/dist/domain/tasks/recommendation/types.d.ts +67 -0
- package/dist/domain/tasks/recommendation/types.js +5 -0
- package/dist/domain/tasks/store.d.ts +1 -0
- package/dist/domain/tasks/store.js +3 -0
- package/dist/domain/tasks/system/cortex-run.d.ts +24 -0
- package/dist/domain/tasks/system/cortex-run.js +342 -0
- package/dist/domain/tasks/system/task-cli.d.ts +49 -0
- package/dist/domain/tasks/system/task-cli.js +664 -0
- package/dist/domain/tasks/system/task-completion.d.ts +22 -0
- package/dist/domain/tasks/system/task-completion.js +89 -0
- package/dist/domain/tasks/system/task-id-utils.d.ts +24 -0
- package/dist/domain/tasks/system/task-id-utils.js +84 -0
- package/dist/domain/tasks/system/task-lifecycle-edit.d.ts +34 -0
- package/dist/domain/tasks/system/task-lifecycle-edit.js +208 -0
- package/dist/domain/tasks/system/task-lock.d.ts +25 -0
- package/dist/domain/tasks/system/task-lock.js +139 -0
- package/dist/domain/tasks/system/task-mutations.d.ts +31 -0
- package/dist/domain/tasks/system/task-mutations.js +110 -0
- package/dist/domain/tasks/system/task-process.d.ts +37 -0
- package/dist/domain/tasks/system/task-process.js +119 -0
- package/dist/domain/tasks/system/task-state.d.ts +70 -0
- package/dist/domain/tasks/system/task-state.js +176 -0
- package/dist/domain/threads/artifact-io.d.ts +18 -0
- package/dist/domain/threads/artifact-io.js +182 -0
- package/dist/domain/threads/auto-thread.d.ts +3 -0
- package/dist/domain/threads/auto-thread.js +19 -0
- package/dist/domain/threads/hook-runner.d.ts +4 -0
- package/dist/domain/threads/hook-runner.js +250 -0
- package/dist/domain/threads/index.d.ts +5 -0
- package/dist/domain/threads/index.js +7 -0
- package/dist/domain/threads/prompt-builder.d.ts +25 -0
- package/dist/domain/threads/prompt-builder.js +176 -0
- package/dist/domain/threads/runner.d.ts +83 -0
- package/dist/domain/threads/runner.js +434 -0
- package/dist/domain/threads/state-machine.d.ts +61 -0
- package/dist/domain/threads/state-machine.js +440 -0
- package/dist/domain/threads/template-loader.d.ts +20 -0
- package/dist/domain/threads/template-loader.js +189 -0
- package/dist/domain/threads/template-resolver.d.ts +1 -0
- package/dist/domain/threads/template-resolver.js +95 -0
- package/dist/domain/threads/utils.d.ts +19 -0
- package/dist/domain/threads/utils.js +49 -0
- package/dist/entry/app.d.ts +1 -0
- package/dist/entry/app.js +234 -0
- package/dist/entry/cli.d.ts +12 -0
- package/dist/entry/cli.js +254 -0
- package/dist/entry/daemon.d.ts +11 -0
- package/dist/entry/daemon.js +521 -0
- package/dist/entry/init.d.ts +93 -0
- package/dist/entry/init.js +1299 -0
- package/dist/entry/startup-helpers.d.ts +2 -0
- package/dist/entry/startup-helpers.js +56 -0
- package/dist/entry/startup-notify.d.ts +10 -0
- package/dist/entry/startup-notify.js +20 -0
- package/dist/events/event-bus.d.ts +42 -0
- package/dist/events/event-bus.js +84 -0
- package/dist/events/event-logger.d.ts +12 -0
- package/dist/events/event-logger.js +135 -0
- package/dist/events/event-replay.d.ts +1 -0
- package/dist/events/event-replay.js +51 -0
- package/dist/events/event-types.d.ts +145 -0
- package/dist/events/event-types.js +5 -0
- package/dist/events/index.d.ts +5 -0
- package/dist/events/index.js +6 -0
- package/dist/hooks/ask-user-question-hook.mjs +66 -0
- package/dist/hooks/cortex-md-injector.mjs +237 -0
- package/dist/hooks/exit-plan-mode-hook.mjs +84 -0
- package/dist/hooks/memory-ref-tracker.mjs +154 -0
- package/dist/hooks/new-session-hook.mjs +83 -0
- package/dist/hooks/post-task-hook.mjs +63 -0
- package/dist/hooks/rules-loader.mjs +212 -0
- package/dist/hooks/sensitive-file-edit.mjs +84 -0
- package/dist/hooks/session-activity-tracker.mjs +254 -0
- package/dist/hooks/task-status-check.mjs +218 -0
- package/dist/hooks/tasks-yaml-guard.mjs +230 -0
- package/dist/orchestration/agent-runner.d.ts +72 -0
- package/dist/orchestration/agent-runner.js +289 -0
- package/dist/orchestration/busy-tracker.d.ts +12 -0
- package/dist/orchestration/busy-tracker.js +35 -0
- package/dist/orchestration/channel-queue.d.ts +18 -0
- package/dist/orchestration/channel-queue.js +32 -0
- package/dist/orchestration/dispatch-reconciler.d.ts +1 -0
- package/dist/orchestration/dispatch-reconciler.js +16 -0
- package/dist/orchestration/durable-helpers.d.ts +4 -0
- package/dist/orchestration/durable-helpers.js +42 -0
- package/dist/orchestration/interactions/ask-user-question.d.ts +32 -0
- package/dist/orchestration/interactions/ask-user-question.js +182 -0
- package/dist/orchestration/interactions/command-action-router.d.ts +47 -0
- package/dist/orchestration/interactions/command-action-router.js +91 -0
- package/dist/orchestration/interactions/interaction-handlers.d.ts +5 -0
- package/dist/orchestration/interactions/interaction-handlers.js +279 -0
- package/dist/orchestration/interactions/plan-approvals.d.ts +47 -0
- package/dist/orchestration/interactions/plan-approvals.js +77 -0
- package/dist/orchestration/interactions/plan-handler.d.ts +6 -0
- package/dist/orchestration/interactions/plan-handler.js +12 -0
- package/dist/orchestration/lifecycle.d.ts +50 -0
- package/dist/orchestration/lifecycle.js +308 -0
- package/dist/orchestration/orchestrator.d.ts +29 -0
- package/dist/orchestration/orchestrator.js +25 -0
- package/dist/orchestration/routing/commands/cancel.d.ts +10 -0
- package/dist/orchestration/routing/commands/cancel.js +136 -0
- package/dist/orchestration/routing/commands/channel.d.ts +11 -0
- package/dist/orchestration/routing/commands/channel.js +219 -0
- package/dist/orchestration/routing/commands/command-context.d.ts +29 -0
- package/dist/orchestration/routing/commands/command-context.js +4 -0
- package/dist/orchestration/routing/commands/cost.d.ts +3 -0
- package/dist/orchestration/routing/commands/cost.js +22 -0
- package/dist/orchestration/routing/commands/device.d.ts +6 -0
- package/dist/orchestration/routing/commands/device.js +83 -0
- package/dist/orchestration/routing/commands/dispatch.d.ts +2 -0
- package/dist/orchestration/routing/commands/dispatch.js +49 -0
- package/dist/orchestration/routing/commands/index.d.ts +15 -0
- package/dist/orchestration/routing/commands/index.js +130 -0
- package/dist/orchestration/routing/commands/mode.d.ts +13 -0
- package/dist/orchestration/routing/commands/mode.js +290 -0
- package/dist/orchestration/routing/commands/nvtop.d.ts +3 -0
- package/dist/orchestration/routing/commands/nvtop.js +103 -0
- package/dist/orchestration/routing/commands/orient.d.ts +2 -0
- package/dist/orchestration/routing/commands/orient.js +3 -0
- package/dist/orchestration/routing/commands/schedule.d.ts +4 -0
- package/dist/orchestration/routing/commands/schedule.js +132 -0
- package/dist/orchestration/routing/commands/sendfile.d.ts +2 -0
- package/dist/orchestration/routing/commands/sendfile.js +92 -0
- package/dist/orchestration/routing/commands/session.d.ts +9 -0
- package/dist/orchestration/routing/commands/session.js +153 -0
- package/dist/orchestration/routing/commands/status.d.ts +7 -0
- package/dist/orchestration/routing/commands/status.js +180 -0
- package/dist/orchestration/routing/commands/tail.d.ts +2 -0
- package/dist/orchestration/routing/commands/tail.js +73 -0
- package/dist/orchestration/routing/commands/task.d.ts +6 -0
- package/dist/orchestration/routing/commands/task.js +142 -0
- package/dist/orchestration/routing/commands/thread-handlers.d.ts +2 -0
- package/dist/orchestration/routing/commands/thread-handlers.js +138 -0
- package/dist/orchestration/routing/commands/thread.d.ts +2 -0
- package/dist/orchestration/routing/commands/thread.js +2 -0
- package/dist/orchestration/routing/edit-handler.d.ts +24 -0
- package/dist/orchestration/routing/edit-handler.js +161 -0
- package/dist/orchestration/routing/file-handler.d.ts +6 -0
- package/dist/orchestration/routing/file-handler.js +23 -0
- package/dist/orchestration/routing/hook-bridge-subscribers.d.ts +4 -0
- package/dist/orchestration/routing/hook-bridge-subscribers.js +79 -0
- package/dist/orchestration/routing/hook-bridge.d.ts +30 -0
- package/dist/orchestration/routing/hook-bridge.js +112 -0
- package/dist/orchestration/routing/message-router.d.ts +6 -0
- package/dist/orchestration/routing/message-router.js +70 -0
- package/dist/orchestration/routing/webhook.d.ts +10 -0
- package/dist/orchestration/routing/webhook.js +239 -0
- package/dist/orchestration/status-helpers.d.ts +66 -0
- package/dist/orchestration/status-helpers.js +222 -0
- package/dist/orchestration/superseded-edits.d.ts +22 -0
- package/dist/orchestration/superseded-edits.js +31 -0
- package/dist/orchestration/thread-executor.d.ts +31 -0
- package/dist/orchestration/thread-executor.js +234 -0
- package/dist/platform/adapter.d.ts +28 -0
- package/dist/platform/adapter.js +5 -0
- package/dist/platform/adapters/feishu.d.ts +66 -0
- package/dist/platform/adapters/feishu.js +558 -0
- package/dist/platform/adapters/index.d.ts +16 -0
- package/dist/platform/adapters/index.js +65 -0
- package/dist/platform/adapters/slack.d.ts +90 -0
- package/dist/platform/adapters/slack.js +630 -0
- package/dist/platform/index.d.ts +12 -0
- package/dist/platform/index.js +10 -0
- package/dist/platform/interactive-builder.d.ts +27 -0
- package/dist/platform/interactive-builder.js +120 -0
- package/dist/platform/testing.d.ts +100 -0
- package/dist/platform/testing.js +190 -0
- package/dist/platform/tool-trace.d.ts +33 -0
- package/dist/platform/tool-trace.js +165 -0
- package/dist/platform/types.d.ts +176 -0
- package/dist/platform/types.js +5 -0
- package/dist/platform/utils/rate-limiter.d.ts +92 -0
- package/dist/platform/utils/rate-limiter.js +213 -0
- package/dist/platform/virtual-message.d.ts +68 -0
- package/dist/platform/virtual-message.js +464 -0
- package/dist/store/atomic-write.d.ts +6 -0
- package/dist/store/atomic-write.js +18 -0
- package/dist/store/channel-repo.d.ts +21 -0
- package/dist/store/channel-repo.js +55 -0
- package/dist/store/conversation-ledger-repo.d.ts +86 -0
- package/dist/store/conversation-ledger-repo.js +220 -0
- package/dist/store/cost-repo.d.ts +57 -0
- package/dist/store/cost-repo.js +135 -0
- package/dist/store/execution-repo.d.ts +172 -0
- package/dist/store/execution-repo.js +343 -0
- package/dist/store/in-memory-repository.d.ts +14 -0
- package/dist/store/in-memory-repository.js +31 -0
- package/dist/store/json-repository.d.ts +51 -0
- package/dist/store/json-repository.js +118 -0
- package/dist/store/outbound-queue.d.ts +65 -0
- package/dist/store/outbound-queue.js +269 -0
- package/dist/store/profile-repo.d.ts +36 -0
- package/dist/store/profile-repo.js +144 -0
- package/dist/store/project-dir-repo.d.ts +22 -0
- package/dist/store/project-dir-repo.js +60 -0
- package/dist/store/schedule-repo.d.ts +92 -0
- package/dist/store/schedule-repo.js +88 -0
- package/dist/store/session-registry-repo.d.ts +38 -0
- package/dist/store/session-registry-repo.js +96 -0
- package/dist/store/session-repo.d.ts +14 -0
- package/dist/store/session-repo.js +56 -0
- package/dist/store/task-repo.d.ts +41 -0
- package/dist/store/task-repo.js +137 -0
- package/dist/store/thread-repo.d.ts +50 -0
- package/dist/store/thread-repo.js +190 -0
- package/package.json +58 -0
- package/scripts/postinstall-restart-trigger.mjs +39 -0
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
// input: project markdown files + CLI args
|
|
2
|
+
// output: scanProjectRecommendations + runCli
|
|
3
|
+
// pos: recommendation/implied task extraction CLI
|
|
4
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
|
+
import * as fs from 'node:fs';
|
|
6
|
+
import * as os from 'node:os';
|
|
7
|
+
import * as path from 'node:path';
|
|
8
|
+
import { parseArgs } from 'node:util';
|
|
9
|
+
import { parse as yamlParse } from 'yaml';
|
|
10
|
+
import { isMainModule, PROJECTS_DIR } from '../../../core/utils.js';
|
|
11
|
+
import { formatHelp } from '../../../core/cli-utils.js';
|
|
12
|
+
import { RECOMMENDATION_HEADER_RE, ANTI_RECOMMENDATION_HEADERS, IMPLIED_TASK_PATTERNS, ACTION_VERBS, NEGATIVE_PATTERNS, STOP_WORDS, EXP_HEADER_RE, DATE_RE, REFLECTION_FIELDS_RE, FINDINGS_HEADER_RE, } from './patterns.js';
|
|
13
|
+
function daysAgoIso(days) {
|
|
14
|
+
const value = new Date();
|
|
15
|
+
value.setDate(value.getDate() - days);
|
|
16
|
+
return value.toISOString().slice(0, 10);
|
|
17
|
+
}
|
|
18
|
+
function extractRecommendationSections(content, sourceFile) {
|
|
19
|
+
const lines = content.split('\n');
|
|
20
|
+
const sections = [];
|
|
21
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
22
|
+
const match = lines[i].match(RECOMMENDATION_HEADER_RE);
|
|
23
|
+
if (!match)
|
|
24
|
+
continue;
|
|
25
|
+
const headerLevel = match[1].length;
|
|
26
|
+
const header = match[2].trim();
|
|
27
|
+
const bodyLines = [];
|
|
28
|
+
for (let j = i + 1; j < lines.length; j += 1) {
|
|
29
|
+
const nextMatch = lines[j].match(/^(#{2,4})\s+/);
|
|
30
|
+
if (nextMatch && nextMatch[1].length <= headerLevel)
|
|
31
|
+
break;
|
|
32
|
+
bodyLines.push(lines[j]);
|
|
33
|
+
}
|
|
34
|
+
const body = bodyLines.join('\n').trim();
|
|
35
|
+
if (body) {
|
|
36
|
+
sections.push({ header, body, source_file: sourceFile });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return sections;
|
|
40
|
+
}
|
|
41
|
+
const LIST_ITEM_RE = /^(?:\d+\.\s+|- \[[ x]\]\s+|- )/;
|
|
42
|
+
function makeRecommendation(text, sourceId, sectionHeader, sourceFile) {
|
|
43
|
+
return { source_id: sourceId, section_header: sectionHeader, text: text.trim(), source_file: sourceFile };
|
|
44
|
+
}
|
|
45
|
+
function parseRecommendations(body, sourceId, sectionHeader, sourceFile) {
|
|
46
|
+
if (!body.trim())
|
|
47
|
+
return [];
|
|
48
|
+
const recommendations = [];
|
|
49
|
+
let current = null;
|
|
50
|
+
const flush = () => {
|
|
51
|
+
if (current != null)
|
|
52
|
+
recommendations.push(makeRecommendation(current, sourceId, sectionHeader, sourceFile));
|
|
53
|
+
current = null;
|
|
54
|
+
};
|
|
55
|
+
for (const line of body.split('\n')) {
|
|
56
|
+
if (LIST_ITEM_RE.test(line)) {
|
|
57
|
+
flush();
|
|
58
|
+
current = line.replace(LIST_ITEM_RE, '').trim();
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (current != null && /^\s+\S/.test(line)) {
|
|
62
|
+
current += ` ${line.trim()}`;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (current != null && line.trim() === '')
|
|
66
|
+
continue;
|
|
67
|
+
if (current != null)
|
|
68
|
+
flush();
|
|
69
|
+
}
|
|
70
|
+
flush();
|
|
71
|
+
return recommendations;
|
|
72
|
+
}
|
|
73
|
+
const REFLECTION_SKIP_EXACT = new Set(['无', 'N/A', '无需调整', '已对齐', '无特别调整']);
|
|
74
|
+
function matchReflectionField(line, currentExpId, currentDate, sourceFile) {
|
|
75
|
+
const trimmed = line.trim();
|
|
76
|
+
for (const [fieldName, pattern] of Object.entries(REFLECTION_FIELDS_RE)) {
|
|
77
|
+
const m = trimmed.match(pattern);
|
|
78
|
+
if (!m)
|
|
79
|
+
continue;
|
|
80
|
+
let text = m[1].trim();
|
|
81
|
+
if (REFLECTION_SKIP_EXACT.has(text))
|
|
82
|
+
return null;
|
|
83
|
+
if (text.startsWith('无。') || text.startsWith('无,') || text.startsWith('无需'))
|
|
84
|
+
return null;
|
|
85
|
+
text = text.replace(/\s*---\s*$/, '');
|
|
86
|
+
return { experiment_id: currentExpId, field_name: fieldName, content: text, experiment_date: currentDate, source_file: sourceFile };
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
function extractReflectionFields(content, sourceFile, days = 7) {
|
|
91
|
+
const cutoff = daysAgoIso(days);
|
|
92
|
+
const results = [];
|
|
93
|
+
let currentExpId = null;
|
|
94
|
+
let currentDate = null;
|
|
95
|
+
for (const line of content.split('\n')) {
|
|
96
|
+
const expMatch = line.match(EXP_HEADER_RE);
|
|
97
|
+
if (expMatch) {
|
|
98
|
+
currentExpId = expMatch[1];
|
|
99
|
+
currentDate = null;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const dateMatch = line.match(DATE_RE);
|
|
103
|
+
if (dateMatch && currentExpId) {
|
|
104
|
+
currentDate = dateMatch[1];
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (currentDate && currentDate < cutoff)
|
|
108
|
+
continue;
|
|
109
|
+
if (!currentExpId)
|
|
110
|
+
continue;
|
|
111
|
+
const field = matchReflectionField(line, currentExpId, currentDate, sourceFile);
|
|
112
|
+
if (field)
|
|
113
|
+
results.push(field);
|
|
114
|
+
}
|
|
115
|
+
return results;
|
|
116
|
+
}
|
|
117
|
+
function detectImpliedTaskPatterns(findingText, sourceId, sourceFile) {
|
|
118
|
+
const results = [];
|
|
119
|
+
for (const entry of IMPLIED_TASK_PATTERNS) {
|
|
120
|
+
for (const signal of entry.signals) {
|
|
121
|
+
if (signal.test(findingText)) {
|
|
122
|
+
results.push({
|
|
123
|
+
pattern: entry.pattern,
|
|
124
|
+
finding_text: findingText.slice(0, 200),
|
|
125
|
+
source_id: sourceId,
|
|
126
|
+
suggested_task_type: entry.suggested_task_type,
|
|
127
|
+
source_file: sourceFile,
|
|
128
|
+
});
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return results;
|
|
134
|
+
}
|
|
135
|
+
function flushConclusion(results, currentDate, cutoff, currentExpId, conclusionLines, sourceFile) {
|
|
136
|
+
if (!currentExpId || conclusionLines.length === 0)
|
|
137
|
+
return;
|
|
138
|
+
if (currentDate && currentDate < cutoff)
|
|
139
|
+
return;
|
|
140
|
+
const text = conclusionLines.join('\n').trim();
|
|
141
|
+
if (!text)
|
|
142
|
+
return;
|
|
143
|
+
results.push(...detectImpliedTaskPatterns(text, currentExpId, sourceFile));
|
|
144
|
+
}
|
|
145
|
+
function processExperimentLine(line, state, results, cutoff, sourceFile) {
|
|
146
|
+
const expMatch = line.match(EXP_HEADER_RE);
|
|
147
|
+
if (expMatch) {
|
|
148
|
+
flushConclusion(results, state.currentDate, cutoff, state.currentExpId, state.conclusionLines, sourceFile);
|
|
149
|
+
state.currentExpId = expMatch[1];
|
|
150
|
+
state.currentDate = null;
|
|
151
|
+
state.inConclusion = false;
|
|
152
|
+
state.conclusionLines = [];
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const dateMatch = line.match(DATE_RE);
|
|
156
|
+
if (dateMatch && state.currentExpId) {
|
|
157
|
+
state.currentDate = dateMatch[1];
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const conclusionMatch = line.match(FINDINGS_HEADER_RE);
|
|
161
|
+
if (conclusionMatch) {
|
|
162
|
+
flushConclusion(results, state.currentDate, cutoff, state.currentExpId, state.conclusionLines, sourceFile);
|
|
163
|
+
state.inConclusion = true;
|
|
164
|
+
state.conclusionLevel = conclusionMatch[1].length;
|
|
165
|
+
state.conclusionLines = [];
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (!state.inConclusion)
|
|
169
|
+
return;
|
|
170
|
+
const headerMatch = line.match(/^(#{2,4})\s+/);
|
|
171
|
+
if (headerMatch && headerMatch[1].length <= state.conclusionLevel) {
|
|
172
|
+
flushConclusion(results, state.currentDate, cutoff, state.currentExpId, state.conclusionLines, sourceFile);
|
|
173
|
+
state.inConclusion = false;
|
|
174
|
+
state.conclusionLines = [];
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
state.conclusionLines.push(line);
|
|
178
|
+
}
|
|
179
|
+
function extractImpliedTasksFromExperiments(content, sourceFile, days = 7) {
|
|
180
|
+
const cutoff = daysAgoIso(days);
|
|
181
|
+
const results = [];
|
|
182
|
+
const state = { currentExpId: null, currentDate: null, inConclusion: false, conclusionLevel: 0, conclusionLines: [] };
|
|
183
|
+
for (const line of content.split('\n')) {
|
|
184
|
+
processExperimentLine(line, state, results, cutoff, sourceFile);
|
|
185
|
+
}
|
|
186
|
+
flushConclusion(results, state.currentDate, cutoff, state.currentExpId, state.conclusionLines, sourceFile);
|
|
187
|
+
return results;
|
|
188
|
+
}
|
|
189
|
+
function isActionable(text) {
|
|
190
|
+
for (const pattern of NEGATIVE_PATTERNS) {
|
|
191
|
+
if (pattern.test(text))
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
const firstWord = (text.split(/\s+/)[0] || '').toLowerCase().replace(/[.,;:]+$/, '').replace(/[^a-z]/g, '');
|
|
195
|
+
if (ACTION_VERBS.has(firstWord))
|
|
196
|
+
return true;
|
|
197
|
+
for (const sentence of text.split(/[.;]\s+/)) {
|
|
198
|
+
const word = (sentence.trim().split(/\s+/)[0] || '').toLowerCase().replace(/[.,;:]+$/, '').replace(/[^a-z]/g, '');
|
|
199
|
+
if (ACTION_VERBS.has(word))
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
function extractKeywords(text) {
|
|
205
|
+
return new Set(text
|
|
206
|
+
.toLowerCase()
|
|
207
|
+
.replace(/[^a-z0-9\s-]/g, ' ')
|
|
208
|
+
.split(/\s+/)
|
|
209
|
+
.filter((word) => word.length > 2 && !STOP_WORDS.has(word)));
|
|
210
|
+
}
|
|
211
|
+
function keywordOverlap(a, b) {
|
|
212
|
+
if (a.size === 0 || b.size === 0)
|
|
213
|
+
return 0;
|
|
214
|
+
const intersection = [...a].filter((value) => b.has(value)).length;
|
|
215
|
+
const union = new Set([...a, ...b]).size;
|
|
216
|
+
return union === 0 ? 0 : intersection / union;
|
|
217
|
+
}
|
|
218
|
+
function deduplicateCandidates(candidates, existingTasksContent) {
|
|
219
|
+
let existingTasks = [];
|
|
220
|
+
try {
|
|
221
|
+
const parsed = yamlParse(existingTasksContent);
|
|
222
|
+
if (parsed && Array.isArray(parsed.tasks)) {
|
|
223
|
+
existingTasks = parsed.tasks.map((t) => ({
|
|
224
|
+
text: String(t.text ?? ''),
|
|
225
|
+
why: String(t.why ?? ''),
|
|
226
|
+
textKeywords: extractKeywords(String(t.text ?? '')),
|
|
227
|
+
}));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
// If YAML parsing fails, fall back to no dedup (content is corrupt/missing)
|
|
232
|
+
}
|
|
233
|
+
for (const candidate of candidates) {
|
|
234
|
+
if (candidate.source_id && existingTasksContent.includes(candidate.source_id)) {
|
|
235
|
+
candidate.is_duplicate = true;
|
|
236
|
+
candidate.duplicate_of = `source-id match: ${candidate.source_id}`;
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
if (candidate.is_duplicate)
|
|
240
|
+
continue;
|
|
241
|
+
const candidateKeywords = extractKeywords(candidate.text);
|
|
242
|
+
for (const existing of existingTasks) {
|
|
243
|
+
if (keywordOverlap(candidateKeywords, existing.textKeywords) > 0.5) {
|
|
244
|
+
candidate.is_duplicate = true;
|
|
245
|
+
candidate.duplicate_of = `keyword overlap: ${existing.text.slice(0, 80)}`;
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return candidates;
|
|
251
|
+
}
|
|
252
|
+
function cleanMarkdown(text) {
|
|
253
|
+
return text
|
|
254
|
+
.replace(/\*\*(.+?)\*\*/g, '$1')
|
|
255
|
+
.replace(/\*(.+?)\*/g, '$1')
|
|
256
|
+
.replace(/`(.+?)`/g, '$1')
|
|
257
|
+
.trim();
|
|
258
|
+
}
|
|
259
|
+
function truncate(text, maxLen = 120) {
|
|
260
|
+
const cleaned = cleanMarkdown(text);
|
|
261
|
+
const first = cleaned.match(/^[^.]+(?:\.|$)/);
|
|
262
|
+
let summary = (first ? first[0] : cleaned).trim();
|
|
263
|
+
if (summary) {
|
|
264
|
+
summary = summary[0].toUpperCase() + summary.slice(1);
|
|
265
|
+
}
|
|
266
|
+
summary = summary.replace(/\.$/, '');
|
|
267
|
+
return summary.length > maxLen ? `${summary.slice(0, maxLen - 3)}...` : summary;
|
|
268
|
+
}
|
|
269
|
+
function summarize(text, maxLen = 80) {
|
|
270
|
+
const cleaned = cleanMarkdown(text);
|
|
271
|
+
const first = cleaned.match(/^[^.]+(?:\.|$)/);
|
|
272
|
+
const summary = (first ? first[0] : cleaned).replace(/\.$/, '');
|
|
273
|
+
return summary.length > maxLen ? `${summary.slice(0, maxLen - 3)}...` : summary;
|
|
274
|
+
}
|
|
275
|
+
function recommendationToCandidate(recommendation) {
|
|
276
|
+
if (ANTI_RECOMMENDATION_HEADERS.has(recommendation.section_header.toLowerCase()))
|
|
277
|
+
return null;
|
|
278
|
+
if (!isActionable(recommendation.text))
|
|
279
|
+
return null;
|
|
280
|
+
return {
|
|
281
|
+
text: truncate(recommendation.text),
|
|
282
|
+
why: `From ${recommendation.source_id} — ${summarize(recommendation.text)}`,
|
|
283
|
+
done_when: `${truncate(recommendation.text, 100)} is complete and verified`,
|
|
284
|
+
source_id: recommendation.source_id,
|
|
285
|
+
source_type: 'recommendation',
|
|
286
|
+
pattern: undefined,
|
|
287
|
+
is_duplicate: false,
|
|
288
|
+
duplicate_of: undefined,
|
|
289
|
+
source_file: recommendation.source_file,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
function impliedTaskToCandidate(task) {
|
|
293
|
+
const descriptions = {
|
|
294
|
+
'failed-success-criterion': 'Investigate failed success criterion and redesign experiment protocol',
|
|
295
|
+
'insufficient-sample': 'Run larger-scale replication with sufficient sample size',
|
|
296
|
+
'identified-confound': 'Design controlled follow-up experiment to isolate confound',
|
|
297
|
+
'partial-confirmation': 'Refine hypothesis and run targeted investigation',
|
|
298
|
+
'unexplained-result': 'Investigate unexplained result and diagnose root cause',
|
|
299
|
+
'multi-phase-plan': 'Verify all phases have corresponding TASKS.yaml entries',
|
|
300
|
+
};
|
|
301
|
+
const description = descriptions[task.pattern] || task.suggested_task_type;
|
|
302
|
+
const preview = task.finding_text.slice(0, 80).replace(/\n/g, ' ');
|
|
303
|
+
return {
|
|
304
|
+
text: `${description} (${task.source_id})`,
|
|
305
|
+
why: `From ${task.source_id} — "${preview}..."`,
|
|
306
|
+
done_when: `${task.suggested_task_type} is complete and verified`,
|
|
307
|
+
source_id: task.source_id,
|
|
308
|
+
source_type: 'implied-task',
|
|
309
|
+
pattern: task.pattern,
|
|
310
|
+
is_duplicate: false,
|
|
311
|
+
duplicate_of: undefined,
|
|
312
|
+
source_file: task.source_file,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
function reflectionToCandidate(field) {
|
|
316
|
+
if (field.field_name === '行为调整') {
|
|
317
|
+
return {
|
|
318
|
+
text: `Apply behavior adjustment from ${field.experiment_id}: ${truncate(field.content, 80)}`,
|
|
319
|
+
why: `From ${field.experiment_id} Reflection.行为调整`,
|
|
320
|
+
done_when: 'Adjustment applied or integrated into convention/skill',
|
|
321
|
+
source_id: field.experiment_id,
|
|
322
|
+
source_type: 'reflection',
|
|
323
|
+
pattern: 'behavior-adjustment',
|
|
324
|
+
is_duplicate: false,
|
|
325
|
+
duplicate_of: undefined,
|
|
326
|
+
source_file: field.source_file,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
return {
|
|
330
|
+
text: `Address process defect from ${field.experiment_id}: ${truncate(field.content, 80)}`,
|
|
331
|
+
why: `From ${field.experiment_id} Reflection.过程缺陷`,
|
|
332
|
+
done_when: 'Defect addressed or mitigation documented',
|
|
333
|
+
source_id: field.experiment_id,
|
|
334
|
+
source_type: 'reflection',
|
|
335
|
+
pattern: 'process-defect',
|
|
336
|
+
is_duplicate: false,
|
|
337
|
+
duplicate_of: undefined,
|
|
338
|
+
source_file: field.source_file,
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
function extractSourceId(filePath) {
|
|
342
|
+
const parts = filePath.split(path.sep);
|
|
343
|
+
const name = path.parse(filePath).name;
|
|
344
|
+
if (name === 'EXPERIMENTS') {
|
|
345
|
+
const projectIndex = parts.indexOf('projects');
|
|
346
|
+
if (projectIndex !== -1 && projectIndex + 1 < parts.length) {
|
|
347
|
+
return `${parts[projectIndex + 1]}/EXPERIMENTS`;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return name;
|
|
351
|
+
}
|
|
352
|
+
function emptyResult() {
|
|
353
|
+
return {
|
|
354
|
+
candidates: [],
|
|
355
|
+
reflection_fields: [],
|
|
356
|
+
scan_summary: {
|
|
357
|
+
files_scanned: 0,
|
|
358
|
+
recommendations_found: 0,
|
|
359
|
+
implied_tasks_found: 0,
|
|
360
|
+
reflection_fields_found: 0,
|
|
361
|
+
total_candidates: 0,
|
|
362
|
+
actionable: 0,
|
|
363
|
+
duplicates: 0,
|
|
364
|
+
new_candidates: 0,
|
|
365
|
+
},
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
const SKIP_PROJECT_MD_FILES = new Set(['TASKS.yaml', 'EXPERIMENTS.md', 'STATUS.md', 'KNOWLEDGE.md', 'experiments-archive.md', 'mission.md', 'roadmap.md', 'CLAUDE.md']);
|
|
369
|
+
function collectProjectDirs(projectsDir, project) {
|
|
370
|
+
const dirs = [];
|
|
371
|
+
const names = project ? [project] : fs.readdirSync(projectsDir).sort();
|
|
372
|
+
for (const name of names) {
|
|
373
|
+
const projectPath = path.join(projectsDir, name);
|
|
374
|
+
if (fs.existsSync(projectPath) && fs.statSync(projectPath).isDirectory())
|
|
375
|
+
dirs.push([name, projectPath]);
|
|
376
|
+
}
|
|
377
|
+
return dirs;
|
|
378
|
+
}
|
|
379
|
+
function collectRecommendationsFromSections(content, filePath, sourceId, acc) {
|
|
380
|
+
for (const section of extractRecommendationSections(content, filePath)) {
|
|
381
|
+
const recs = parseRecommendations(section.body, sourceId, section.header, filePath);
|
|
382
|
+
acc.recommendations.push(...recs);
|
|
383
|
+
for (const rec of recs) {
|
|
384
|
+
const candidate = recommendationToCandidate(rec);
|
|
385
|
+
if (candidate)
|
|
386
|
+
acc.candidates.push(candidate);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
function scanExperimentsFile(projectName, projectPath, acc, days) {
|
|
391
|
+
const experimentsPath = path.join(projectPath, 'EXPERIMENTS.md');
|
|
392
|
+
if (!fs.existsSync(experimentsPath) || !fs.statSync(experimentsPath).isFile())
|
|
393
|
+
return;
|
|
394
|
+
acc.filesScanned += 1;
|
|
395
|
+
const content = fs.readFileSync(experimentsPath, 'utf8');
|
|
396
|
+
acc.reflections.push(...extractReflectionFields(content, experimentsPath, days));
|
|
397
|
+
const implied = extractImpliedTasksFromExperiments(content, experimentsPath, days);
|
|
398
|
+
acc.implied.push(...implied);
|
|
399
|
+
acc.candidates.push(...implied.map(impliedTaskToCandidate));
|
|
400
|
+
collectRecommendationsFromSections(content, experimentsPath, `${projectName}/EXPERIMENTS`, acc);
|
|
401
|
+
}
|
|
402
|
+
function scanMiscProjectFiles(projectPath, acc) {
|
|
403
|
+
for (const fileName of fs.readdirSync(projectPath).sort()) {
|
|
404
|
+
if (!fileName.endsWith('.md') || SKIP_PROJECT_MD_FILES.has(fileName))
|
|
405
|
+
continue;
|
|
406
|
+
const filePath = path.join(projectPath, fileName);
|
|
407
|
+
if (!fs.existsSync(filePath) || !fs.statSync(filePath).isFile())
|
|
408
|
+
continue;
|
|
409
|
+
acc.filesScanned += 1;
|
|
410
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
411
|
+
collectRecommendationsFromSections(content, filePath, extractSourceId(filePath), acc);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
function applyProjectsDeduplication(projectDirs, candidates) {
|
|
415
|
+
for (const [, projectPath] of projectDirs) {
|
|
416
|
+
const tasksPath = path.join(projectPath, 'TASKS.yaml');
|
|
417
|
+
if (!fs.existsSync(tasksPath) || !fs.statSync(tasksPath).isFile())
|
|
418
|
+
continue;
|
|
419
|
+
deduplicateCandidates(candidates, fs.readFileSync(tasksPath, 'utf8'));
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
function buildScanResult(acc) {
|
|
423
|
+
const actionableCount = acc.candidates.filter((c) => !c.is_duplicate).length;
|
|
424
|
+
const duplicateCount = acc.candidates.filter((c) => c.is_duplicate).length;
|
|
425
|
+
return {
|
|
426
|
+
candidates: acc.candidates,
|
|
427
|
+
reflection_fields: acc.reflections,
|
|
428
|
+
scan_summary: {
|
|
429
|
+
files_scanned: acc.filesScanned,
|
|
430
|
+
recommendations_found: acc.recommendations.length,
|
|
431
|
+
implied_tasks_found: acc.implied.length,
|
|
432
|
+
reflection_fields_found: acc.reflections.length,
|
|
433
|
+
total_candidates: acc.candidates.length,
|
|
434
|
+
actionable: actionableCount,
|
|
435
|
+
duplicates: duplicateCount,
|
|
436
|
+
new_candidates: actionableCount,
|
|
437
|
+
},
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
function scanProjectRecommendations(_baseDir, project = null, days = 7) {
|
|
441
|
+
const projectsDir = PROJECTS_DIR;
|
|
442
|
+
if (!fs.existsSync(projectsDir) || !fs.statSync(projectsDir).isDirectory())
|
|
443
|
+
return emptyResult();
|
|
444
|
+
const projectDirs = collectProjectDirs(projectsDir, project);
|
|
445
|
+
const acc = { candidates: [], reflections: [], implied: [], recommendations: [], filesScanned: 0 };
|
|
446
|
+
for (const [projectName, projectPath] of projectDirs) {
|
|
447
|
+
scanExperimentsFile(projectName, projectPath, acc, days);
|
|
448
|
+
scanMiscProjectFiles(projectPath, acc);
|
|
449
|
+
}
|
|
450
|
+
applyProjectsDeduplication(projectDirs, acc.candidates);
|
|
451
|
+
return buildScanResult(acc);
|
|
452
|
+
}
|
|
453
|
+
function formatScanSummary(summary) {
|
|
454
|
+
return [
|
|
455
|
+
'Recommendation Extractor Scan',
|
|
456
|
+
'='.repeat(50),
|
|
457
|
+
`Files scanned: ${summary.files_scanned}`,
|
|
458
|
+
`Recommendations: ${summary.recommendations_found}`,
|
|
459
|
+
`Implied tasks: ${summary.implied_tasks_found}`,
|
|
460
|
+
`Reflection fields: ${summary.reflection_fields_found}`,
|
|
461
|
+
`Total candidates: ${summary.total_candidates}`,
|
|
462
|
+
` New (actionable): ${summary.new_candidates}`,
|
|
463
|
+
` Duplicates: ${summary.duplicates}`,
|
|
464
|
+
];
|
|
465
|
+
}
|
|
466
|
+
function formatReflectionSection(fields) {
|
|
467
|
+
if (fields.length === 0)
|
|
468
|
+
return [];
|
|
469
|
+
const lines = [`\n${'─'.repeat(50)}`, 'Reflection Fields', '─'.repeat(50)];
|
|
470
|
+
for (const field of fields) {
|
|
471
|
+
lines.push(`\n [${field.experiment_id}] ${field.field_name}:`);
|
|
472
|
+
lines.push(` ${field.content.slice(0, 120)}`);
|
|
473
|
+
}
|
|
474
|
+
return lines;
|
|
475
|
+
}
|
|
476
|
+
function formatCandidatesSection(candidates) {
|
|
477
|
+
const fresh = candidates.filter((c) => !c.is_duplicate);
|
|
478
|
+
if (fresh.length === 0)
|
|
479
|
+
return [];
|
|
480
|
+
const lines = [`\n${'─'.repeat(50)}`, 'New Task Candidates', '─'.repeat(50)];
|
|
481
|
+
fresh.forEach((candidate, index) => {
|
|
482
|
+
lines.push(`\n ${index + 1}. - [ ] ${candidate.text}`.trimEnd());
|
|
483
|
+
lines.push(` Why: ${candidate.why}`);
|
|
484
|
+
lines.push(` Done when: ${candidate.done_when}`);
|
|
485
|
+
});
|
|
486
|
+
return lines;
|
|
487
|
+
}
|
|
488
|
+
function formatHumanReadable(result) {
|
|
489
|
+
return [
|
|
490
|
+
...formatScanSummary(result.scan_summary),
|
|
491
|
+
...formatReflectionSection(result.reflection_fields),
|
|
492
|
+
...formatCandidatesSection(result.candidates),
|
|
493
|
+
].join('\n');
|
|
494
|
+
}
|
|
495
|
+
function parseCli(argv) {
|
|
496
|
+
const parsed = parseArgs({
|
|
497
|
+
args: argv,
|
|
498
|
+
allowPositionals: false,
|
|
499
|
+
options: {
|
|
500
|
+
'base-dir': { type: 'string', default: path.join(os.homedir(), 'Cortex') },
|
|
501
|
+
project: { type: 'string' },
|
|
502
|
+
days: { type: 'string', default: '7' },
|
|
503
|
+
json: { type: 'boolean', default: false },
|
|
504
|
+
},
|
|
505
|
+
});
|
|
506
|
+
const values = parsed.values;
|
|
507
|
+
return {
|
|
508
|
+
baseDir: values['base-dir'],
|
|
509
|
+
project: values.project || null,
|
|
510
|
+
days: Number(values.days || '7'),
|
|
511
|
+
json: values.json,
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
function getExtractorHelp() {
|
|
515
|
+
return formatHelp({
|
|
516
|
+
name: 'recommendation-extractor',
|
|
517
|
+
description: 'Scan project markdown for unactioned recommendations and implied tasks',
|
|
518
|
+
usage: 'recommendation-extractor [options]',
|
|
519
|
+
options: [
|
|
520
|
+
{ flag: '--project <name>', description: 'Filter by project name (scans all if omitted)' },
|
|
521
|
+
{ flag: '--days <n>', description: 'Look back N days', default: '7' },
|
|
522
|
+
{ flag: '--json', description: 'Output as JSON instead of human-readable', default: 'false' },
|
|
523
|
+
{ flag: '--base-dir <path>', description: 'Cortex root directory', default: '~/Cortex' },
|
|
524
|
+
{ flag: '--help', description: 'Show this help message' },
|
|
525
|
+
],
|
|
526
|
+
examples: [
|
|
527
|
+
{ description: 'Scan all projects for recommendations', command: 'recommendation-extractor --json' },
|
|
528
|
+
{ description: 'Scan a specific project, last 14 days', command: 'recommendation-extractor --project example-project --days 14 --json' },
|
|
529
|
+
{ description: 'Human-readable report for all projects', command: 'recommendation-extractor' },
|
|
530
|
+
],
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
function runCli(argv) {
|
|
534
|
+
if (argv.includes('--help') || argv.includes('-h')) {
|
|
535
|
+
return { exitCode: 0, stdout: getExtractorHelp(), stderr: '' };
|
|
536
|
+
}
|
|
537
|
+
try {
|
|
538
|
+
const options = parseCli(argv);
|
|
539
|
+
if (!Number.isFinite(options.days) || options.days < 0) {
|
|
540
|
+
return { exitCode: 1, stdout: '', stderr: 'Invalid --days value\n' };
|
|
541
|
+
}
|
|
542
|
+
const result = scanProjectRecommendations(options.baseDir, options.project, options.days);
|
|
543
|
+
const stdout = options.json
|
|
544
|
+
? `${JSON.stringify(result, null, 2)}\n`
|
|
545
|
+
: `${formatHumanReadable(result)}\n`;
|
|
546
|
+
return { exitCode: 0, stdout, stderr: '' };
|
|
547
|
+
}
|
|
548
|
+
catch (error) {
|
|
549
|
+
return { exitCode: 1, stdout: '', stderr: `${error.message}\n` };
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
function main() {
|
|
553
|
+
const result = runCli(process.argv.slice(2));
|
|
554
|
+
if (result.stdout)
|
|
555
|
+
process.stdout.write(result.stdout);
|
|
556
|
+
if (result.stderr)
|
|
557
|
+
process.stderr.write(result.stderr);
|
|
558
|
+
process.exit(result.exitCode);
|
|
559
|
+
}
|
|
560
|
+
if (isMainModule(import.meta.url)) {
|
|
561
|
+
main();
|
|
562
|
+
}
|
|
563
|
+
export { extractRecommendationSections, parseRecommendations, extractReflectionFields, extractImpliedTasksFromExperiments, recommendationToCandidate, impliedTaskToCandidate, reflectionToCandidate, deduplicateCandidates, scanProjectRecommendations, runCli, };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ImpliedTaskPattern } from './types.js';
|
|
2
|
+
export declare const RECOMMENDATION_HEADER_RE: RegExp;
|
|
3
|
+
export declare const ANTI_RECOMMENDATION_HEADERS: Set<string>;
|
|
4
|
+
export declare const IMPLIED_TASK_PATTERNS: ImpliedTaskPattern[];
|
|
5
|
+
export declare const ACTION_VERBS: Set<string>;
|
|
6
|
+
export declare const NEGATIVE_PATTERNS: RegExp[];
|
|
7
|
+
export declare const STOP_WORDS: Set<string>;
|
|
8
|
+
export declare const EXP_HEADER_RE: RegExp;
|
|
9
|
+
export declare const DATE_RE: RegExp;
|
|
10
|
+
export declare const REFLECTION_FIELDS_RE: Record<string, RegExp>;
|
|
11
|
+
export declare const FINDINGS_HEADER_RE: RegExp;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// input: consumed by recommendation-extractor.ts
|
|
2
|
+
// output: regex + string literal constants
|
|
3
|
+
// pos: shared regex/constant module for recommendation scanning
|
|
4
|
+
// >>> If I am updated, update my header comment and the parent folder's CORTEX.md <<<
|
|
5
|
+
export const RECOMMENDATION_HEADER_RE = /^(#{2,4})\s+(Recommended\s+actions?|Next\s+steps?|Prevention|Implications|Quick\s+wins?|Experiments?\s+needed|Proposed\s+solutions?|What\s+NOT\s+to\s+do)\s*$/i;
|
|
6
|
+
export const ANTI_RECOMMENDATION_HEADERS = new Set(['what not to do']);
|
|
7
|
+
export const IMPLIED_TASK_PATTERNS = [
|
|
8
|
+
{
|
|
9
|
+
pattern: 'failed-success-criterion',
|
|
10
|
+
signals: [
|
|
11
|
+
/\bFAIL\b/,
|
|
12
|
+
/\bdoes\s+not\s+meet\b/i,
|
|
13
|
+
/\bbelow\s+threshold\b/i,
|
|
14
|
+
/\bdid\s+not\s+(?:meet|pass|satisfy|achieve)\b/i,
|
|
15
|
+
/\bnot\s+met\b/i,
|
|
16
|
+
/未达成|未通过|未满足/i,
|
|
17
|
+
],
|
|
18
|
+
suggested_task_type: 'Refined experiment or protocol redesign',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
pattern: 'insufficient-sample',
|
|
22
|
+
signals: [
|
|
23
|
+
/\bN\s+too\s+small\b/i,
|
|
24
|
+
/\bN\s*=\s*[12]\b/,
|
|
25
|
+
/\bcannot\s+draw\s+conclusions?\b/i,
|
|
26
|
+
/\binsufficient\s+(?:data|sample|evidence)\b/i,
|
|
27
|
+
/\btoo\s+few\s+(?:samples?|data\s+points?|observations?)\b/i,
|
|
28
|
+
/样本不足|数据不足|样本量(?:过小|不够)/i,
|
|
29
|
+
],
|
|
30
|
+
suggested_task_type: 'Larger-scale replication',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
pattern: 'identified-confound',
|
|
34
|
+
signals: [
|
|
35
|
+
/\bconfound(?:ing)?\b/i,
|
|
36
|
+
/\bcannot\s+(?:separate|disentangle|isolate|distinguish)\b/i,
|
|
37
|
+
/混淆变量|无法分离|无法区分/i,
|
|
38
|
+
],
|
|
39
|
+
suggested_task_type: 'Controlled follow-up experiment',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
pattern: 'partial-confirmation',
|
|
43
|
+
signals: [
|
|
44
|
+
/\bpartially?\s+(?:confirmed|supported|validated?|verified)\b/i,
|
|
45
|
+
/\beffect\s+exists?\s+but\b/i,
|
|
46
|
+
/部分(?:确认|验证|达成)/i,
|
|
47
|
+
],
|
|
48
|
+
suggested_task_type: 'Refined hypothesis or targeted investigation',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
pattern: 'unexplained-result',
|
|
52
|
+
signals: [
|
|
53
|
+
/\bunexpected(?:ly)?\b/i,
|
|
54
|
+
/\bcontrary\s+to\b/i,
|
|
55
|
+
/\bmechanism\s+(?:is\s+)?unclear\b/i,
|
|
56
|
+
/\bunexplained\b/i,
|
|
57
|
+
/\bsurprising(?:ly)?\b/i,
|
|
58
|
+
/意外|机制不明|原因不明|出乎预料/i,
|
|
59
|
+
],
|
|
60
|
+
suggested_task_type: 'Investigation or diagnosis',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
pattern: 'multi-phase-plan',
|
|
64
|
+
signals: [/\bPhase\s+\d+\b/i],
|
|
65
|
+
suggested_task_type: 'Check if all phases have TASKS.md entries',
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
export const ACTION_VERBS = new Set([
|
|
69
|
+
'implement', 'add', 'create', 'fix', 'update', 'remove', 'refactor',
|
|
70
|
+
'test', 'write', 'run', 'design', 'investigate', 'build', 'deploy',
|
|
71
|
+
'configure', 'enable', 'disable', 'migrate', 'extract', 'integrate',
|
|
72
|
+
'validate', 'check', 'verify', 'measure', 'analyze', 'document',
|
|
73
|
+
'define', 'extend', 'split', 'merge', 'rename', 'move', 'replace',
|
|
74
|
+
'convert', 'optimize', 'reduce', 'increase', 'use', 'introduce',
|
|
75
|
+
]);
|
|
76
|
+
export const NEGATIVE_PATTERNS = [
|
|
77
|
+
/^do\s+not\b/i,
|
|
78
|
+
/^don't\b/i,
|
|
79
|
+
/\bshows?\s+that\b/i,
|
|
80
|
+
/\bsuggests?\s+that\b/i,
|
|
81
|
+
/\bindicates?\s+that\b/i,
|
|
82
|
+
/\bis\s+(the|a)\s+(strongest|weakest|dominant|primary)/i,
|
|
83
|
+
];
|
|
84
|
+
export const STOP_WORDS = new Set([
|
|
85
|
+
'a', 'an', 'the', 'is', 'are', 'was', 'were', 'be', 'been', 'being',
|
|
86
|
+
'have', 'has', 'had', 'do', 'does', 'did', 'will', 'would', 'could',
|
|
87
|
+
'should', 'may', 'might', 'shall', 'can', 'need', 'must', 'to', 'of',
|
|
88
|
+
'in', 'for', 'on', 'with', 'at', 'by', 'from', 'as', 'into', 'through',
|
|
89
|
+
'during', 'before', 'after', 'and', 'or', 'but', 'if', 'than', 'that',
|
|
90
|
+
'this', 'these', 'those', 'it', 'its', 'not', 'no', 'all', 'each',
|
|
91
|
+
'every', 'both', 'any', 'such', 'when', 'where', 'how', 'what', 'which',
|
|
92
|
+
]);
|
|
93
|
+
export const EXP_HEADER_RE = /^#{2,4}\s+(EXP-\d+\w*)\s*[::]/i;
|
|
94
|
+
export const DATE_RE = /(?:\*\*日期\*\*|\*\*Date\*\*)\s*[::]\s*(\d{4}-\d{2}-\d{2})/;
|
|
95
|
+
export const REFLECTION_FIELDS_RE = {
|
|
96
|
+
行为调整: /^[-*]\s*\*?\*?行为调整\*?\*?\s*[::]\s*(.+)/i,
|
|
97
|
+
过程缺陷: /^[-*]\s*\*?\*?过程缺陷\*?\*?\s*[::]\s*(.+)/i,
|
|
98
|
+
};
|
|
99
|
+
export const FINDINGS_HEADER_RE = /^(#{2,4})\s+(?:Findings|结论|Conclusion)\s*$/i;
|