@blxzer/cursor-trellis 0.1.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 +45 -0
- package/LICENSE +235 -0
- package/README.md +9 -0
- package/bin/smart-search.js +79 -0
- package/bin/trellis.js +3 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +258 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/commands/channel/adapters/claude.d.ts +29 -0
- package/dist/commands/channel/adapters/claude.d.ts.map +1 -0
- package/dist/commands/channel/adapters/claude.js +203 -0
- package/dist/commands/channel/adapters/claude.js.map +1 -0
- package/dist/commands/channel/adapters/codex.d.ts +85 -0
- package/dist/commands/channel/adapters/codex.d.ts.map +1 -0
- package/dist/commands/channel/adapters/codex.js +505 -0
- package/dist/commands/channel/adapters/codex.js.map +1 -0
- package/dist/commands/channel/adapters/index.d.ts +84 -0
- package/dist/commands/channel/adapters/index.d.ts.map +1 -0
- package/dist/commands/channel/adapters/index.js +115 -0
- package/dist/commands/channel/adapters/index.js.map +1 -0
- package/dist/commands/channel/adapters/types.d.ts +33 -0
- package/dist/commands/channel/adapters/types.d.ts.map +1 -0
- package/dist/commands/channel/adapters/types.js +2 -0
- package/dist/commands/channel/adapters/types.js.map +1 -0
- package/dist/commands/channel/agent-loader.d.ts +32 -0
- package/dist/commands/channel/agent-loader.d.ts.map +1 -0
- package/dist/commands/channel/agent-loader.js +154 -0
- package/dist/commands/channel/agent-loader.js.map +1 -0
- package/dist/commands/channel/context-loader.d.ts +26 -0
- package/dist/commands/channel/context-loader.d.ts.map +1 -0
- package/dist/commands/channel/context-loader.js +290 -0
- package/dist/commands/channel/context-loader.js.map +1 -0
- package/dist/commands/channel/context.d.ts +16 -0
- package/dist/commands/channel/context.d.ts.map +1 -0
- package/dist/commands/channel/context.js +83 -0
- package/dist/commands/channel/context.js.map +1 -0
- package/dist/commands/channel/create.d.ts +27 -0
- package/dist/commands/channel/create.d.ts.map +1 -0
- package/dist/commands/channel/create.js +39 -0
- package/dist/commands/channel/create.js.map +1 -0
- package/dist/commands/channel/dev-parse-trace.d.ts +14 -0
- package/dist/commands/channel/dev-parse-trace.d.ts.map +1 -0
- package/dist/commands/channel/dev-parse-trace.js +70 -0
- package/dist/commands/channel/dev-parse-trace.js.map +1 -0
- package/dist/commands/channel/guard.d.ts +150 -0
- package/dist/commands/channel/guard.d.ts.map +1 -0
- package/dist/commands/channel/guard.js +474 -0
- package/dist/commands/channel/guard.js.map +1 -0
- package/dist/commands/channel/index.d.ts +3 -0
- package/dist/commands/channel/index.d.ts.map +1 -0
- package/dist/commands/channel/index.js +531 -0
- package/dist/commands/channel/index.js.map +1 -0
- package/dist/commands/channel/interrupt.d.ts +10 -0
- package/dist/commands/channel/interrupt.d.ts.map +1 -0
- package/dist/commands/channel/interrupt.js +22 -0
- package/dist/commands/channel/interrupt.js.map +1 -0
- package/dist/commands/channel/kill.d.ts +7 -0
- package/dist/commands/channel/kill.d.ts.map +1 -0
- package/dist/commands/channel/kill.js +121 -0
- package/dist/commands/channel/kill.js.map +1 -0
- package/dist/commands/channel/list.d.ts +17 -0
- package/dist/commands/channel/list.d.ts.map +1 -0
- package/dist/commands/channel/list.js +233 -0
- package/dist/commands/channel/list.js.map +1 -0
- package/dist/commands/channel/messages.d.ts +15 -0
- package/dist/commands/channel/messages.d.ts.map +1 -0
- package/dist/commands/channel/messages.js +245 -0
- package/dist/commands/channel/messages.js.map +1 -0
- package/dist/commands/channel/rm.d.ts +27 -0
- package/dist/commands/channel/rm.d.ts.map +1 -0
- package/dist/commands/channel/rm.js +216 -0
- package/dist/commands/channel/rm.js.map +1 -0
- package/dist/commands/channel/run.d.ts +30 -0
- package/dist/commands/channel/run.d.ts.map +1 -0
- package/dist/commands/channel/run.js +130 -0
- package/dist/commands/channel/run.js.map +1 -0
- package/dist/commands/channel/send.d.ts +11 -0
- package/dist/commands/channel/send.d.ts.map +1 -0
- package/dist/commands/channel/send.js +24 -0
- package/dist/commands/channel/send.js.map +1 -0
- package/dist/commands/channel/spawn.d.ts +40 -0
- package/dist/commands/channel/spawn.d.ts.map +1 -0
- package/dist/commands/channel/spawn.js +244 -0
- package/dist/commands/channel/spawn.js.map +1 -0
- package/dist/commands/channel/store/events.d.ts +39 -0
- package/dist/commands/channel/store/events.d.ts.map +1 -0
- package/dist/commands/channel/store/events.js +87 -0
- package/dist/commands/channel/store/events.js.map +1 -0
- package/dist/commands/channel/store/filter.d.ts +3 -0
- package/dist/commands/channel/store/filter.d.ts.map +1 -0
- package/dist/commands/channel/store/filter.js +2 -0
- package/dist/commands/channel/store/filter.js.map +1 -0
- package/dist/commands/channel/store/lock.d.ts +23 -0
- package/dist/commands/channel/store/lock.d.ts.map +1 -0
- package/dist/commands/channel/store/lock.js +99 -0
- package/dist/commands/channel/store/lock.js.map +1 -0
- package/dist/commands/channel/store/paths.d.ts +63 -0
- package/dist/commands/channel/store/paths.d.ts.map +1 -0
- package/dist/commands/channel/store/paths.js +246 -0
- package/dist/commands/channel/store/paths.js.map +1 -0
- package/dist/commands/channel/store/schema.d.ts +27 -0
- package/dist/commands/channel/store/schema.d.ts.map +1 -0
- package/dist/commands/channel/store/schema.js +34 -0
- package/dist/commands/channel/store/schema.js.map +1 -0
- package/dist/commands/channel/store/thread-state.d.ts +5 -0
- package/dist/commands/channel/store/thread-state.d.ts.map +1 -0
- package/dist/commands/channel/store/thread-state.js +16 -0
- package/dist/commands/channel/store/thread-state.js.map +1 -0
- package/dist/commands/channel/store/watch.d.ts +19 -0
- package/dist/commands/channel/store/watch.d.ts.map +1 -0
- package/dist/commands/channel/store/watch.js +146 -0
- package/dist/commands/channel/store/watch.js.map +1 -0
- package/dist/commands/channel/supervisor/idle.d.ts +46 -0
- package/dist/commands/channel/supervisor/idle.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/idle.js +72 -0
- package/dist/commands/channel/supervisor/idle.js.map +1 -0
- package/dist/commands/channel/supervisor/inbox.d.ts +30 -0
- package/dist/commands/channel/supervisor/inbox.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/inbox.js +160 -0
- package/dist/commands/channel/supervisor/inbox.js.map +1 -0
- package/dist/commands/channel/supervisor/shutdown.d.ts +68 -0
- package/dist/commands/channel/supervisor/shutdown.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/shutdown.js +146 -0
- package/dist/commands/channel/supervisor/shutdown.js.map +1 -0
- package/dist/commands/channel/supervisor/stdout.d.ts +51 -0
- package/dist/commands/channel/supervisor/stdout.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/stdout.js +121 -0
- package/dist/commands/channel/supervisor/stdout.js.map +1 -0
- package/dist/commands/channel/supervisor/turns.d.ts +31 -0
- package/dist/commands/channel/supervisor/turns.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/turns.js +45 -0
- package/dist/commands/channel/supervisor/turns.js.map +1 -0
- package/dist/commands/channel/supervisor/warning.d.ts +48 -0
- package/dist/commands/channel/supervisor/warning.d.ts.map +1 -0
- package/dist/commands/channel/supervisor/warning.js +77 -0
- package/dist/commands/channel/supervisor/warning.js.map +1 -0
- package/dist/commands/channel/supervisor.d.ts +59 -0
- package/dist/commands/channel/supervisor.d.ts.map +1 -0
- package/dist/commands/channel/supervisor.js +344 -0
- package/dist/commands/channel/supervisor.js.map +1 -0
- package/dist/commands/channel/text-body.d.ts +13 -0
- package/dist/commands/channel/text-body.d.ts.map +1 -0
- package/dist/commands/channel/text-body.js +47 -0
- package/dist/commands/channel/text-body.js.map +1 -0
- package/dist/commands/channel/threads.d.ts +39 -0
- package/dist/commands/channel/threads.d.ts.map +1 -0
- package/dist/commands/channel/threads.js +106 -0
- package/dist/commands/channel/threads.js.map +1 -0
- package/dist/commands/channel/title.d.ts +12 -0
- package/dist/commands/channel/title.d.ts.map +1 -0
- package/dist/commands/channel/title.js +24 -0
- package/dist/commands/channel/title.js.map +1 -0
- package/dist/commands/channel/wait.d.ts +17 -0
- package/dist/commands/channel/wait.d.ts.map +1 -0
- package/dist/commands/channel/wait.js +75 -0
- package/dist/commands/channel/wait.js.map +1 -0
- package/dist/commands/init.d.ts +62 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +1656 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/mem.d.ts +30 -0
- package/dist/commands/mem.d.ts.map +1 -0
- package/dist/commands/mem.js +424 -0
- package/dist/commands/mem.js.map +1 -0
- package/dist/commands/rollout.d.ts +34 -0
- package/dist/commands/rollout.d.ts.map +1 -0
- package/dist/commands/rollout.js +102 -0
- package/dist/commands/rollout.js.map +1 -0
- package/dist/commands/uninstall.d.ts +27 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +339 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/commands/update.d.ts +80 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +2185 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/upgrade.d.ts +28 -0
- package/dist/commands/upgrade.d.ts.map +1 -0
- package/dist/commands/upgrade.js +84 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/commands/workflow.d.ts +35 -0
- package/dist/commands/workflow.d.ts.map +1 -0
- package/dist/commands/workflow.js +219 -0
- package/dist/commands/workflow.js.map +1 -0
- package/dist/configurators/antigravity.d.ts +7 -0
- package/dist/configurators/antigravity.d.ts.map +1 -0
- package/dist/configurators/antigravity.js +19 -0
- package/dist/configurators/antigravity.js.map +1 -0
- package/dist/configurators/claude.d.ts +9 -0
- package/dist/configurators/claude.d.ts.map +1 -0
- package/dist/configurators/claude.js +72 -0
- package/dist/configurators/claude.js.map +1 -0
- package/dist/configurators/codebuddy.d.ts +10 -0
- package/dist/configurators/codebuddy.d.ts.map +1 -0
- package/dist/configurators/codebuddy.js +30 -0
- package/dist/configurators/codebuddy.js.map +1 -0
- package/dist/configurators/codex.d.ts +8 -0
- package/dist/configurators/codex.d.ts.map +1 -0
- package/dist/configurators/codex.js +87 -0
- package/dist/configurators/codex.js.map +1 -0
- package/dist/configurators/copilot.d.ts +10 -0
- package/dist/configurators/copilot.d.ts.map +1 -0
- package/dist/configurators/copilot.js +51 -0
- package/dist/configurators/copilot.js.map +1 -0
- package/dist/configurators/cursor.d.ts +20 -0
- package/dist/configurators/cursor.d.ts.map +1 -0
- package/dist/configurators/cursor.js +49 -0
- package/dist/configurators/cursor.js.map +1 -0
- package/dist/configurators/cursor2plus-local.d.ts +6 -0
- package/dist/configurators/cursor2plus-local.d.ts.map +1 -0
- package/dist/configurators/cursor2plus-local.js +20 -0
- package/dist/configurators/cursor2plus-local.js.map +1 -0
- package/dist/configurators/droid.d.ts +10 -0
- package/dist/configurators/droid.d.ts.map +1 -0
- package/dist/configurators/droid.js +30 -0
- package/dist/configurators/droid.js.map +1 -0
- package/dist/configurators/gemini.d.ts +16 -0
- package/dist/configurators/gemini.d.ts.map +1 -0
- package/dist/configurators/gemini.js +38 -0
- package/dist/configurators/gemini.js.map +1 -0
- package/dist/configurators/index.d.ts +69 -0
- package/dist/configurators/index.d.ts.map +1 -0
- package/dist/configurators/index.js +395 -0
- package/dist/configurators/index.js.map +1 -0
- package/dist/configurators/kilo.d.ts +7 -0
- package/dist/configurators/kilo.d.ts.map +1 -0
- package/dist/configurators/kilo.js +19 -0
- package/dist/configurators/kilo.js.map +1 -0
- package/dist/configurators/kiro.d.ts +8 -0
- package/dist/configurators/kiro.d.ts.map +1 -0
- package/dist/configurators/kiro.js +24 -0
- package/dist/configurators/kiro.js.map +1 -0
- package/dist/configurators/opencode.d.ts +14 -0
- package/dist/configurators/opencode.d.ts.map +1 -0
- package/dist/configurators/opencode.js +96 -0
- package/dist/configurators/opencode.js.map +1 -0
- package/dist/configurators/pi.d.ts +3 -0
- package/dist/configurators/pi.d.ts.map +1 -0
- package/dist/configurators/pi.js +45 -0
- package/dist/configurators/pi.js.map +1 -0
- package/dist/configurators/qoder.d.ts +11 -0
- package/dist/configurators/qoder.d.ts.map +1 -0
- package/dist/configurators/qoder.js +31 -0
- package/dist/configurators/qoder.js.map +1 -0
- package/dist/configurators/shared.d.ts +183 -0
- package/dist/configurators/shared.d.ts.map +1 -0
- package/dist/configurators/shared.js +557 -0
- package/dist/configurators/shared.js.map +1 -0
- package/dist/configurators/windsurf.d.ts +7 -0
- package/dist/configurators/windsurf.d.ts.map +1 -0
- package/dist/configurators/windsurf.js +19 -0
- package/dist/configurators/windsurf.js.map +1 -0
- package/dist/configurators/workflow.d.ts +46 -0
- package/dist/configurators/workflow.d.ts.map +1 -0
- package/dist/configurators/workflow.js +180 -0
- package/dist/configurators/workflow.js.map +1 -0
- package/dist/constants/paths.d.ts +70 -0
- package/dist/constants/paths.d.ts.map +1 -0
- package/dist/constants/paths.js +79 -0
- package/dist/constants/paths.js.map +1 -0
- package/dist/constants/version.d.ts +9 -0
- package/dist/constants/version.d.ts.map +1 -0
- package/dist/constants/version.js +15 -0
- package/dist/constants/version.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/migrations/index.d.ts +62 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/index.js +187 -0
- package/dist/migrations/index.js.map +1 -0
- package/dist/migrations/manifests/0.1.0.json +9 -0
- package/dist/templates/claude/agents/trellis-check.md +124 -0
- package/dist/templates/claude/agents/trellis-implement.md +110 -0
- package/dist/templates/claude/agents/trellis-research.md +137 -0
- package/dist/templates/claude/index.d.ts +22 -0
- package/dist/templates/claude/index.d.ts.map +1 -0
- package/dist/templates/claude/index.js +46 -0
- package/dist/templates/claude/index.js.map +1 -0
- package/dist/templates/claude/settings.json +84 -0
- package/dist/templates/codebuddy/agents/trellis-check.md +115 -0
- package/dist/templates/codebuddy/agents/trellis-implement.md +110 -0
- package/dist/templates/codebuddy/agents/trellis-research.md +137 -0
- package/dist/templates/codebuddy/index.d.ts +15 -0
- package/dist/templates/codebuddy/index.d.ts.map +1 -0
- package/dist/templates/codebuddy/index.js +15 -0
- package/dist/templates/codebuddy/index.js.map +1 -0
- package/dist/templates/codebuddy/settings.json +70 -0
- package/dist/templates/codex/agents/trellis-check.toml +67 -0
- package/dist/templates/codex/agents/trellis-implement.toml +40 -0
- package/dist/templates/codex/agents/trellis-research.toml +73 -0
- package/dist/templates/codex/config.toml +28 -0
- package/dist/templates/codex/hooks/session-start.py +575 -0
- package/dist/templates/codex/hooks.json +15 -0
- package/dist/templates/codex/index.d.ts +39 -0
- package/dist/templates/codex/index.d.ts.map +1 -0
- package/dist/templates/codex/index.js +85 -0
- package/dist/templates/codex/index.js.map +1 -0
- package/dist/templates/codex/skills/before-dev/SKILL.md +40 -0
- package/dist/templates/codex/skills/brainstorm/SKILL.md +112 -0
- package/dist/templates/codex/skills/break-loop/SKILL.md +130 -0
- package/dist/templates/codex/skills/check/SKILL.md +98 -0
- package/dist/templates/codex/skills/check-cross-layer/SKILL.md +158 -0
- package/dist/templates/codex/skills/create-command/SKILL.md +101 -0
- package/dist/templates/codex/skills/finish-work/SKILL.md +90 -0
- package/dist/templates/codex/skills/improve-ut/SKILL.md +69 -0
- package/dist/templates/codex/skills/integrate-skill/SKILL.md +221 -0
- package/dist/templates/codex/skills/onboard/SKILL.md +363 -0
- package/dist/templates/codex/skills/record-session/SKILL.md +67 -0
- package/dist/templates/codex/skills/start/SKILL.md +66 -0
- package/dist/templates/codex/skills/update-spec/SKILL.md +335 -0
- package/dist/templates/common/bundled-skills/smart-search-cli/SKILL.md +388 -0
- package/dist/templates/common/bundled-skills/smart-search-cli/agents/openai.yaml +3 -0
- package/dist/templates/common/bundled-skills/smart-search-cli/examples/batch-search.md +98 -0
- package/dist/templates/common/bundled-skills/smart-search-cli/examples/evidence-gathering.md +89 -0
- package/dist/templates/common/bundled-skills/smart-search-cli/references/cli-contract.md +337 -0
- package/dist/templates/common/bundled-skills/trellis-cursor2plus-setup/SKILL.md +62 -0
- package/dist/templates/common/bundled-skills/trellis-meta/SKILL.md +73 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/add-project-local-conventions.md +83 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-agents.md +54 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-context-loading.md +84 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-hooks.md +57 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-skills-or-commands.md +80 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-spec-structure.md +83 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-task-lifecycle.md +88 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/change-workflow.md +65 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/customize-local/overview.md +55 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/context-injection.md +68 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/generated-files.md +80 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/overview.md +51 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/spec-system.md +102 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/task-system.md +133 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/workflow.md +75 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/local-architecture/workspace-memory.md +71 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/agents.md +80 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/hooks-and-settings.md +69 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/overview.md +61 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md +76 -0
- package/dist/templates/common/bundled-skills/trellis-meta/references/platform-files/skills-and-commands.md +128 -0
- package/dist/templates/common/bundled-skills/trellis-micro-grill/SKILL.md +47 -0
- package/dist/templates/common/bundled-skills/trellis-skill-creator/SKILL.md +44 -0
- package/dist/templates/common/bundled-skills/trellis-skill-creator/references/authoring-rules.md +97 -0
- package/dist/templates/common/bundled-skills/trellis-skill-creator/references/review-checklist.md +47 -0
- package/dist/templates/common/bundled-skills/trellis-skill-creator/references/trellis-skill-locations.md +52 -0
- package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/SKILL.md +41 -0
- package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/mcp-setup.md +90 -0
- package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/repository-analysis.md +59 -0
- package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/spec-task-planning.md +61 -0
- package/dist/templates/common/bundled-skills/trellis-spec-bootstrap/references/spec-writing.md +70 -0
- package/dist/templates/common/commands/continue.md +63 -0
- package/dist/templates/common/commands/finish-work.md +68 -0
- package/dist/templates/common/commands/start.md +69 -0
- package/dist/templates/common/index.d.ts +48 -0
- package/dist/templates/common/index.d.ts.map +1 -0
- package/dist/templates/common/index.js +104 -0
- package/dist/templates/common/index.js.map +1 -0
- package/dist/templates/common/skills/before-dev.md +35 -0
- package/dist/templates/common/skills/brainstorm.md +164 -0
- package/dist/templates/common/skills/break-loop.md +125 -0
- package/dist/templates/common/skills/check.md +106 -0
- package/dist/templates/common/skills/update-spec.md +364 -0
- package/dist/templates/copilot/hooks/session-start.py +557 -0
- package/dist/templates/copilot/hooks.json +19 -0
- package/dist/templates/copilot/index.d.ts +23 -0
- package/dist/templates/copilot/index.d.ts.map +1 -0
- package/dist/templates/copilot/index.js +54 -0
- package/dist/templates/copilot/index.js.map +1 -0
- package/dist/templates/copilot/prompts/before-dev.prompt.md +39 -0
- package/dist/templates/copilot/prompts/brainstorm.prompt.md +111 -0
- package/dist/templates/copilot/prompts/break-loop.prompt.md +129 -0
- package/dist/templates/copilot/prompts/check-cross-layer.prompt.md +157 -0
- package/dist/templates/copilot/prompts/check.prompt.md +97 -0
- package/dist/templates/copilot/prompts/create-command.prompt.md +116 -0
- package/dist/templates/copilot/prompts/finish-work.prompt.md +99 -0
- package/dist/templates/copilot/prompts/integrate-skill.prompt.md +223 -0
- package/dist/templates/copilot/prompts/onboard.prompt.md +362 -0
- package/dist/templates/copilot/prompts/parallel.prompt.md +204 -0
- package/dist/templates/copilot/prompts/record-session.prompt.md +66 -0
- package/dist/templates/copilot/prompts/start.prompt.md +63 -0
- package/dist/templates/copilot/prompts/update-spec.prompt.md +358 -0
- package/dist/templates/cursor/agents/trellis-check.md +139 -0
- package/dist/templates/cursor/agents/trellis-implement.md +119 -0
- package/dist/templates/cursor/agents/trellis-research.md +147 -0
- package/dist/templates/cursor/commands/cursor2plus-setup.md +82 -0
- package/dist/templates/cursor/hooks.json +30 -0
- package/dist/templates/cursor/index.d.ts +19 -0
- package/dist/templates/cursor/index.d.ts.map +1 -0
- package/dist/templates/cursor/index.js +19 -0
- package/dist/templates/cursor/index.js.map +1 -0
- package/dist/templates/cursor/rules/trellis-triage.mdc +38 -0
- package/dist/templates/cursor/worktrees.json +11 -0
- package/dist/templates/droid/droids/trellis-check.md +107 -0
- package/dist/templates/droid/droids/trellis-implement.md +102 -0
- package/dist/templates/droid/droids/trellis-research.md +137 -0
- package/dist/templates/droid/index.d.ts +15 -0
- package/dist/templates/droid/index.d.ts.map +1 -0
- package/dist/templates/droid/index.js +15 -0
- package/dist/templates/droid/index.js.map +1 -0
- package/dist/templates/droid/settings.json +70 -0
- package/dist/templates/extract.d.ts +40 -0
- package/dist/templates/extract.d.ts.map +1 -0
- package/dist/templates/extract.js +106 -0
- package/dist/templates/extract.js.map +1 -0
- package/dist/templates/gemini/agents/trellis-check.md +107 -0
- package/dist/templates/gemini/agents/trellis-implement.md +102 -0
- package/dist/templates/gemini/agents/trellis-research.md +136 -0
- package/dist/templates/gemini/index.d.ts +13 -0
- package/dist/templates/gemini/index.d.ts.map +1 -0
- package/dist/templates/gemini/index.js +13 -0
- package/dist/templates/gemini/index.js.map +1 -0
- package/dist/templates/gemini/settings.json +28 -0
- package/dist/templates/kiro/agents/trellis-check.json +26 -0
- package/dist/templates/kiro/agents/trellis-implement.json +26 -0
- package/dist/templates/kiro/agents/trellis-research.json +30 -0
- package/dist/templates/kiro/index.d.ts +18 -0
- package/dist/templates/kiro/index.d.ts.map +1 -0
- package/dist/templates/kiro/index.js +18 -0
- package/dist/templates/kiro/index.js.map +1 -0
- package/dist/templates/markdown/agents.md +32 -0
- package/dist/templates/markdown/gitignore.txt +15 -0
- package/dist/templates/markdown/index.d.ts +30 -0
- package/dist/templates/markdown/index.d.ts.map +1 -0
- package/dist/templates/markdown/index.js +55 -0
- package/dist/templates/markdown/index.js.map +1 -0
- package/dist/templates/markdown/spec/backend/database-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/backend/directory-structure.md.txt +54 -0
- package/dist/templates/markdown/spec/backend/error-handling.md.txt +51 -0
- package/dist/templates/markdown/spec/backend/index.md.txt +38 -0
- package/dist/templates/markdown/spec/backend/logging-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/backend/quality-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/frontend/component-guidelines.md.txt +59 -0
- package/dist/templates/markdown/spec/frontend/directory-structure.md.txt +54 -0
- package/dist/templates/markdown/spec/frontend/hook-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/frontend/index.md.txt +39 -0
- package/dist/templates/markdown/spec/frontend/quality-guidelines.md.txt +51 -0
- package/dist/templates/markdown/spec/frontend/state-management.md.txt +51 -0
- package/dist/templates/markdown/spec/frontend/type-safety.md.txt +51 -0
- package/dist/templates/markdown/spec/guides/code-reuse-thinking-guide.md.txt +223 -0
- package/dist/templates/markdown/spec/guides/cross-layer-thinking-guide.md.txt +259 -0
- package/dist/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt +633 -0
- package/dist/templates/markdown/spec/guides/cursor-context-injection-guide.md.txt +65 -0
- package/dist/templates/markdown/spec/guides/cursor-subagent-policy.md.txt +382 -0
- package/dist/templates/markdown/spec/guides/durable-learning-decision-guide.md.txt +76 -0
- package/dist/templates/markdown/spec/guides/index.md.txt +101 -0
- package/dist/templates/markdown/spec/guides/retrieval-daily-guide.md.txt +92 -0
- package/dist/templates/markdown/workspace-index.md +125 -0
- package/dist/templates/markdown/worktree.yaml.txt +58 -0
- package/dist/templates/opencode/agents/trellis-check.md +122 -0
- package/dist/templates/opencode/agents/trellis-implement.md +118 -0
- package/dist/templates/opencode/agents/trellis-research.md +145 -0
- package/dist/templates/opencode/lib/session-utils.js +667 -0
- package/dist/templates/opencode/lib/trellis-context.js +336 -0
- package/dist/templates/opencode/package.json +5 -0
- package/dist/templates/opencode/plugins/inject-subagent-context.js +495 -0
- package/dist/templates/opencode/plugins/inject-workflow-state.js +159 -0
- package/dist/templates/opencode/plugins/session-start.js +101 -0
- package/dist/templates/pi/agents/trellis-check.md +37 -0
- package/dist/templates/pi/agents/trellis-implement.md +42 -0
- package/dist/templates/pi/agents/trellis-research.md +25 -0
- package/dist/templates/pi/extensions/trellis/index.ts.txt +1600 -0
- package/dist/templates/pi/index.d.ts +5 -0
- package/dist/templates/pi/index.d.ts.map +1 -0
- package/dist/templates/pi/index.js +12 -0
- package/dist/templates/pi/index.js.map +1 -0
- package/dist/templates/pi/settings.json +12 -0
- package/dist/templates/qoder/agents/trellis-check.md +108 -0
- package/dist/templates/qoder/agents/trellis-implement.md +103 -0
- package/dist/templates/qoder/agents/trellis-research.md +137 -0
- package/dist/templates/qoder/index.d.ts +15 -0
- package/dist/templates/qoder/index.d.ts.map +1 -0
- package/dist/templates/qoder/index.js +15 -0
- package/dist/templates/qoder/index.js.map +1 -0
- package/dist/templates/qoder/settings.json +47 -0
- package/dist/templates/shared-hooks/index.d.ts +50 -0
- package/dist/templates/shared-hooks/index.d.ts.map +1 -0
- package/dist/templates/shared-hooks/index.js +92 -0
- package/dist/templates/shared-hooks/index.js.map +1 -0
- package/dist/templates/shared-hooks/inject-shell-session-context.py +183 -0
- package/dist/templates/shared-hooks/inject-subagent-context.py +774 -0
- package/dist/templates/shared-hooks/inject-workflow-state.py +366 -0
- package/dist/templates/shared-hooks/research-end-retrieval-pack.py +220 -0
- package/dist/templates/shared-hooks/session-start.py +873 -0
- package/dist/templates/template-utils.d.ts +28 -0
- package/dist/templates/template-utils.d.ts.map +1 -0
- package/dist/templates/template-utils.js +83 -0
- package/dist/templates/template-utils.js.map +1 -0
- package/dist/templates/trellis/config.yaml +132 -0
- package/dist/templates/trellis/gitignore.txt +39 -0
- package/dist/templates/trellis/index.d.ts +80 -0
- package/dist/templates/trellis/index.d.ts.map +1 -0
- package/dist/templates/trellis/index.js +171 -0
- package/dist/templates/trellis/index.js.map +1 -0
- package/dist/templates/trellis/local/README.md +59 -0
- package/dist/templates/trellis/local/config.local.json.example +6 -0
- package/dist/templates/trellis/local/index.d.ts +7 -0
- package/dist/templates/trellis/local/index.d.ts.map +1 -0
- package/dist/templates/trellis/local/index.js +14 -0
- package/dist/templates/trellis/local/index.js.map +1 -0
- package/dist/templates/trellis/local/patch_wpelc8.py +297 -0
- package/dist/templates/trellis/local/subagent-models.json.example +4 -0
- package/dist/templates/trellis/local/trellis-task-models.json.example +10 -0
- package/dist/templates/trellis/local/trellis-task-models.json5.example +45 -0
- package/dist/templates/trellis/local/trellis_task_models_config.py +200 -0
- package/dist/templates/trellis/scripts/__init__.py +5 -0
- package/dist/templates/trellis/scripts/add_session.py +547 -0
- package/dist/templates/trellis/scripts/build_context_pack.py +12 -0
- package/dist/templates/trellis/scripts/build_retrieval_pack.py +12 -0
- package/dist/templates/trellis/scripts/common/__init__.py +103 -0
- package/dist/templates/trellis/scripts/common/active_task.py +607 -0
- package/dist/templates/trellis/scripts/common/artifact_search.py +587 -0
- package/dist/templates/trellis/scripts/common/cli_adapter.py +811 -0
- package/dist/templates/trellis/scripts/common/cli_environment.py +155 -0
- package/dist/templates/trellis/scripts/common/codebase_retrieval_router.py +902 -0
- package/dist/templates/trellis/scripts/common/config.py +458 -0
- package/dist/templates/trellis/scripts/common/context_pack.py +371 -0
- package/dist/templates/trellis/scripts/common/developer.py +190 -0
- package/dist/templates/trellis/scripts/common/git.py +31 -0
- package/dist/templates/trellis/scripts/common/git_context.py +149 -0
- package/dist/templates/trellis/scripts/common/io.py +37 -0
- package/dist/templates/trellis/scripts/common/log.py +45 -0
- package/dist/templates/trellis/scripts/common/packages_context.py +239 -0
- package/dist/templates/trellis/scripts/common/parent_orchestration.py +691 -0
- package/dist/templates/trellis/scripts/common/paths.py +457 -0
- package/dist/templates/trellis/scripts/common/retrieval_adapter_metadata.py +889 -0
- package/dist/templates/trellis/scripts/common/retrieval_evidence.py +917 -0
- package/dist/templates/trellis/scripts/common/retrieval_pack.py +425 -0
- package/dist/templates/trellis/scripts/common/retrieval_pack_context.py +126 -0
- package/dist/templates/trellis/scripts/common/safe_commit.py +285 -0
- package/dist/templates/trellis/scripts/common/session_context.py +1159 -0
- package/dist/templates/trellis/scripts/common/session_memory.py +360 -0
- package/dist/templates/trellis/scripts/common/smart_search_evidence.py +479 -0
- package/dist/templates/trellis/scripts/common/smart_search_resolve.py +125 -0
- package/dist/templates/trellis/scripts/common/task_context.py +223 -0
- package/dist/templates/trellis/scripts/common/task_dashboard.py +140 -0
- package/dist/templates/trellis/scripts/common/task_gates.py +1735 -0
- package/dist/templates/trellis/scripts/common/task_map.py +586 -0
- package/dist/templates/trellis/scripts/common/task_queue.py +188 -0
- package/dist/templates/trellis/scripts/common/task_store.py +1533 -0
- package/dist/templates/trellis/scripts/common/task_utils.py +274 -0
- package/dist/templates/trellis/scripts/common/tasks.py +231 -0
- package/dist/templates/trellis/scripts/common/test_retrieval_arbitration.py +333 -0
- package/dist/templates/trellis/scripts/common/trellis_config.py +131 -0
- package/dist/templates/trellis/scripts/common/types.py +110 -0
- package/dist/templates/trellis/scripts/common/workflow_phase.py +212 -0
- package/dist/templates/trellis/scripts/get_context.py +17 -0
- package/dist/templates/trellis/scripts/get_developer.py +26 -0
- package/dist/templates/trellis/scripts/hooks/linear_sync.py +243 -0
- package/dist/templates/trellis/scripts/init_developer.py +51 -0
- package/dist/templates/trellis/scripts/route_codebase_retrieval.py +77 -0
- package/dist/templates/trellis/scripts/run_smart_search.py +12 -0
- package/dist/templates/trellis/scripts/search_artifacts.py +13 -0
- package/dist/templates/trellis/scripts/search_memory.py +12 -0
- package/dist/templates/trellis/scripts/task.py +851 -0
- package/dist/templates/trellis/tasks/.gitkeep +0 -0
- package/dist/templates/trellis/tasks/templates/release-execution/design.md +61 -0
- package/dist/templates/trellis/tasks/templates/release-execution/handoff-template.md +29 -0
- package/dist/templates/trellis/tasks/templates/release-execution/implement.md +29 -0
- package/dist/templates/trellis/tasks/templates/release-execution/prd.md +31 -0
- package/dist/templates/trellis/tasks/templates/release-readiness/design.md +50 -0
- package/dist/templates/trellis/tasks/templates/release-readiness/handoff-template.md +39 -0
- package/dist/templates/trellis/tasks/templates/release-readiness/implement.md +29 -0
- package/dist/templates/trellis/tasks/templates/release-readiness/prd.md +31 -0
- package/dist/templates/trellis/workflow.md +960 -0
- package/dist/types/ai-tools.d.ts +106 -0
- package/dist/types/ai-tools.d.ts.map +1 -0
- package/dist/types/ai-tools.js +294 -0
- package/dist/types/ai-tools.js.map +1 -0
- package/dist/types/migration.d.ts +125 -0
- package/dist/types/migration.d.ts.map +1 -0
- package/dist/types/migration.js +8 -0
- package/dist/types/migration.js.map +1 -0
- package/dist/utils/codebase-retrieval-router.d.ts +77 -0
- package/dist/utils/codebase-retrieval-router.d.ts.map +1 -0
- package/dist/utils/codebase-retrieval-router.js +767 -0
- package/dist/utils/codebase-retrieval-router.js.map +1 -0
- package/dist/utils/compare-versions.d.ts +12 -0
- package/dist/utils/compare-versions.d.ts.map +1 -0
- package/dist/utils/compare-versions.js +86 -0
- package/dist/utils/compare-versions.js.map +1 -0
- package/dist/utils/cwd-guard.d.ts +38 -0
- package/dist/utils/cwd-guard.d.ts.map +1 -0
- package/dist/utils/cwd-guard.js +62 -0
- package/dist/utils/cwd-guard.js.map +1 -0
- package/dist/utils/file-writer.d.ts +36 -0
- package/dist/utils/file-writer.d.ts.map +1 -0
- package/dist/utils/file-writer.js +203 -0
- package/dist/utils/file-writer.js.map +1 -0
- package/dist/utils/manifest-prune.d.ts +61 -0
- package/dist/utils/manifest-prune.d.ts.map +1 -0
- package/dist/utils/manifest-prune.js +136 -0
- package/dist/utils/manifest-prune.js.map +1 -0
- package/dist/utils/posix.d.ts +13 -0
- package/dist/utils/posix.d.ts.map +1 -0
- package/dist/utils/posix.js +15 -0
- package/dist/utils/posix.js.map +1 -0
- package/dist/utils/post-update-smoke.d.ts +7 -0
- package/dist/utils/post-update-smoke.d.ts.map +1 -0
- package/dist/utils/post-update-smoke.js +40 -0
- package/dist/utils/post-update-smoke.js.map +1 -0
- package/dist/utils/project-capabilities.d.ts +54 -0
- package/dist/utils/project-capabilities.d.ts.map +1 -0
- package/dist/utils/project-capabilities.js +515 -0
- package/dist/utils/project-capabilities.js.map +1 -0
- package/dist/utils/project-detector.d.ts +46 -0
- package/dist/utils/project-detector.d.ts.map +1 -0
- package/dist/utils/project-detector.js +666 -0
- package/dist/utils/project-detector.js.map +1 -0
- package/dist/utils/proxy.d.ts +25 -0
- package/dist/utils/proxy.d.ts.map +1 -0
- package/dist/utils/proxy.js +60 -0
- package/dist/utils/proxy.js.map +1 -0
- package/dist/utils/readiness.d.ts +20 -0
- package/dist/utils/readiness.d.ts.map +1 -0
- package/dist/utils/readiness.js +430 -0
- package/dist/utils/readiness.js.map +1 -0
- package/dist/utils/retrieval-execution-telemetry.d.ts +162 -0
- package/dist/utils/retrieval-execution-telemetry.d.ts.map +1 -0
- package/dist/utils/retrieval-execution-telemetry.js +288 -0
- package/dist/utils/retrieval-execution-telemetry.js.map +1 -0
- package/dist/utils/retrieval-result-ranking.d.ts +40 -0
- package/dist/utils/retrieval-result-ranking.d.ts.map +1 -0
- package/dist/utils/retrieval-result-ranking.js +162 -0
- package/dist/utils/retrieval-result-ranking.js.map +1 -0
- package/dist/utils/task-json.d.ts +13 -0
- package/dist/utils/task-json.d.ts.map +1 -0
- package/dist/utils/task-json.js +12 -0
- package/dist/utils/task-json.js.map +1 -0
- package/dist/utils/template-fetcher.d.ts +150 -0
- package/dist/utils/template-fetcher.d.ts.map +1 -0
- package/dist/utils/template-fetcher.js +907 -0
- package/dist/utils/template-fetcher.js.map +1 -0
- package/dist/utils/template-hash.d.ts +123 -0
- package/dist/utils/template-hash.d.ts.map +1 -0
- package/dist/utils/template-hash.js +334 -0
- package/dist/utils/template-hash.js.map +1 -0
- package/dist/utils/uninstall-scrubbers.d.ts +66 -0
- package/dist/utils/uninstall-scrubbers.d.ts.map +1 -0
- package/dist/utils/uninstall-scrubbers.js +342 -0
- package/dist/utils/uninstall-scrubbers.js.map +1 -0
- package/dist/utils/update-rollout-report.d.ts +137 -0
- package/dist/utils/update-rollout-report.d.ts.map +1 -0
- package/dist/utils/update-rollout-report.js +108 -0
- package/dist/utils/update-rollout-report.js.map +1 -0
- package/dist/utils/workflow-resolver.d.ts +86 -0
- package/dist/utils/workflow-resolver.d.ts.map +1 -0
- package/dist/utils/workflow-resolver.js +265 -0
- package/dist/utils/workflow-resolver.js.map +1 -0
- package/package.json +137 -0
- package/scripts/postinstall.js +45 -0
- package/vendor/smart-search/LICENSE +21 -0
- package/vendor/smart-search/README.md +412 -0
- package/vendor/smart-search/README.zh-CN.md +430 -0
- package/vendor/smart-search/npm/bin/smart-search.js +63 -0
- package/vendor/smart-search/npm/scripts/postinstall.js +87 -0
- package/vendor/smart-search/npm/scripts/resolve-prerelease-version.js +108 -0
- package/vendor/smart-search/npm/scripts/set-package-version.js +35 -0
- package/vendor/smart-search/npm/scripts/sync-python-version.js +22 -0
- package/vendor/smart-search/npm/scripts/test-wrapper-repair.js +99 -0
- package/vendor/smart-search/npm/scripts/test.js +85 -0
- package/vendor/smart-search/package.json +42 -0
- package/vendor/smart-search/pyproject.toml +37 -0
- package/vendor/smart-search/skills/smart-search-cli/SKILL.md +387 -0
- package/vendor/smart-search/skills/smart-search-cli/agents/openai.yaml +3 -0
- package/vendor/smart-search/skills/smart-search-cli/examples/batch-search.md +98 -0
- package/vendor/smart-search/skills/smart-search-cli/examples/evidence-gathering.md +89 -0
- package/vendor/smart-search/skills/smart-search-cli/references/cli-contract.md +337 -0
- package/vendor/smart-search/src/smart_search/__init__.py +1 -0
- package/vendor/smart-search/src/smart_search/assets/skills/smart-search-cli/SKILL.md +387 -0
- package/vendor/smart-search/src/smart_search/assets/skills/smart-search-cli/agents/openai.yaml +3 -0
- package/vendor/smart-search/src/smart_search/assets/skills/smart-search-cli/examples/batch-search.md +98 -0
- package/vendor/smart-search/src/smart_search/assets/skills/smart-search-cli/examples/evidence-gathering.md +89 -0
- package/vendor/smart-search/src/smart_search/assets/skills/smart-search-cli/references/cli-contract.md +337 -0
- package/vendor/smart-search/src/smart_search/cli.py +2003 -0
- package/vendor/smart-search/src/smart_search/config.py +580 -0
- package/vendor/smart-search/src/smart_search/logger.py +43 -0
- package/vendor/smart-search/src/smart_search/providers/__init__.py +16 -0
- package/vendor/smart-search/src/smart_search/providers/base.py +41 -0
- package/vendor/smart-search/src/smart_search/providers/context7.py +141 -0
- package/vendor/smart-search/src/smart_search/providers/exa.py +206 -0
- package/vendor/smart-search/src/smart_search/providers/jina.py +136 -0
- package/vendor/smart-search/src/smart_search/providers/openai_compatible.py +370 -0
- package/vendor/smart-search/src/smart_search/providers/zhipu.py +143 -0
- package/vendor/smart-search/src/smart_search/service.py +2865 -0
- package/vendor/smart-search/src/smart_search/sources.py +429 -0
- package/vendor/smart-search/src/smart_search/utils.py +220 -0
|
@@ -0,0 +1,917 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Normalize Phase 2 retrieval evidence into comparable scored evidence.
|
|
4
|
+
|
|
5
|
+
This module exposes pure functions only. It does not run Smart Search,
|
|
6
|
+
network calls, MCP tools, or codebase search.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from dataclasses import dataclass, field
|
|
12
|
+
from datetime import datetime, timezone
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
EVIDENCE_VERSION = 1
|
|
16
|
+
|
|
17
|
+
SOURCE_TASK_ARTIFACTS = "task-artifacts"
|
|
18
|
+
SOURCE_ARTIFACT_SEARCH = "artifact-search"
|
|
19
|
+
SOURCE_SESSION_MEMORY = "session-memory"
|
|
20
|
+
SOURCE_SMART_SEARCH = "smart-search"
|
|
21
|
+
SOURCE_CODEBASE_EVIDENCE = "codebase-evidence"
|
|
22
|
+
|
|
23
|
+
SOURCES = (
|
|
24
|
+
SOURCE_TASK_ARTIFACTS,
|
|
25
|
+
SOURCE_ARTIFACT_SEARCH,
|
|
26
|
+
SOURCE_SESSION_MEMORY,
|
|
27
|
+
SOURCE_SMART_SEARCH,
|
|
28
|
+
SOURCE_CODEBASE_EVIDENCE,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
STATUS_OK = "ok"
|
|
32
|
+
STATUS_DEGRADED = "degraded"
|
|
33
|
+
STATUS_FAILED = "failed"
|
|
34
|
+
STATUS_NOT_CONFIGURED = "not_configured"
|
|
35
|
+
STATUS_MISSING = "missing"
|
|
36
|
+
|
|
37
|
+
STATUSES = (
|
|
38
|
+
STATUS_OK,
|
|
39
|
+
STATUS_DEGRADED,
|
|
40
|
+
STATUS_FAILED,
|
|
41
|
+
STATUS_NOT_CONFIGURED,
|
|
42
|
+
STATUS_MISSING,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
VALIDATION_VERIFIED = "verified"
|
|
46
|
+
VALIDATION_UNVERIFIED = "unverified"
|
|
47
|
+
VALIDATION_CANDIDATE = "candidate"
|
|
48
|
+
VALIDATION_UNAVAILABLE = "unavailable"
|
|
49
|
+
VALIDATION_FAILED = "failed"
|
|
50
|
+
|
|
51
|
+
VALIDATION_STATES = (
|
|
52
|
+
VALIDATION_VERIFIED,
|
|
53
|
+
VALIDATION_UNVERIFIED,
|
|
54
|
+
VALIDATION_CANDIDATE,
|
|
55
|
+
VALIDATION_UNAVAILABLE,
|
|
56
|
+
VALIDATION_FAILED,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
SOURCE_ORDER = {
|
|
60
|
+
SOURCE_TASK_ARTIFACTS: 0,
|
|
61
|
+
SOURCE_ARTIFACT_SEARCH: 1,
|
|
62
|
+
SOURCE_SESSION_MEMORY: 2,
|
|
63
|
+
SOURCE_SMART_SEARCH: 3,
|
|
64
|
+
SOURCE_CODEBASE_EVIDENCE: 4,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
KIND_BY_SOURCE = {
|
|
68
|
+
SOURCE_TASK_ARTIFACTS: "local-artifact",
|
|
69
|
+
SOURCE_ARTIFACT_SEARCH: "local-artifact",
|
|
70
|
+
SOURCE_SESSION_MEMORY: "historical-context",
|
|
71
|
+
SOURCE_SMART_SEARCH: "external-evidence",
|
|
72
|
+
SOURCE_CODEBASE_EVIDENCE: "candidate-evidence",
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
SOURCE_AUTHORITY = {
|
|
76
|
+
SOURCE_TASK_ARTIFACTS: 95,
|
|
77
|
+
SOURCE_ARTIFACT_SEARCH: 90,
|
|
78
|
+
SOURCE_SESSION_MEMORY: 55,
|
|
79
|
+
SOURCE_SMART_SEARCH: 85,
|
|
80
|
+
SOURCE_CODEBASE_EVIDENCE: 60,
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
BASE_TRUST = {
|
|
84
|
+
SOURCE_TASK_ARTIFACTS: "high",
|
|
85
|
+
SOURCE_ARTIFACT_SEARCH: "high",
|
|
86
|
+
SOURCE_SESSION_MEMORY: "medium",
|
|
87
|
+
SOURCE_SMART_SEARCH: "high",
|
|
88
|
+
SOURCE_CODEBASE_EVIDENCE: "medium",
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
TRUST_SCORE = {"high": 100, "medium": 70, "low": 40}
|
|
92
|
+
|
|
93
|
+
MAX_UPSTREAM_SCORE = 100
|
|
94
|
+
MAX_RECOMMENDATION_PRIORITY = 100
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@dataclass
|
|
98
|
+
class ScoredEvidence:
|
|
99
|
+
source: str
|
|
100
|
+
kind: str
|
|
101
|
+
reference: str
|
|
102
|
+
title: str
|
|
103
|
+
status: str
|
|
104
|
+
trust: str
|
|
105
|
+
confidence: str
|
|
106
|
+
relevance: int
|
|
107
|
+
freshness: int
|
|
108
|
+
source_authority: int
|
|
109
|
+
validation_state: str
|
|
110
|
+
score: int
|
|
111
|
+
reasons: list[str] = field(default_factory=list)
|
|
112
|
+
warnings: list[str] = field(default_factory=list)
|
|
113
|
+
|
|
114
|
+
def to_json(self) -> dict[str, object]:
|
|
115
|
+
return {
|
|
116
|
+
"version": EVIDENCE_VERSION,
|
|
117
|
+
"source": self.source,
|
|
118
|
+
"kind": self.kind,
|
|
119
|
+
"reference": self.reference,
|
|
120
|
+
"title": self.title,
|
|
121
|
+
"status": self.status,
|
|
122
|
+
"trust": self.trust,
|
|
123
|
+
"confidence": self.confidence,
|
|
124
|
+
"relevance": self.relevance,
|
|
125
|
+
"freshness": self.freshness,
|
|
126
|
+
"sourceAuthority": self.source_authority,
|
|
127
|
+
"validationState": self.validation_state,
|
|
128
|
+
"score": self.score,
|
|
129
|
+
"reasons": list(self.reasons),
|
|
130
|
+
"warnings": list(self.warnings),
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def score_evidence_bundle(bundle: dict[str, Any]) -> dict[str, object]:
|
|
135
|
+
"""Score all evidence inputs in a retrieval bundle and return stable JSON."""
|
|
136
|
+
items: list[ScoredEvidence] = []
|
|
137
|
+
|
|
138
|
+
selected_artifacts = dict_value(bundle.get("selectedTaskArtifacts"))
|
|
139
|
+
recommendations = list_value(bundle.get("recommendations"))
|
|
140
|
+
recommendation_by_source = index_recommendations(recommendations)
|
|
141
|
+
|
|
142
|
+
if selected_artifacts or recommendation_by_source.get(SOURCE_TASK_ARTIFACTS):
|
|
143
|
+
items.extend(
|
|
144
|
+
score_task_artifacts(
|
|
145
|
+
selected_artifacts,
|
|
146
|
+
recommendation_by_source.get(SOURCE_TASK_ARTIFACTS),
|
|
147
|
+
)
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
for result in list_value(bundle.get("artifactSearchResults")):
|
|
151
|
+
if isinstance(result, dict):
|
|
152
|
+
items.append(
|
|
153
|
+
score_artifact_search_result(
|
|
154
|
+
result,
|
|
155
|
+
recommendation_by_source.get(SOURCE_ARTIFACT_SEARCH),
|
|
156
|
+
)
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
for result in list_value(bundle.get("sessionMemoryResults")):
|
|
160
|
+
if isinstance(result, dict):
|
|
161
|
+
items.append(
|
|
162
|
+
score_session_memory_result(
|
|
163
|
+
result,
|
|
164
|
+
recommendation_by_source.get(SOURCE_SESSION_MEMORY),
|
|
165
|
+
)
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
for manifest in list_value(bundle.get("smartSearchManifests")):
|
|
169
|
+
if isinstance(manifest, dict):
|
|
170
|
+
items.append(
|
|
171
|
+
score_smart_search_manifest(
|
|
172
|
+
manifest,
|
|
173
|
+
recommendation_by_source.get(SOURCE_SMART_SEARCH),
|
|
174
|
+
)
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
for candidate in list_value(bundle.get("codebaseCandidates")):
|
|
178
|
+
if isinstance(candidate, dict):
|
|
179
|
+
items.append(
|
|
180
|
+
score_codebase_candidate(
|
|
181
|
+
candidate,
|
|
182
|
+
recommendation_by_source.get(SOURCE_CODEBASE_EVIDENCE),
|
|
183
|
+
)
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
# Availability / missing signals for recommended sources without evidence.
|
|
187
|
+
consumed_sources = {item.source for item in items}
|
|
188
|
+
items.extend(
|
|
189
|
+
score_missing_recommendations(
|
|
190
|
+
recommendations,
|
|
191
|
+
consumed_sources,
|
|
192
|
+
has_smart_search_manifests=bool(bundle.get("smartSearchManifests")),
|
|
193
|
+
)
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
sorted_items = sort_scored_evidence(items)
|
|
197
|
+
return {
|
|
198
|
+
"version": EVIDENCE_VERSION,
|
|
199
|
+
"total": len(sorted_items),
|
|
200
|
+
"items": [item.to_json() for item in sorted_items],
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def score_task_artifacts(
|
|
205
|
+
artifacts: dict[str, Any],
|
|
206
|
+
recommendation: dict[str, Any] | None,
|
|
207
|
+
) -> list[ScoredEvidence]:
|
|
208
|
+
if not artifacts and not recommendation:
|
|
209
|
+
return []
|
|
210
|
+
|
|
211
|
+
task_path = string_value(artifacts.get("taskPath")) or string_value(
|
|
212
|
+
(recommendation or {}).get("reference")
|
|
213
|
+
) or ""
|
|
214
|
+
if not task_path:
|
|
215
|
+
return []
|
|
216
|
+
|
|
217
|
+
present_labels: list[str] = []
|
|
218
|
+
for key, label in (
|
|
219
|
+
("prd", "prd.md"),
|
|
220
|
+
("design", "design.md"),
|
|
221
|
+
("implement", "implement.md"),
|
|
222
|
+
("verify", "verify.md"),
|
|
223
|
+
):
|
|
224
|
+
if artifacts.get(key):
|
|
225
|
+
present_labels.append(label)
|
|
226
|
+
if artifacts.get("research"):
|
|
227
|
+
count = int_value(artifacts.get("researchCount"))
|
|
228
|
+
if count:
|
|
229
|
+
present_labels.append(f"research/ ({count} file(s))")
|
|
230
|
+
else:
|
|
231
|
+
present_labels.append("research/")
|
|
232
|
+
|
|
233
|
+
if not present_labels:
|
|
234
|
+
if recommendation:
|
|
235
|
+
return [
|
|
236
|
+
_build_scored(
|
|
237
|
+
source=SOURCE_TASK_ARTIFACTS,
|
|
238
|
+
reference=task_path,
|
|
239
|
+
title="Selected task artifacts",
|
|
240
|
+
status=STATUS_MISSING,
|
|
241
|
+
trust="high",
|
|
242
|
+
confidence=string_value(recommendation.get("confidence")) or "high",
|
|
243
|
+
relevance=scale_priority(int_value(recommendation.get("priority"))),
|
|
244
|
+
freshness=90,
|
|
245
|
+
source_authority=SOURCE_AUTHORITY[SOURCE_TASK_ARTIFACTS],
|
|
246
|
+
validation_state=VALIDATION_UNAVAILABLE,
|
|
247
|
+
reasons=[
|
|
248
|
+
"task-artifacts recommended but no local artifacts are present",
|
|
249
|
+
],
|
|
250
|
+
warnings=["missing selected-task artifacts"],
|
|
251
|
+
)
|
|
252
|
+
]
|
|
253
|
+
return []
|
|
254
|
+
|
|
255
|
+
relevance = scale_priority(int_value((recommendation or {}).get("priority"), 100))
|
|
256
|
+
confidence = string_value((recommendation or {}).get("confidence")) or "high"
|
|
257
|
+
title = f"Task artifacts: {', '.join(present_labels)}"
|
|
258
|
+
return [
|
|
259
|
+
_build_scored(
|
|
260
|
+
source=SOURCE_TASK_ARTIFACTS,
|
|
261
|
+
reference=task_path,
|
|
262
|
+
title=title,
|
|
263
|
+
status=STATUS_OK,
|
|
264
|
+
trust=BASE_TRUST[SOURCE_TASK_ARTIFACTS],
|
|
265
|
+
confidence=confidence,
|
|
266
|
+
relevance=relevance,
|
|
267
|
+
freshness=95,
|
|
268
|
+
source_authority=SOURCE_AUTHORITY[SOURCE_TASK_ARTIFACTS],
|
|
269
|
+
validation_state=VALIDATION_VERIFIED,
|
|
270
|
+
reasons=[
|
|
271
|
+
"durable selected-task artifacts are present",
|
|
272
|
+
"local planning and verification files outrank memory and candidates",
|
|
273
|
+
],
|
|
274
|
+
warnings=[],
|
|
275
|
+
)
|
|
276
|
+
]
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def score_artifact_search_result(
|
|
280
|
+
result: dict[str, Any],
|
|
281
|
+
recommendation: dict[str, Any] | None,
|
|
282
|
+
) -> ScoredEvidence:
|
|
283
|
+
reference = string_value(result.get("path")) or ""
|
|
284
|
+
title = string_value(result.get("title")) or reference or "Artifact search result"
|
|
285
|
+
upstream_score = int_value(result.get("score"))
|
|
286
|
+
relevance = scale_upstream_score(upstream_score)
|
|
287
|
+
if recommendation:
|
|
288
|
+
relevance = max(relevance, scale_priority(int_value(recommendation.get("priority"), 90)))
|
|
289
|
+
|
|
290
|
+
confidence = string_value((recommendation or {}).get("confidence")) or "high"
|
|
291
|
+
reasons = ["durable Trellis markdown artifact match"]
|
|
292
|
+
matched_fields = list_value(result.get("matched_fields"))
|
|
293
|
+
if matched_fields:
|
|
294
|
+
reasons.append(f"matched fields: {', '.join(str(item) for item in matched_fields)}")
|
|
295
|
+
|
|
296
|
+
return _build_scored(
|
|
297
|
+
source=SOURCE_ARTIFACT_SEARCH,
|
|
298
|
+
reference=reference,
|
|
299
|
+
title=title,
|
|
300
|
+
status=STATUS_OK,
|
|
301
|
+
trust=BASE_TRUST[SOURCE_ARTIFACT_SEARCH],
|
|
302
|
+
confidence=confidence,
|
|
303
|
+
relevance=relevance,
|
|
304
|
+
freshness=80,
|
|
305
|
+
source_authority=SOURCE_AUTHORITY[SOURCE_ARTIFACT_SEARCH],
|
|
306
|
+
validation_state=VALIDATION_VERIFIED,
|
|
307
|
+
reasons=reasons,
|
|
308
|
+
warnings=[],
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def score_session_memory_result(
|
|
313
|
+
result: dict[str, Any],
|
|
314
|
+
recommendation: dict[str, Any] | None,
|
|
315
|
+
) -> ScoredEvidence:
|
|
316
|
+
reference = string_value(result.get("path")) or ""
|
|
317
|
+
line = int_value(result.get("line"))
|
|
318
|
+
if line:
|
|
319
|
+
reference = f"{reference}:{line}"
|
|
320
|
+
title = string_value(result.get("title")) or "Session memory"
|
|
321
|
+
upstream_score = int_value(result.get("score"))
|
|
322
|
+
relevance = scale_upstream_score(upstream_score)
|
|
323
|
+
if recommendation:
|
|
324
|
+
relevance = max(relevance, scale_priority(int_value(recommendation.get("priority"), 80)))
|
|
325
|
+
|
|
326
|
+
confidence = string_value((recommendation or {}).get("confidence")) or "medium"
|
|
327
|
+
freshness = freshness_from_date(string_value(result.get("date")))
|
|
328
|
+
reason = string_value(result.get("reason"))
|
|
329
|
+
reasons = ["local session memory is historical context, not authoritative proof"]
|
|
330
|
+
if reason:
|
|
331
|
+
reasons.append(reason)
|
|
332
|
+
|
|
333
|
+
return _build_scored(
|
|
334
|
+
source=SOURCE_SESSION_MEMORY,
|
|
335
|
+
reference=reference,
|
|
336
|
+
title=title,
|
|
337
|
+
status=STATUS_OK,
|
|
338
|
+
trust=BASE_TRUST[SOURCE_SESSION_MEMORY],
|
|
339
|
+
confidence=confidence,
|
|
340
|
+
relevance=relevance,
|
|
341
|
+
freshness=freshness,
|
|
342
|
+
source_authority=SOURCE_AUTHORITY[SOURCE_SESSION_MEMORY],
|
|
343
|
+
validation_state=VALIDATION_UNVERIFIED,
|
|
344
|
+
reasons=reasons,
|
|
345
|
+
warnings=["confirm against durable task artifacts and current source"],
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
def score_smart_search_manifest(
|
|
350
|
+
manifest: dict[str, Any],
|
|
351
|
+
recommendation: dict[str, Any] | None,
|
|
352
|
+
) -> ScoredEvidence:
|
|
353
|
+
reference = (
|
|
354
|
+
string_value(manifest.get("manifestPath"))
|
|
355
|
+
or string_value(manifest.get("evidenceDir"))
|
|
356
|
+
or ""
|
|
357
|
+
)
|
|
358
|
+
title = string_value(manifest.get("query")) or "Smart Search evidence"
|
|
359
|
+
manifest_status = string_value(manifest.get("status")) or STATUS_FAILED
|
|
360
|
+
confidence = string_value((recommendation or {}).get("confidence")) or "medium"
|
|
361
|
+
relevance = scale_priority(int_value((recommendation or {}).get("priority"), 70))
|
|
362
|
+
freshness = freshness_from_iso(string_value(manifest.get("createdAt")))
|
|
363
|
+
|
|
364
|
+
if manifest_status == STATUS_OK:
|
|
365
|
+
return _build_scored(
|
|
366
|
+
source=SOURCE_SMART_SEARCH,
|
|
367
|
+
reference=reference,
|
|
368
|
+
title=title,
|
|
369
|
+
status=STATUS_OK,
|
|
370
|
+
trust=BASE_TRUST[SOURCE_SMART_SEARCH],
|
|
371
|
+
confidence=confidence,
|
|
372
|
+
relevance=max(relevance, 75),
|
|
373
|
+
freshness=freshness,
|
|
374
|
+
source_authority=SOURCE_AUTHORITY[SOURCE_SMART_SEARCH],
|
|
375
|
+
validation_state=VALIDATION_UNVERIFIED,
|
|
376
|
+
reasons=[
|
|
377
|
+
"source-backed external evidence",
|
|
378
|
+
"manifest status ok",
|
|
379
|
+
"current source validation still required",
|
|
380
|
+
],
|
|
381
|
+
warnings=[],
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
if manifest_status == STATUS_DEGRADED:
|
|
385
|
+
summary = string_value(manifest.get("summary"))
|
|
386
|
+
reasons = [
|
|
387
|
+
"source-backed external evidence with gaps",
|
|
388
|
+
"manifest status degraded",
|
|
389
|
+
]
|
|
390
|
+
if summary:
|
|
391
|
+
reasons.append(summary[:120])
|
|
392
|
+
return _build_scored(
|
|
393
|
+
source=SOURCE_SMART_SEARCH,
|
|
394
|
+
reference=reference,
|
|
395
|
+
title=title,
|
|
396
|
+
status=STATUS_DEGRADED,
|
|
397
|
+
trust="medium",
|
|
398
|
+
confidence="low",
|
|
399
|
+
relevance=max(relevance, 55),
|
|
400
|
+
freshness=freshness,
|
|
401
|
+
source_authority=SOURCE_AUTHORITY[SOURCE_SMART_SEARCH] - 15,
|
|
402
|
+
validation_state=VALIDATION_UNVERIFIED,
|
|
403
|
+
reasons=reasons,
|
|
404
|
+
warnings=["degraded Smart Search evidence; review gap explanation"],
|
|
405
|
+
status_penalty=15,
|
|
406
|
+
)
|
|
407
|
+
|
|
408
|
+
if manifest_status == STATUS_NOT_CONFIGURED:
|
|
409
|
+
error = string_value(manifest.get("error")) or "Smart Search is not configured"
|
|
410
|
+
return _build_scored(
|
|
411
|
+
source=SOURCE_SMART_SEARCH,
|
|
412
|
+
reference=reference,
|
|
413
|
+
title=title,
|
|
414
|
+
status=STATUS_NOT_CONFIGURED,
|
|
415
|
+
trust="low",
|
|
416
|
+
confidence="low",
|
|
417
|
+
relevance=min(relevance, 20),
|
|
418
|
+
freshness=freshness,
|
|
419
|
+
source_authority=20,
|
|
420
|
+
validation_state=VALIDATION_UNAVAILABLE,
|
|
421
|
+
reasons=[
|
|
422
|
+
"availability signal only; Smart Search is not configured",
|
|
423
|
+
error[:120],
|
|
424
|
+
],
|
|
425
|
+
warnings=["not_configured Smart Search must not be treated as evidence"],
|
|
426
|
+
score_cap=12,
|
|
427
|
+
)
|
|
428
|
+
|
|
429
|
+
error = string_value(manifest.get("error")) or "Smart Search run failed"
|
|
430
|
+
return _build_scored(
|
|
431
|
+
source=SOURCE_SMART_SEARCH,
|
|
432
|
+
reference=reference,
|
|
433
|
+
title=title,
|
|
434
|
+
status=STATUS_FAILED,
|
|
435
|
+
trust="low",
|
|
436
|
+
confidence="low",
|
|
437
|
+
relevance=min(relevance, 15),
|
|
438
|
+
freshness=freshness,
|
|
439
|
+
source_authority=15,
|
|
440
|
+
validation_state=VALIDATION_FAILED,
|
|
441
|
+
reasons=[
|
|
442
|
+
"availability signal only; Smart Search run failed",
|
|
443
|
+
error[:120],
|
|
444
|
+
],
|
|
445
|
+
warnings=["failed Smart Search must not be treated as positive evidence"],
|
|
446
|
+
score_cap=8,
|
|
447
|
+
)
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
def score_codebase_candidate(
|
|
451
|
+
candidate: dict[str, Any],
|
|
452
|
+
recommendation: dict[str, Any] | None,
|
|
453
|
+
) -> ScoredEvidence:
|
|
454
|
+
reference = (
|
|
455
|
+
string_value(candidate.get("reference"))
|
|
456
|
+
or string_value(candidate.get("path"))
|
|
457
|
+
or string_value((recommendation or {}).get("reference"))
|
|
458
|
+
or "current source tree"
|
|
459
|
+
)
|
|
460
|
+
title = string_value(candidate.get("title")) or "Codebase candidate evidence"
|
|
461
|
+
upstream_score = int_value(candidate.get("score"))
|
|
462
|
+
relevance = scale_upstream_score(upstream_score) if upstream_score else 50
|
|
463
|
+
if recommendation:
|
|
464
|
+
relevance = max(relevance, scale_priority(int_value(recommendation.get("priority"), 60)))
|
|
465
|
+
|
|
466
|
+
confidence = string_value(candidate.get("confidence")) or string_value(
|
|
467
|
+
(recommendation or {}).get("confidence")
|
|
468
|
+
) or "medium"
|
|
469
|
+
status = string_value(candidate.get("status")) or STATUS_OK
|
|
470
|
+
validation_state = VALIDATION_CANDIDATE
|
|
471
|
+
warnings = ["candidate evidence requires current source, Git, or validation confirmation"]
|
|
472
|
+
reasons = [
|
|
473
|
+
string_value(candidate.get("reason"))
|
|
474
|
+
or string_value((recommendation or {}).get("reason"))
|
|
475
|
+
or "codebase retrieval is candidate evidence until validated",
|
|
476
|
+
]
|
|
477
|
+
|
|
478
|
+
return _build_scored(
|
|
479
|
+
source=SOURCE_CODEBASE_EVIDENCE,
|
|
480
|
+
reference=reference,
|
|
481
|
+
title=title,
|
|
482
|
+
status=status,
|
|
483
|
+
trust=BASE_TRUST[SOURCE_CODEBASE_EVIDENCE],
|
|
484
|
+
confidence=confidence,
|
|
485
|
+
relevance=relevance,
|
|
486
|
+
freshness=int_value(candidate.get("freshness"), 50),
|
|
487
|
+
source_authority=SOURCE_AUTHORITY[SOURCE_CODEBASE_EVIDENCE],
|
|
488
|
+
validation_state=validation_state,
|
|
489
|
+
reasons=reasons,
|
|
490
|
+
warnings=warnings,
|
|
491
|
+
status_penalty=10 if status != STATUS_OK else 0,
|
|
492
|
+
)
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
def score_missing_recommendations(
|
|
496
|
+
recommendations: list[dict[str, Any]],
|
|
497
|
+
consumed_sources: set[str],
|
|
498
|
+
has_smart_search_manifests: bool,
|
|
499
|
+
) -> list[ScoredEvidence]:
|
|
500
|
+
items: list[ScoredEvidence] = []
|
|
501
|
+
for recommendation in recommendations:
|
|
502
|
+
if not isinstance(recommendation, dict):
|
|
503
|
+
continue
|
|
504
|
+
source = string_value(recommendation.get("source")) or ""
|
|
505
|
+
if source not in SOURCES or source in consumed_sources:
|
|
506
|
+
continue
|
|
507
|
+
if source == SOURCE_SMART_SEARCH and has_smart_search_manifests:
|
|
508
|
+
continue
|
|
509
|
+
if source == SOURCE_TASK_ARTIFACTS:
|
|
510
|
+
continue
|
|
511
|
+
|
|
512
|
+
reference = string_value(recommendation.get("reference")) or source
|
|
513
|
+
title = f"Missing {source} evidence"
|
|
514
|
+
items.append(
|
|
515
|
+
_build_scored(
|
|
516
|
+
source=source,
|
|
517
|
+
reference=reference,
|
|
518
|
+
title=title,
|
|
519
|
+
status=STATUS_MISSING,
|
|
520
|
+
trust="low",
|
|
521
|
+
confidence=string_value(recommendation.get("confidence")) or "low",
|
|
522
|
+
relevance=scale_priority(int_value(recommendation.get("priority"))),
|
|
523
|
+
freshness=30,
|
|
524
|
+
source_authority=max(20, SOURCE_AUTHORITY.get(source, 30) - 40),
|
|
525
|
+
validation_state=VALIDATION_UNAVAILABLE,
|
|
526
|
+
reasons=[
|
|
527
|
+
f"{source} recommended but no scored evidence payload was provided",
|
|
528
|
+
string_value(recommendation.get("reason")) or "awaiting explicit retrieval",
|
|
529
|
+
],
|
|
530
|
+
warnings=[f"missing {source} evidence"],
|
|
531
|
+
score_cap=18,
|
|
532
|
+
)
|
|
533
|
+
)
|
|
534
|
+
return items
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
def sort_scored_evidence(items: list[ScoredEvidence]) -> list[ScoredEvidence]:
|
|
538
|
+
return sorted(
|
|
539
|
+
items,
|
|
540
|
+
key=lambda item: (
|
|
541
|
+
-item.score,
|
|
542
|
+
SOURCE_ORDER.get(item.source, 99),
|
|
543
|
+
item.reference,
|
|
544
|
+
item.title,
|
|
545
|
+
),
|
|
546
|
+
)
|
|
547
|
+
|
|
548
|
+
|
|
549
|
+
def _build_scored(
|
|
550
|
+
*,
|
|
551
|
+
source: str,
|
|
552
|
+
reference: str,
|
|
553
|
+
title: str,
|
|
554
|
+
status: str,
|
|
555
|
+
trust: str,
|
|
556
|
+
confidence: str,
|
|
557
|
+
relevance: int,
|
|
558
|
+
freshness: int,
|
|
559
|
+
source_authority: int,
|
|
560
|
+
validation_state: str,
|
|
561
|
+
reasons: list[str],
|
|
562
|
+
warnings: list[str],
|
|
563
|
+
status_penalty: int = 0,
|
|
564
|
+
score_cap: int | None = None,
|
|
565
|
+
) -> ScoredEvidence:
|
|
566
|
+
trust_value = TRUST_SCORE.get(trust, 70)
|
|
567
|
+
raw_score = round(
|
|
568
|
+
relevance * 0.45
|
|
569
|
+
+ source_authority * 0.25
|
|
570
|
+
+ freshness * 0.15
|
|
571
|
+
+ trust_value * 0.15
|
|
572
|
+
- status_penalty
|
|
573
|
+
)
|
|
574
|
+
if score_cap is not None:
|
|
575
|
+
raw_score = min(raw_score, score_cap)
|
|
576
|
+
score = clamp(raw_score, 0, 100)
|
|
577
|
+
|
|
578
|
+
return ScoredEvidence(
|
|
579
|
+
source=source,
|
|
580
|
+
kind=KIND_BY_SOURCE.get(source, "evidence"),
|
|
581
|
+
reference=reference,
|
|
582
|
+
title=title,
|
|
583
|
+
status=status,
|
|
584
|
+
trust=trust,
|
|
585
|
+
confidence=confidence,
|
|
586
|
+
relevance=clamp(relevance, 0, 100),
|
|
587
|
+
freshness=clamp(freshness, 0, 100),
|
|
588
|
+
source_authority=clamp(source_authority, 0, 100),
|
|
589
|
+
validation_state=validation_state,
|
|
590
|
+
score=score,
|
|
591
|
+
reasons=normalize_reasons(reasons),
|
|
592
|
+
warnings=normalize_reasons(warnings),
|
|
593
|
+
)
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
def index_recommendations(
|
|
597
|
+
recommendations: list[Any],
|
|
598
|
+
) -> dict[str, dict[str, Any]]:
|
|
599
|
+
indexed: dict[str, dict[str, Any]] = {}
|
|
600
|
+
for item in recommendations:
|
|
601
|
+
if not isinstance(item, dict):
|
|
602
|
+
continue
|
|
603
|
+
source = string_value(item.get("source"))
|
|
604
|
+
if source:
|
|
605
|
+
indexed[source] = item
|
|
606
|
+
return indexed
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
def scale_priority(priority: int, default: int = 50) -> int:
|
|
610
|
+
value = priority if priority > 0 else default
|
|
611
|
+
return clamp(round(value / MAX_RECOMMENDATION_PRIORITY * 100), 0, 100)
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
def scale_upstream_score(score: int, default: int = 40) -> int:
|
|
615
|
+
if score <= 0:
|
|
616
|
+
return default
|
|
617
|
+
return clamp(round(score / MAX_UPSTREAM_SCORE * 100), 0, 100)
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
def freshness_from_date(value: str | None) -> int:
|
|
621
|
+
if not value:
|
|
622
|
+
return 50
|
|
623
|
+
try:
|
|
624
|
+
parsed = datetime.strptime(value[:10], "%Y-%m-%d").replace(tzinfo=timezone.utc)
|
|
625
|
+
except ValueError:
|
|
626
|
+
return 50
|
|
627
|
+
age_days = (datetime.now(timezone.utc) - parsed).days
|
|
628
|
+
if age_days <= 0:
|
|
629
|
+
return 95
|
|
630
|
+
if age_days <= 7:
|
|
631
|
+
return 85
|
|
632
|
+
if age_days <= 30:
|
|
633
|
+
return 70
|
|
634
|
+
if age_days <= 90:
|
|
635
|
+
return 55
|
|
636
|
+
return 35
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
def freshness_from_iso(value: str | None) -> int:
|
|
640
|
+
if not value:
|
|
641
|
+
return 60
|
|
642
|
+
normalized = value.replace("Z", "+00:00")
|
|
643
|
+
try:
|
|
644
|
+
parsed = datetime.fromisoformat(normalized)
|
|
645
|
+
except ValueError:
|
|
646
|
+
return freshness_from_date(value)
|
|
647
|
+
if parsed.tzinfo is None:
|
|
648
|
+
parsed = parsed.replace(tzinfo=timezone.utc)
|
|
649
|
+
age_days = (datetime.now(timezone.utc) - parsed).days
|
|
650
|
+
if age_days <= 0:
|
|
651
|
+
return 90
|
|
652
|
+
if age_days <= 3:
|
|
653
|
+
return 85
|
|
654
|
+
if age_days <= 14:
|
|
655
|
+
return 75
|
|
656
|
+
if age_days <= 60:
|
|
657
|
+
return 60
|
|
658
|
+
return 40
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
def normalize_reasons(values: list[str]) -> list[str]:
|
|
662
|
+
seen: set[str] = set()
|
|
663
|
+
normalized: list[str] = []
|
|
664
|
+
for value in values:
|
|
665
|
+
text = normalize_space(value)
|
|
666
|
+
if not text or text in seen:
|
|
667
|
+
continue
|
|
668
|
+
seen.add(text)
|
|
669
|
+
normalized.append(text[:200])
|
|
670
|
+
return normalized
|
|
671
|
+
|
|
672
|
+
|
|
673
|
+
def normalize_space(value: str) -> str:
|
|
674
|
+
return " ".join(value.split()).strip()
|
|
675
|
+
|
|
676
|
+
|
|
677
|
+
def clamp(value: int, lower: int, upper: int) -> int:
|
|
678
|
+
return max(lower, min(upper, value))
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
# ---------------------------------------------------------------------------
|
|
682
|
+
# RB-009: Cross-source conflict resolution PoC
|
|
683
|
+
# ---------------------------------------------------------------------------
|
|
684
|
+
|
|
685
|
+
INTENT_AUTHORITY_ADJUSTMENTS: dict[str, dict[str, int]] = {
|
|
686
|
+
"policy-document": {SOURCE_ARTIFACT_SEARCH: 10, SOURCE_CODEBASE_EVIDENCE: -5},
|
|
687
|
+
"caller-chain": {SOURCE_CODEBASE_EVIDENCE: 20},
|
|
688
|
+
"trap-package-disambiguation": {SOURCE_CODEBASE_EVIDENCE: 15},
|
|
689
|
+
"extension-shared-symbol": {SOURCE_CODEBASE_EVIDENCE: 15},
|
|
690
|
+
"env-config-literal": {SOURCE_CODEBASE_EVIDENCE: 5, SOURCE_SMART_SEARCH: -10},
|
|
691
|
+
"cross-cutting-discovery": {SOURCE_SMART_SEARCH: 10, SOURCE_CODEBASE_EVIDENCE: -5},
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
STALE_FRESHNESS_THRESHOLD = 50
|
|
695
|
+
CONFLICT_PENALTY_CANDIDATE = 5
|
|
696
|
+
STALE_PENALTY = 10
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
def _title_tokens(title: str) -> set[str]:
|
|
700
|
+
return set(normalize_space(title).lower().split())
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
def _jaccard_similarity(tokens_a: set[str], tokens_b: set[str]) -> float:
|
|
704
|
+
if not tokens_a or not tokens_b:
|
|
705
|
+
return 0.0
|
|
706
|
+
intersection = tokens_a & tokens_b
|
|
707
|
+
union = tokens_a | tokens_b
|
|
708
|
+
return len(intersection) / len(union)
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
def _effective_authority(
|
|
712
|
+
item: ScoredEvidence,
|
|
713
|
+
query_intent: str | None,
|
|
714
|
+
) -> int:
|
|
715
|
+
base = item.source_authority
|
|
716
|
+
if not query_intent:
|
|
717
|
+
return base
|
|
718
|
+
adjustments = INTENT_AUTHORITY_ADJUSTMENTS.get(query_intent, {})
|
|
719
|
+
return clamp(base + adjustments.get(item.source, 0), 0, 100)
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
@dataclass
|
|
723
|
+
class ConflictDescriptor:
|
|
724
|
+
source_a: str
|
|
725
|
+
reference_a: str
|
|
726
|
+
source_b: str
|
|
727
|
+
reference_b: str
|
|
728
|
+
conflict_type: str # "blocking" | "downgrade" | "stale"
|
|
729
|
+
resolution: str
|
|
730
|
+
|
|
731
|
+
|
|
732
|
+
@dataclass
|
|
733
|
+
class ArbitratedEvidence:
|
|
734
|
+
item: ScoredEvidence
|
|
735
|
+
effective_authority: int
|
|
736
|
+
conflict_flags: list[str]
|
|
737
|
+
arbitration_reasons: list[str]
|
|
738
|
+
|
|
739
|
+
def to_json(self) -> dict[str, Any]:
|
|
740
|
+
result = self.item.to_json()
|
|
741
|
+
result["effectiveAuthority"] = self.effective_authority
|
|
742
|
+
result["conflictFlags"] = list(self.conflict_flags)
|
|
743
|
+
result["arbitrationReasons"] = list(self.arbitration_reasons)
|
|
744
|
+
return result
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
def resolve_cross_source_conflicts(
|
|
748
|
+
items: list[ScoredEvidence],
|
|
749
|
+
*,
|
|
750
|
+
query_intent: str | None = None,
|
|
751
|
+
conflict_threshold: float = 0.5,
|
|
752
|
+
freshness_threshold: int = STALE_FRESHNESS_THRESHOLD,
|
|
753
|
+
) -> dict[str, Any]:
|
|
754
|
+
"""Resolve cross-source conflicts in scored evidence.
|
|
755
|
+
|
|
756
|
+
Returns dict with:
|
|
757
|
+
- items: list of ArbitratedEvidence, sorted by effective authority then score
|
|
758
|
+
- conflicts: list of ConflictDescriptor
|
|
759
|
+
- metrics: conflict/arbitration summary
|
|
760
|
+
"""
|
|
761
|
+
conflicts: list[ConflictDescriptor] = []
|
|
762
|
+
arbitrated: list[ArbitratedEvidence] = []
|
|
763
|
+
|
|
764
|
+
for item in items:
|
|
765
|
+
effective = _effective_authority(item, query_intent)
|
|
766
|
+
flags: list[str] = []
|
|
767
|
+
reasons: list[str] = []
|
|
768
|
+
|
|
769
|
+
# Stale session-memory penalty
|
|
770
|
+
if item.source == SOURCE_SESSION_MEMORY and item.freshness < freshness_threshold:
|
|
771
|
+
effective = clamp(effective - STALE_PENALTY, 0, 100)
|
|
772
|
+
flags.append("stale_warning")
|
|
773
|
+
reasons.append(
|
|
774
|
+
f"session-memory freshness {item.freshness} < {freshness_threshold}; authority penalty -{STALE_PENALTY}"
|
|
775
|
+
)
|
|
776
|
+
|
|
777
|
+
arbitrated.append(
|
|
778
|
+
ArbitratedEvidence(
|
|
779
|
+
item=item,
|
|
780
|
+
effective_authority=effective,
|
|
781
|
+
conflict_flags=flags,
|
|
782
|
+
arbitration_reasons=reasons,
|
|
783
|
+
)
|
|
784
|
+
)
|
|
785
|
+
|
|
786
|
+
# Pairwise conflict detection
|
|
787
|
+
n = len(arbitrated)
|
|
788
|
+
for i in range(n):
|
|
789
|
+
for j in range(i + 1, n):
|
|
790
|
+
a = arbitrated[i]
|
|
791
|
+
b = arbitrated[j]
|
|
792
|
+
if a.item.source == b.item.source:
|
|
793
|
+
continue
|
|
794
|
+
|
|
795
|
+
tokens_a = _title_tokens(a.item.title)
|
|
796
|
+
tokens_b = _title_tokens(b.item.title)
|
|
797
|
+
similarity = _jaccard_similarity(tokens_a, tokens_b)
|
|
798
|
+
if similarity < conflict_threshold:
|
|
799
|
+
continue
|
|
800
|
+
|
|
801
|
+
# Potential conflict detected
|
|
802
|
+
a_verified = a.item.validation_state == VALIDATION_VERIFIED
|
|
803
|
+
b_verified = b.item.validation_state == VALIDATION_VERIFIED
|
|
804
|
+
|
|
805
|
+
if a_verified and b_verified:
|
|
806
|
+
conflict_type = "blocking"
|
|
807
|
+
resolution = (
|
|
808
|
+
f"Both sources verified and overlapping (sim={similarity:.2f}); "
|
|
809
|
+
"requires human resolution"
|
|
810
|
+
)
|
|
811
|
+
a.conflict_flags.append("blocking_conflict")
|
|
812
|
+
b.conflict_flags.append("blocking_conflict")
|
|
813
|
+
a.arbitration_reasons.append(
|
|
814
|
+
f"blocking conflict with {b.item.source}: {b.item.reference}"
|
|
815
|
+
)
|
|
816
|
+
b.arbitration_reasons.append(
|
|
817
|
+
f"blocking conflict with {a.item.source}: {a.item.reference}"
|
|
818
|
+
)
|
|
819
|
+
elif a_verified and not b_verified:
|
|
820
|
+
conflict_type = "downgrade"
|
|
821
|
+
resolution = (
|
|
822
|
+
f"{a.item.source} verified vs {b.item.source} {b.item.validation_state}; "
|
|
823
|
+
f"downgrading {b.item.source}"
|
|
824
|
+
)
|
|
825
|
+
b.effective_authority = clamp(
|
|
826
|
+
b.effective_authority - CONFLICT_PENALTY_CANDIDATE, 0, 100
|
|
827
|
+
)
|
|
828
|
+
b.conflict_flags.append("conflict_flagged")
|
|
829
|
+
b.arbitration_reasons.append(
|
|
830
|
+
f"downgraded due to conflict with verified {a.item.source}"
|
|
831
|
+
)
|
|
832
|
+
elif b_verified and not a_verified:
|
|
833
|
+
conflict_type = "downgrade"
|
|
834
|
+
resolution = (
|
|
835
|
+
f"{b.item.source} verified vs {a.item.source} {a.item.validation_state}; "
|
|
836
|
+
f"downgrading {a.item.source}"
|
|
837
|
+
)
|
|
838
|
+
a.effective_authority = clamp(
|
|
839
|
+
a.effective_authority - CONFLICT_PENALTY_CANDIDATE, 0, 100
|
|
840
|
+
)
|
|
841
|
+
a.conflict_flags.append("conflict_flagged")
|
|
842
|
+
a.arbitration_reasons.append(
|
|
843
|
+
f"downgraded due to conflict with verified {b.item.source}"
|
|
844
|
+
)
|
|
845
|
+
else:
|
|
846
|
+
continue
|
|
847
|
+
|
|
848
|
+
conflicts.append(
|
|
849
|
+
ConflictDescriptor(
|
|
850
|
+
source_a=a.item.source,
|
|
851
|
+
reference_a=a.item.reference,
|
|
852
|
+
source_b=b.item.source,
|
|
853
|
+
reference_b=b.item.reference,
|
|
854
|
+
conflict_type=conflict_type,
|
|
855
|
+
resolution=resolution,
|
|
856
|
+
)
|
|
857
|
+
)
|
|
858
|
+
|
|
859
|
+
# Re-sort by effective authority (desc) then score (desc) then source order
|
|
860
|
+
arbitrated.sort(
|
|
861
|
+
key=lambda ae: (
|
|
862
|
+
-ae.effective_authority,
|
|
863
|
+
-ae.item.score,
|
|
864
|
+
SOURCE_ORDER.get(ae.item.source, 99),
|
|
865
|
+
)
|
|
866
|
+
)
|
|
867
|
+
|
|
868
|
+
blocking_count = sum(1 for c in conflicts if c.conflict_type == "blocking")
|
|
869
|
+
downgrade_count = sum(1 for ae in arbitrated if "conflict_flagged" in ae.conflict_flags)
|
|
870
|
+
|
|
871
|
+
return {
|
|
872
|
+
"version": 1,
|
|
873
|
+
"total": len(arbitrated),
|
|
874
|
+
"items": [ae.to_json() for ae in arbitrated],
|
|
875
|
+
"conflicts": [
|
|
876
|
+
{
|
|
877
|
+
"sourceA": c.source_a,
|
|
878
|
+
"referenceA": c.reference_a,
|
|
879
|
+
"sourceB": c.source_b,
|
|
880
|
+
"referenceB": c.reference_b,
|
|
881
|
+
"type": c.conflict_type,
|
|
882
|
+
"resolution": c.resolution,
|
|
883
|
+
}
|
|
884
|
+
for c in conflicts
|
|
885
|
+
],
|
|
886
|
+
"metrics": {
|
|
887
|
+
"totalItems": len(arbitrated),
|
|
888
|
+
"conflictCount": len(conflicts),
|
|
889
|
+
"blockingConflictCount": blocking_count,
|
|
890
|
+
"downgradeCount": downgrade_count,
|
|
891
|
+
},
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
def dict_value(value: Any) -> dict[str, Any]:
|
|
896
|
+
return value if isinstance(value, dict) else {}
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
def list_value(value: Any) -> list[Any]:
|
|
900
|
+
return value if isinstance(value, list) else []
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
def string_value(value: Any) -> str | None:
|
|
904
|
+
if isinstance(value, str):
|
|
905
|
+
stripped = value.strip()
|
|
906
|
+
return stripped or None
|
|
907
|
+
return None
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
def int_value(value: Any, default: int = 0) -> int:
|
|
911
|
+
if isinstance(value, bool):
|
|
912
|
+
return int(value)
|
|
913
|
+
if isinstance(value, int):
|
|
914
|
+
return value
|
|
915
|
+
if isinstance(value, float):
|
|
916
|
+
return int(value)
|
|
917
|
+
return default
|