@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,141 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import time
|
|
3
|
+
from typing import Any
|
|
4
|
+
from urllib.parse import quote
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
from tenacity import AsyncRetrying, retry_if_exception, stop_after_attempt, wait_random_exponential
|
|
8
|
+
|
|
9
|
+
from .base import BaseSearchProvider
|
|
10
|
+
from ..config import config
|
|
11
|
+
from ..logger import log_info
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
RETRYABLE_STATUS_CODES = {408, 429, 500, 502, 503, 504}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _is_retryable_exception(exc) -> bool:
|
|
18
|
+
if isinstance(exc, (httpx.TimeoutException, httpx.NetworkError, httpx.ConnectError)):
|
|
19
|
+
return True
|
|
20
|
+
if isinstance(exc, httpx.HTTPStatusError):
|
|
21
|
+
return exc.response.status_code in RETRYABLE_STATUS_CODES
|
|
22
|
+
return False
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _normalize_library(item: dict[str, Any]) -> dict[str, Any]:
|
|
26
|
+
return {
|
|
27
|
+
"id": item.get("id") or "",
|
|
28
|
+
"title": item.get("title") or "",
|
|
29
|
+
"description": item.get("description") or "",
|
|
30
|
+
"trust_score": item.get("trustScore"),
|
|
31
|
+
"benchmark_score": item.get("benchmarkScore"),
|
|
32
|
+
"total_snippets": item.get("totalSnippets"),
|
|
33
|
+
"stars": item.get("stars"),
|
|
34
|
+
"provider": "context7",
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Context7Provider(BaseSearchProvider):
|
|
39
|
+
def __init__(self, api_url: str, api_key: str, timeout: float = 30.0):
|
|
40
|
+
super().__init__(api_url.rstrip("/"), api_key)
|
|
41
|
+
self.timeout = timeout
|
|
42
|
+
|
|
43
|
+
def get_provider_name(self) -> str:
|
|
44
|
+
return "Context7"
|
|
45
|
+
|
|
46
|
+
async def search(self, query: str, max_results: int = 5) -> str:
|
|
47
|
+
return await self.library(query)
|
|
48
|
+
|
|
49
|
+
def _headers(self) -> dict[str, str]:
|
|
50
|
+
headers = {
|
|
51
|
+
"Accept": "application/json, text/plain",
|
|
52
|
+
"X-Context7-Source": "smart-search",
|
|
53
|
+
}
|
|
54
|
+
if self.api_key:
|
|
55
|
+
headers["Authorization"] = f"Bearer {self.api_key}"
|
|
56
|
+
return headers
|
|
57
|
+
|
|
58
|
+
async def library(self, name: str, query: str = "", ctx=None) -> str:
|
|
59
|
+
request_query = f"{name} {query}".strip()
|
|
60
|
+
endpoint = f"{self.api_url}/api/v2/search?query={quote(request_query)}"
|
|
61
|
+
await log_info(ctx, f"Context7 library: {request_query}", config.debug_enabled)
|
|
62
|
+
start_time = time.time()
|
|
63
|
+
try:
|
|
64
|
+
data = await self._get_with_retry(endpoint)
|
|
65
|
+
elapsed_ms = round((time.time() - start_time) * 1000, 2)
|
|
66
|
+
raw_results = data if isinstance(data, list) else data.get("results", [])
|
|
67
|
+
results = [_normalize_library(item) for item in raw_results or []]
|
|
68
|
+
output = {
|
|
69
|
+
"ok": True,
|
|
70
|
+
"query": request_query,
|
|
71
|
+
"provider": "context7",
|
|
72
|
+
"results": results,
|
|
73
|
+
"total": len(results),
|
|
74
|
+
"elapsed_ms": elapsed_ms,
|
|
75
|
+
}
|
|
76
|
+
except Exception as e:
|
|
77
|
+
elapsed_ms = round((time.time() - start_time) * 1000, 2)
|
|
78
|
+
output = {
|
|
79
|
+
"ok": False,
|
|
80
|
+
"query": request_query,
|
|
81
|
+
"provider": "context7",
|
|
82
|
+
"error": str(e),
|
|
83
|
+
"elapsed_ms": elapsed_ms,
|
|
84
|
+
}
|
|
85
|
+
return json.dumps(output, ensure_ascii=False, indent=2)
|
|
86
|
+
|
|
87
|
+
async def docs(self, library_id: str, query: str, ctx=None) -> str:
|
|
88
|
+
endpoint = f"{self.api_url}/api/v2/context?libraryId={quote(library_id, safe='')}&query={quote(query)}"
|
|
89
|
+
await log_info(ctx, f"Context7 docs: {library_id} {query}", config.debug_enabled)
|
|
90
|
+
start_time = time.time()
|
|
91
|
+
try:
|
|
92
|
+
data = await self._get_with_retry(endpoint)
|
|
93
|
+
elapsed_ms = round((time.time() - start_time) * 1000, 2)
|
|
94
|
+
snippets = data.get("codeSnippets", []) if isinstance(data, dict) else []
|
|
95
|
+
info = data.get("infoSnippets", []) if isinstance(data, dict) else []
|
|
96
|
+
content = json.dumps(data, ensure_ascii=False) if isinstance(data, dict) else str(data)
|
|
97
|
+
output = {
|
|
98
|
+
"ok": True,
|
|
99
|
+
"library_id": library_id,
|
|
100
|
+
"query": query,
|
|
101
|
+
"provider": "context7",
|
|
102
|
+
"code_snippets": snippets,
|
|
103
|
+
"info_snippets": info,
|
|
104
|
+
"results": snippets + info,
|
|
105
|
+
"total": len(snippets) + len(info),
|
|
106
|
+
"content": content,
|
|
107
|
+
"elapsed_ms": elapsed_ms,
|
|
108
|
+
}
|
|
109
|
+
except Exception as e:
|
|
110
|
+
elapsed_ms = round((time.time() - start_time) * 1000, 2)
|
|
111
|
+
output = {
|
|
112
|
+
"ok": False,
|
|
113
|
+
"library_id": library_id,
|
|
114
|
+
"query": query,
|
|
115
|
+
"provider": "context7",
|
|
116
|
+
"error": str(e),
|
|
117
|
+
"elapsed_ms": elapsed_ms,
|
|
118
|
+
}
|
|
119
|
+
return json.dumps(output, ensure_ascii=False, indent=2)
|
|
120
|
+
|
|
121
|
+
async def _get_with_retry(self, endpoint: str) -> Any:
|
|
122
|
+
timeout = httpx.Timeout(connect=6.0, read=self.timeout, write=10.0, pool=None)
|
|
123
|
+
async with httpx.AsyncClient(timeout=timeout, follow_redirects=True) as client:
|
|
124
|
+
async for attempt in AsyncRetrying(
|
|
125
|
+
stop=stop_after_attempt(config.retry_max_attempts + 1),
|
|
126
|
+
wait=wait_random_exponential(multiplier=config.retry_multiplier, max=config.retry_max_wait),
|
|
127
|
+
retry=retry_if_exception(_is_retryable_exception),
|
|
128
|
+
reraise=True,
|
|
129
|
+
):
|
|
130
|
+
with attempt:
|
|
131
|
+
response = await client.get(endpoint, headers=self._headers())
|
|
132
|
+
response.raise_for_status()
|
|
133
|
+
content_type = response.headers.get("content-type", "")
|
|
134
|
+
if "application/json" in content_type:
|
|
135
|
+
return response.json()
|
|
136
|
+
text = response.text
|
|
137
|
+
try:
|
|
138
|
+
return json.loads(text)
|
|
139
|
+
except json.JSONDecodeError:
|
|
140
|
+
return {"content": text, "results": []}
|
|
141
|
+
return {}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import time
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
from tenacity import AsyncRetrying, retry_if_exception, stop_after_attempt, wait_random_exponential
|
|
7
|
+
|
|
8
|
+
from .base import BaseSearchProvider
|
|
9
|
+
from ..config import config
|
|
10
|
+
from ..logger import log_info
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
RETRYABLE_STATUS_CODES = {408, 429, 500, 502, 503, 504}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _is_retryable_exception(exc) -> bool:
|
|
17
|
+
if isinstance(exc, (httpx.TimeoutException, httpx.NetworkError, httpx.ConnectError)):
|
|
18
|
+
return True
|
|
19
|
+
if isinstance(exc, httpx.HTTPStatusError):
|
|
20
|
+
return exc.response.status_code in RETRYABLE_STATUS_CODES
|
|
21
|
+
return False
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _normalize_result(item: dict[str, Any], *, include_text: bool, include_highlights: bool) -> dict[str, Any]:
|
|
25
|
+
out = {
|
|
26
|
+
"id": item.get("id"),
|
|
27
|
+
"title": item.get("title") or "",
|
|
28
|
+
"url": item.get("url") or item.get("id") or "",
|
|
29
|
+
"publishedDate": item.get("publishedDate"),
|
|
30
|
+
"author": item.get("author") or "",
|
|
31
|
+
"score": item.get("score"),
|
|
32
|
+
}
|
|
33
|
+
if include_text and "text" in item:
|
|
34
|
+
out["text"] = item.get("text") or ""
|
|
35
|
+
if include_highlights and "highlights" in item:
|
|
36
|
+
out["highlights"] = item.get("highlights") or []
|
|
37
|
+
if "image" in item:
|
|
38
|
+
out["image"] = item.get("image")
|
|
39
|
+
if "favicon" in item:
|
|
40
|
+
out["favicon"] = item.get("favicon")
|
|
41
|
+
return out
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _error_payload(exc: Exception) -> dict[str, Any]:
|
|
45
|
+
if isinstance(exc, httpx.HTTPStatusError):
|
|
46
|
+
status_code = exc.response.status_code
|
|
47
|
+
body = exc.response.text.strip()
|
|
48
|
+
detail = f" - {body[:500]}" if body else ""
|
|
49
|
+
if status_code == 429:
|
|
50
|
+
error_type = "rate_limited"
|
|
51
|
+
elif status_code in {400, 422}:
|
|
52
|
+
error_type = "parameter_error"
|
|
53
|
+
elif status_code in {401, 403}:
|
|
54
|
+
error_type = "auth_error"
|
|
55
|
+
else:
|
|
56
|
+
error_type = "network_error"
|
|
57
|
+
return {"error_type": error_type, "error": f"HTTP {status_code}: {exc.response.reason_phrase}{detail}"}
|
|
58
|
+
if isinstance(exc, httpx.TimeoutException):
|
|
59
|
+
return {"error_type": "timeout", "error": "request timed out"}
|
|
60
|
+
if isinstance(exc, httpx.RequestError):
|
|
61
|
+
return {"error_type": "network_error", "error": str(exc)}
|
|
62
|
+
return {"error_type": "runtime_error", "error": str(exc)}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class ExaSearchProvider(BaseSearchProvider):
|
|
66
|
+
def __init__(self, api_url: str, api_key: str, timeout: float = 30.0):
|
|
67
|
+
super().__init__(api_url, api_key)
|
|
68
|
+
self.timeout = timeout
|
|
69
|
+
|
|
70
|
+
def get_provider_name(self) -> str:
|
|
71
|
+
return "Exa"
|
|
72
|
+
|
|
73
|
+
async def search(
|
|
74
|
+
self,
|
|
75
|
+
query: str,
|
|
76
|
+
num_results: int = 5,
|
|
77
|
+
search_type: str = "neural",
|
|
78
|
+
include_text: bool = False,
|
|
79
|
+
include_highlights: bool = False,
|
|
80
|
+
start_published_date: str | None = None,
|
|
81
|
+
include_domains: list[str] | None = None,
|
|
82
|
+
exclude_domains: list[str] | None = None,
|
|
83
|
+
category: str | None = None,
|
|
84
|
+
ctx=None,
|
|
85
|
+
) -> str:
|
|
86
|
+
endpoint = f"{self.api_url.rstrip('/')}/search"
|
|
87
|
+
headers = {
|
|
88
|
+
"accept": "application/json",
|
|
89
|
+
"content-type": "application/json",
|
|
90
|
+
"x-api-key": self.api_key,
|
|
91
|
+
}
|
|
92
|
+
payload: dict[str, Any] = {
|
|
93
|
+
"query": query,
|
|
94
|
+
"numResults": num_results,
|
|
95
|
+
"type": search_type,
|
|
96
|
+
"useAutoprompt": True,
|
|
97
|
+
}
|
|
98
|
+
if include_text or include_highlights:
|
|
99
|
+
payload["contents"] = {
|
|
100
|
+
"text": include_text,
|
|
101
|
+
"highlights": include_highlights,
|
|
102
|
+
}
|
|
103
|
+
if start_published_date:
|
|
104
|
+
payload["startPublishedDate"] = start_published_date
|
|
105
|
+
if include_domains:
|
|
106
|
+
payload["includeDomains"] = include_domains
|
|
107
|
+
if exclude_domains:
|
|
108
|
+
payload["excludeDomains"] = exclude_domains
|
|
109
|
+
if category:
|
|
110
|
+
payload["category"] = category
|
|
111
|
+
|
|
112
|
+
await log_info(ctx, f"Exa search: {query}", config.debug_enabled)
|
|
113
|
+
|
|
114
|
+
start_time = time.time()
|
|
115
|
+
try:
|
|
116
|
+
data = await self._request_with_retry(endpoint, headers, payload, ctx)
|
|
117
|
+
elapsed_ms = round((time.time() - start_time) * 1000, 2)
|
|
118
|
+
|
|
119
|
+
results = [
|
|
120
|
+
_normalize_result(item, include_text=include_text, include_highlights=include_highlights)
|
|
121
|
+
for item in data.get("results", [])
|
|
122
|
+
]
|
|
123
|
+
|
|
124
|
+
output = {
|
|
125
|
+
"ok": True,
|
|
126
|
+
"query": query,
|
|
127
|
+
"search_type": search_type,
|
|
128
|
+
"results": results,
|
|
129
|
+
"total": len(results),
|
|
130
|
+
"elapsed_ms": elapsed_ms,
|
|
131
|
+
}
|
|
132
|
+
except Exception as e:
|
|
133
|
+
elapsed_ms = round((time.time() - start_time) * 1000, 2)
|
|
134
|
+
error = _error_payload(e)
|
|
135
|
+
output = {
|
|
136
|
+
"ok": False,
|
|
137
|
+
"query": query,
|
|
138
|
+
"error_type": error["error_type"],
|
|
139
|
+
"error": error["error"],
|
|
140
|
+
"elapsed_ms": elapsed_ms,
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
await log_info(ctx, "Exa search finished!", config.debug_enabled)
|
|
144
|
+
return json.dumps(output, ensure_ascii=False, indent=2)
|
|
145
|
+
|
|
146
|
+
async def find_similar(self, url: str, num_results: int = 5, ctx=None) -> str:
|
|
147
|
+
endpoint = f"{self.api_url.rstrip('/')}/findSimilar"
|
|
148
|
+
headers = {
|
|
149
|
+
"accept": "application/json",
|
|
150
|
+
"content-type": "application/json",
|
|
151
|
+
"x-api-key": self.api_key,
|
|
152
|
+
}
|
|
153
|
+
payload = {
|
|
154
|
+
"url": url,
|
|
155
|
+
"numResults": num_results,
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
await log_info(ctx, f"Exa find_similar: {url}", config.debug_enabled)
|
|
159
|
+
|
|
160
|
+
start_time = time.time()
|
|
161
|
+
try:
|
|
162
|
+
data = await self._request_with_retry(endpoint, headers, payload, ctx)
|
|
163
|
+
elapsed_ms = round((time.time() - start_time) * 1000, 2)
|
|
164
|
+
|
|
165
|
+
results = [
|
|
166
|
+
_normalize_result(item, include_text=False, include_highlights=False)
|
|
167
|
+
for item in data.get("results", [])
|
|
168
|
+
]
|
|
169
|
+
|
|
170
|
+
output = {
|
|
171
|
+
"ok": True,
|
|
172
|
+
"url": url,
|
|
173
|
+
"results": results,
|
|
174
|
+
"total": len(results),
|
|
175
|
+
"elapsed_ms": elapsed_ms,
|
|
176
|
+
}
|
|
177
|
+
except Exception as e:
|
|
178
|
+
elapsed_ms = round((time.time() - start_time) * 1000, 2)
|
|
179
|
+
error = _error_payload(e)
|
|
180
|
+
output = {
|
|
181
|
+
"ok": False,
|
|
182
|
+
"url": url,
|
|
183
|
+
"error_type": error["error_type"],
|
|
184
|
+
"error": error["error"],
|
|
185
|
+
"elapsed_ms": elapsed_ms,
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
await log_info(ctx, "Exa find_similar finished!", config.debug_enabled)
|
|
189
|
+
return json.dumps(output, ensure_ascii=False, indent=2)
|
|
190
|
+
|
|
191
|
+
async def _request_with_retry(
|
|
192
|
+
self, endpoint: str, headers: dict, payload: dict, ctx=None
|
|
193
|
+
) -> dict[str, Any]:
|
|
194
|
+
timeout = httpx.Timeout(connect=6.0, read=self.timeout, write=10.0, pool=None)
|
|
195
|
+
|
|
196
|
+
async with httpx.AsyncClient(timeout=timeout) as client:
|
|
197
|
+
async for attempt in AsyncRetrying(
|
|
198
|
+
stop=stop_after_attempt(config.retry_max_attempts + 1),
|
|
199
|
+
wait=wait_random_exponential(multiplier=config.retry_multiplier, max=config.retry_max_wait),
|
|
200
|
+
retry=retry_if_exception(_is_retryable_exception),
|
|
201
|
+
reraise=True,
|
|
202
|
+
):
|
|
203
|
+
with attempt:
|
|
204
|
+
response = await client.post(endpoint, headers=headers, json=payload)
|
|
205
|
+
response.raise_for_status()
|
|
206
|
+
return response.json()
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import time
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
import httpx
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
CHALLENGE_MARKERS = (
|
|
9
|
+
"title: just a moment",
|
|
10
|
+
"checking if the site connection is secure",
|
|
11
|
+
"attention required! | cloudflare",
|
|
12
|
+
"enable javascript and cookies to continue",
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _elapsed_ms(start: float) -> float:
|
|
17
|
+
return round((time.time() - start) * 1000, 2)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _error_payload(exc: Exception) -> dict[str, str]:
|
|
21
|
+
if isinstance(exc, httpx.HTTPStatusError):
|
|
22
|
+
status_code = exc.response.status_code
|
|
23
|
+
if status_code in {401, 403}:
|
|
24
|
+
error_type = "auth_error"
|
|
25
|
+
elif status_code == 422:
|
|
26
|
+
error_type = "parameter_error"
|
|
27
|
+
elif status_code == 429:
|
|
28
|
+
error_type = "rate_limited"
|
|
29
|
+
else:
|
|
30
|
+
error_type = "network_error"
|
|
31
|
+
body = (exc.response.text or exc.response.reason_phrase or "")[:300]
|
|
32
|
+
return {"error_type": error_type, "error": f"HTTP {status_code}: {body}"}
|
|
33
|
+
if isinstance(exc, httpx.TimeoutException):
|
|
34
|
+
return {"error_type": "timeout", "error": "request timed out"}
|
|
35
|
+
if isinstance(exc, httpx.RequestError):
|
|
36
|
+
return {"error_type": "network_error", "error": str(exc)}
|
|
37
|
+
return {"error_type": "runtime_error", "error": str(exc)}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _mask_secret(text: str, secret: str) -> str:
|
|
41
|
+
return text.replace(secret, "***") if secret else text
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _quality_error(content: str) -> str:
|
|
45
|
+
lower = content.strip().lower()
|
|
46
|
+
if not lower:
|
|
47
|
+
return "empty response"
|
|
48
|
+
for marker in CHALLENGE_MARKERS:
|
|
49
|
+
if marker in lower:
|
|
50
|
+
return f"low-quality challenge page detected: {marker}"
|
|
51
|
+
return ""
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class JinaReaderProvider:
|
|
55
|
+
def __init__(
|
|
56
|
+
self,
|
|
57
|
+
reader_api_url: str,
|
|
58
|
+
api_key: str | None = None,
|
|
59
|
+
respond_with: str = "",
|
|
60
|
+
timeout: float = 30.0,
|
|
61
|
+
):
|
|
62
|
+
self.reader_api_url = reader_api_url.rstrip("/")
|
|
63
|
+
self.api_key = api_key or ""
|
|
64
|
+
self.respond_with = respond_with.strip()
|
|
65
|
+
self.timeout = timeout
|
|
66
|
+
|
|
67
|
+
async def fetch(self, url: str) -> str:
|
|
68
|
+
start = time.time()
|
|
69
|
+
if self.respond_with and not self.api_key:
|
|
70
|
+
return json.dumps(
|
|
71
|
+
{
|
|
72
|
+
"ok": False,
|
|
73
|
+
"provider": "jina",
|
|
74
|
+
"url": url,
|
|
75
|
+
"error_type": "config_error",
|
|
76
|
+
"error": "JINA_RESPOND_WITH requires JINA_API_KEY.",
|
|
77
|
+
"elapsed_ms": _elapsed_ms(start),
|
|
78
|
+
},
|
|
79
|
+
ensure_ascii=False,
|
|
80
|
+
indent=2,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
headers = {"X-Return-Format": "markdown", "Accept": "text/plain, text/markdown, */*"}
|
|
84
|
+
if self.respond_with:
|
|
85
|
+
headers["X-Respond-With"] = self.respond_with
|
|
86
|
+
if self.api_key:
|
|
87
|
+
headers["Authorization"] = f"Bearer {self.api_key}"
|
|
88
|
+
|
|
89
|
+
endpoint = f"{self.reader_api_url}/{url}"
|
|
90
|
+
try:
|
|
91
|
+
timeout = httpx.Timeout(connect=6.0, read=self.timeout, write=10.0, pool=None)
|
|
92
|
+
async with httpx.AsyncClient(timeout=timeout, follow_redirects=True) as client:
|
|
93
|
+
response = await client.get(endpoint, headers=headers)
|
|
94
|
+
response.raise_for_status()
|
|
95
|
+
content = response.text.strip()
|
|
96
|
+
quality_error = _quality_error(content)
|
|
97
|
+
if quality_error:
|
|
98
|
+
return json.dumps(
|
|
99
|
+
{
|
|
100
|
+
"ok": False,
|
|
101
|
+
"provider": "jina",
|
|
102
|
+
"url": url,
|
|
103
|
+
"error_type": "quality_error",
|
|
104
|
+
"error": quality_error,
|
|
105
|
+
"content": content,
|
|
106
|
+
"elapsed_ms": _elapsed_ms(start),
|
|
107
|
+
},
|
|
108
|
+
ensure_ascii=False,
|
|
109
|
+
indent=2,
|
|
110
|
+
)
|
|
111
|
+
return json.dumps(
|
|
112
|
+
{
|
|
113
|
+
"ok": True,
|
|
114
|
+
"provider": "jina",
|
|
115
|
+
"url": url,
|
|
116
|
+
"content": content,
|
|
117
|
+
"elapsed_ms": _elapsed_ms(start),
|
|
118
|
+
},
|
|
119
|
+
ensure_ascii=False,
|
|
120
|
+
indent=2,
|
|
121
|
+
)
|
|
122
|
+
except Exception as e:
|
|
123
|
+
error = _error_payload(e)
|
|
124
|
+
message = _mask_secret(error["error"], self.api_key)
|
|
125
|
+
return json.dumps(
|
|
126
|
+
{
|
|
127
|
+
"ok": False,
|
|
128
|
+
"provider": "jina",
|
|
129
|
+
"url": url,
|
|
130
|
+
"error_type": error["error_type"],
|
|
131
|
+
"error": message,
|
|
132
|
+
"elapsed_ms": _elapsed_ms(start),
|
|
133
|
+
},
|
|
134
|
+
ensure_ascii=False,
|
|
135
|
+
indent=2,
|
|
136
|
+
)
|