aiwcli 0.15.7 → 0.17.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/README.md +106 -1125
- package/bin/run.js +0 -4
- package/dist/capabilities/installation/control-plane/clear-command.d.ts +2 -0
- package/dist/capabilities/installation/control-plane/clear-command.js +32 -3
- package/dist/capabilities/installation/control-plane/init-command.js +2 -2
- package/dist/capabilities/launch/contracts.d.ts +39 -4
- package/dist/capabilities/launch/control-plane/execute-launch.js +158 -119
- package/dist/capabilities/launch/runtime-core/launch-decisions.d.ts +82 -0
- package/dist/capabilities/launch/runtime-core/launch-decisions.js +202 -0
- package/dist/commands/branch.d.ts +1 -1
- package/dist/commands/branch.js +1 -1
- package/dist/commands/launch.d.ts +0 -5
- package/dist/commands/launch.js +2 -37
- package/dist/lib/config.js +1 -2
- package/dist/lib/context/context-store.js +28 -2
- package/dist/lib/core-installer.d.ts +1 -1
- package/dist/lib/core-installer.js +6 -27
- package/dist/lib/debug.d.ts +0 -10
- package/dist/lib/debug.js +0 -10
- package/dist/lib/env-sanitizer.d.ts +25 -0
- package/dist/lib/env-sanitizer.js +46 -0
- package/dist/lib/errors.d.ts +0 -13
- package/dist/lib/errors.js +0 -15
- package/dist/lib/git-exclude-manager.js +1 -1
- package/dist/lib/hooks/context-monitor-logic.d.ts +6 -0
- package/dist/lib/hooks/context-monitor-logic.js +25 -0
- package/dist/lib/hooks/hook-utils.js +11 -0
- package/dist/lib/hooks/prompt-binding-logic.d.ts +7 -0
- package/dist/lib/hooks/prompt-binding-logic.js +50 -0
- package/dist/lib/hooks/session-end-logic.js +2 -14
- package/dist/lib/install-state.js +6 -13
- package/dist/lib/json-io.d.ts +12 -0
- package/dist/lib/json-io.js +30 -0
- package/dist/lib/multiplexer.d.ts +43 -35
- package/dist/lib/multiplexer.js +21 -2
- package/dist/lib/multiplexers/psmux.d.ts +14 -34
- package/dist/lib/multiplexers/psmux.js +70 -130
- package/dist/lib/multiplexers/tmux.d.ts +11 -19
- package/dist/lib/multiplexers/tmux.js +79 -120
- package/dist/lib/multiplexers/wezterm.d.ts +38 -0
- package/dist/lib/multiplexers/wezterm.js +225 -0
- package/dist/lib/mux-utils.d.ts +4 -3
- package/dist/lib/mux-utils.js +7 -13
- package/dist/lib/prompt-file-manager.d.ts +23 -0
- package/dist/lib/prompt-file-manager.js +41 -0
- package/dist/lib/runtime/agent-launcher.d.ts +67 -0
- package/dist/lib/runtime/agent-launcher.js +262 -0
- package/dist/lib/runtime/aiw-cli.d.ts +2 -0
- package/dist/lib/runtime/aiw-cli.js +3 -1
- package/dist/lib/runtime/cli-args.d.ts +5 -2
- package/dist/lib/runtime/cli-args.js +18 -3
- package/dist/lib/runtime/inference.js +3 -14
- package/dist/lib/runtime/models.d.ts +6 -0
- package/dist/lib/runtime/models.js +6 -0
- package/dist/lib/runtime/state-io.d.ts +2 -1
- package/dist/lib/runtime/state-io.js +9 -4
- package/dist/lib/runtime/utils.d.ts +8 -0
- package/dist/lib/runtime/utils.js +31 -1
- package/dist/lib/schemas.d.ts +250 -0
- package/dist/lib/schemas.js +216 -0
- package/dist/lib/sentinel-manager.d.ts +32 -0
- package/dist/lib/sentinel-manager.js +62 -0
- package/dist/lib/sentinel-wrapper.d.ts +1 -0
- package/dist/lib/sentinel-wrapper.js +12 -3
- package/dist/lib/settings-hierarchy.js +3 -20
- package/dist/lib/shell-adapters/bash-adapter.d.ts +18 -0
- package/dist/lib/shell-adapters/bash-adapter.js +69 -0
- package/dist/lib/shell-adapters/index.d.ts +5 -0
- package/dist/lib/shell-adapters/index.js +7 -0
- package/dist/lib/shell-adapters/powershell-adapter.d.ts +18 -0
- package/dist/lib/shell-adapters/powershell-adapter.js +62 -0
- package/dist/lib/shell-adapters/shell-adapter.d.ts +45 -0
- package/dist/lib/shell-adapters/shell-adapter.js +5 -0
- package/dist/lib/spawn-errors.d.ts +3 -0
- package/dist/lib/spawn-errors.js +15 -1
- package/dist/lib/spinner.d.ts +0 -5
- package/dist/lib/spinner.js +0 -16
- package/dist/lib/template-installer.d.ts +10 -0
- package/dist/lib/template-installer.js +4 -4
- package/dist/lib/terminal-strategy.d.ts +1 -0
- package/dist/lib/terminal-strategy.js +12 -6
- package/dist/lib/terminal.d.ts +7 -5
- package/dist/lib/terminal.js +42 -19
- package/dist/lib/tmux-primitives.d.ts +0 -2
- package/dist/lib/tmux-primitives.js +0 -4
- package/dist/lib/tmux-session.js +2 -1
- package/dist/lib/windsurf-hooks-hierarchy.js +6 -23
- package/dist/platform/launch.d.ts +2 -1
- package/dist/platform/launch.js +1 -0
- package/dist/templates/CLAUDE.md +0 -1
- package/dist/templates/cc-native/.claude/settings.json +0 -10
- package/dist/templates/cc-native/TEMPLATE-SCHEMA.md +11 -4
- package/dist/templates/cc-native/_cc-native/cc-native.config.json +3 -7
- package/dist/templates/cc-native/_cc-native/hooks/CLAUDE.md +26 -47
- package/dist/templates/cc-native/_cc-native/hooks/cc-native-plan-review.ts +7 -9
- package/dist/templates/cc-native/_cc-native/hooks/enhance_plan_post_write.ts +2 -3
- package/dist/templates/cc-native/_cc-native/hooks/mark_questions_asked.ts +2 -2
- package/dist/templates/cc-native/_cc-native/hooks/plan_questions_early.ts +0 -25
- package/dist/templates/cc-native/_cc-native/hooks/validate_task_prompt.ts +4 -4
- package/dist/templates/cc-native/_cc-native/lib-ts/.mocharc.json +9 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/aggregate-agents.test.ts +118 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/artifacts.test.ts +234 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/cc-native-state.test.ts +170 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/cli-output-parser.test.ts +73 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/config.test.ts +64 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/constants.test.ts +40 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/debug.test.ts +42 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/exports.test.ts +58 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/helpers.ts +107 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/hooks/add-plan-context.hook.test.ts +97 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/hooks/plan-questions.hook.test.ts +81 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/hooks/plan-review.hook.test.ts +71 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/json-parser.test.ts +99 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/orchestrator-agent.test.ts +288 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/orchestrator.test.ts +48 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/reviewers.test.ts +32 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/state.test.ts +124 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/__tests__/verdict.test.ts +93 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/agent-selection.ts +163 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/aggregate-agents.ts +6 -14
- package/dist/templates/cc-native/_cc-native/{artifacts/lib → lib-ts/artifacts}/format.ts +597 -599
- package/dist/templates/cc-native/_cc-native/{artifacts/lib → lib-ts/artifacts}/index.ts +26 -26
- package/dist/templates/cc-native/_cc-native/{artifacts/lib → lib-ts/artifacts}/tracker.ts +106 -107
- package/dist/templates/cc-native/_cc-native/{artifacts/lib → lib-ts/artifacts}/write.ts +118 -119
- package/dist/templates/cc-native/_cc-native/lib-ts/artifacts.ts +21 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/cc-native-state.ts +16 -15
- package/dist/templates/cc-native/_cc-native/lib-ts/cli-output-parser.ts +132 -10
- package/dist/templates/cc-native/_cc-native/lib-ts/constants.ts +6 -6
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/corroboration.ts +119 -119
- package/dist/templates/cc-native/_cc-native/lib-ts/debug.ts +1 -2
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/graduation.ts +132 -132
- package/dist/templates/cc-native/_cc-native/lib-ts/index.ts +88 -86
- package/dist/templates/cc-native/_cc-native/lib-ts/json-parser.ts +5 -6
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/orchestrator.ts +70 -70
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/output-builder.ts +130 -121
- package/dist/templates/cc-native/_cc-native/lib-ts/package-lock.json +1679 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/package.json +24 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/plan-discovery.ts +4 -4
- package/dist/templates/cc-native/_cc-native/lib-ts/plan-enhancement.ts +1 -6
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/plan-questions.ts +101 -101
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/review-pipeline.ts +511 -543
- package/dist/templates/cc-native/_cc-native/lib-ts/reviewers/__tests__/agent-providers.test.ts +262 -0
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/agent.ts +71 -85
- package/dist/templates/{core/lib-ts/agent-exec → cc-native/_cc-native/lib-ts/reviewers/base}/base-agent.ts +138 -152
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/index.ts +12 -12
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/providers/claude-agent.ts +66 -57
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/providers/codex-agent.ts +185 -200
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/providers/gemini-agent.ts +39 -40
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/providers/orchestrator-claude-agent.ts +196 -224
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/schemas.ts +201 -201
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/reviewers/types.ts +21 -23
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/__tests__/hyde.test.ts +365 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/__tests__/ollama-client.test.ts +223 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/embedding-indexer.ts +12 -16
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/hyde.ts +3 -2
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/index.ts +31 -31
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/logger.ts +6 -7
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/ollama-client.ts +7 -9
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/retrieval-pipeline.ts +14 -17
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-indexer.ts +37 -41
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-loader.ts +33 -43
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-searcher.ts +20 -20
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/types.ts +8 -9
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/vector-store.ts +3 -4
- package/dist/templates/cc-native/_cc-native/lib-ts/settings.ts +50 -126
- package/dist/templates/cc-native/_cc-native/lib-ts/state.ts +19 -21
- package/dist/templates/cc-native/_cc-native/lib-ts/types.ts +13 -88
- package/dist/templates/cc-native/_cc-native/{plan-review/lib → lib-ts}/verdict.ts +72 -72
- package/dist/templates/cc-native/_cc-native/plan-review/CLAUDE.md +35 -0
- package/dist/templates/cc-native/_cc-native/plan-review/lib/agent-selection.ts +1 -1
- package/dist/templates/cc-native/_cc-native/scripts/council_debate.ts +242 -0
- package/dist/templates/cc-native/_cc-native/scripts/council_debate_simple.ts +294 -0
- package/dist/templates/cc-native/_cc-native/{plan-review/workflows → workflows}/specdev.md +9 -9
- package/dist/templates/core/.claude/skills/codex/SKILL.md +25 -0
- package/dist/templates/core/.claude/skills/devin/SKILL.md +25 -0
- package/dist/templates/core/.claude/skills/handoff/SKILL.md +11 -0
- package/dist/templates/core/.claude/skills/handoff-resume/SKILL.md +11 -0
- package/dist/templates/core/.claude/skills/meta-plan/SKILL.md +13 -0
- package/dist/templates/core/.codex/skills/codex/SKILL.md +13 -0
- package/dist/templates/core/.codex/skills/devin/SKILL.md +19 -0
- package/dist/templates/core/.codex/skills/handoff/SKILL.md +11 -0
- package/dist/templates/core/.codex/skills/handoff-resume/SKILL.md +11 -0
- package/dist/templates/core/.codex/{workflows/meta-plan.md → skills/meta-plan/SKILL.md} +6 -0
- package/dist/templates/core/{.cognition → .devin}/AGENTS.md +2 -2
- package/dist/templates/core/.devin/skills/codex/SKILL.md +19 -0
- package/dist/templates/core/.devin/skills/devin/SKILL.md +13 -0
- package/dist/templates/core/.devin/skills/handoff/SKILL.md +11 -0
- package/dist/templates/core/.devin/skills/handoff-resume/SKILL.md +11 -0
- package/dist/templates/core/.devin/skills/meta-plan/SKILL.md +13 -0
- package/dist/templates/core/.windsurf/workflows/handoff-resume.md +9 -0
- package/dist/templates/core/hooks-ts/archive_plan.ts +1 -21
- package/dist/templates/core/hooks-ts/file-suggestion.ts +1 -19
- package/dist/templates/core/hooks-ts/pre_compact.ts +5 -18
- package/dist/templates/core/lib-ts/context/context-store.ts +29 -2
- package/dist/templates/core/lib-ts/hooks/hook-utils.ts +11 -0
- package/dist/templates/core/lib-ts/hooks/session-end-logic.ts +2 -13
- package/dist/templates/core/lib-ts/runtime/agent-launcher.ts +74 -0
- package/dist/templates/core/lib-ts/runtime/aiw-cli.ts +4 -2
- package/dist/templates/core/lib-ts/runtime/cli-args.ts +18 -4
- package/dist/templates/core/lib-ts/runtime/inference.ts +3 -15
- package/dist/templates/core/lib-ts/runtime/models.ts +7 -0
- package/dist/templates/core/lib-ts/runtime/state-io.ts +9 -4
- package/dist/templates/core/lib-ts/runtime/utils.ts +30 -1
- package/dist/templates/core/lib-ts/schemas.ts +233 -0
- package/dist/templates/core/scripts/resolve-run.ts +34 -2
- package/dist/templates/core/scripts/status_line.ts +1 -1
- package/dist/templates/core/skills/codex/CLAUDE.md +9 -4
- package/dist/templates/core/skills/codex/SKILL.md +6 -0
- package/dist/templates/core/skills/codex/lib/codex-watcher.ts +3 -10
- package/dist/templates/core/skills/codex/scripts/launch-codex.ts +26 -26
- package/dist/templates/core/skills/devin/CLAUDE.md +63 -6
- package/dist/templates/core/skills/devin/lib/devin-watcher.ts +116 -96
- package/dist/templates/core/skills/devin/scripts/launch-devin.ts +22 -21
- package/dist/templates/core/skills/handoff-system/CLAUDE.md +1 -1
- package/oclif.manifest.json +4 -4
- package/package.json +4 -4
- package/dist/lib/base-command.d.ts +0 -1
- package/dist/lib/base-command.js +0 -1
- package/dist/lib/env-compat.d.ts +0 -18
- package/dist/lib/env-compat.js +0 -23
- package/dist/lib/launch-options.d.ts +0 -1
- package/dist/lib/launch-options.js +0 -1
- package/dist/lib/stdin.d.ts +0 -48
- package/dist/lib/stdin.js +0 -60
- package/dist/templates/cc-native/_cc-native/CLAUDE.md +0 -73
- package/dist/templates/cc-native/_cc-native/artifacts/CLAUDE.md +0 -64
- package/dist/templates/cc-native/_cc-native/lib-ts/CLAUDE.md +0 -70
- package/dist/templates/cc-native/_cc-native/plan-review/CODING-STANDARDS-CHECKLIST.md +0 -75
- package/dist/templates/cc-native/_cc-native/plan-review/agents/CLAUDE.md +0 -143
- package/dist/templates/cc-native/_cc-native/plan-review/agents/PLAN-ORCHESTRATOR.md +0 -213
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-questions/PLAN-QUESTIONER.md +0 -70
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-EVOLUTION.md +0 -62
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-PATTERNS.md +0 -61
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-STRUCTURE.md +0 -62
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ASSUMPTION-TRACER.md +0 -56
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/CLARITY-AUDITOR.md +0 -53
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-FEASIBILITY.md +0 -66
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-GAPS.md +0 -70
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-ORDERING.md +0 -62
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/CONSTRAINT-VALIDATOR.md +0 -72
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DESIGN-ADR-VALIDATOR.md +0 -61
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DESIGN-SCALE-MATCHER.md +0 -64
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DEVILS-ADVOCATE.md +0 -56
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DOCUMENTATION-PHILOSOPHY.md +0 -86
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/HANDOFF-READINESS.md +0 -59
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/HIDDEN-COMPLEXITY.md +0 -58
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/INCREMENTAL-DELIVERY.md +0 -66
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-DEPENDENCY.md +0 -62
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-FMEA.md +0 -66
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-PREMORTEM.md +0 -71
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-REVERSIBILITY.md +0 -74
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SCOPE-BOUNDARY.md +0 -77
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SIMPLICITY-GUARDIAN.md +0 -62
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SKEPTIC.md +0 -68
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-BEHAVIOR-AUDITOR.md +0 -61
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-CHARACTERIZATION.md +0 -71
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-FIRST-VALIDATOR.md +0 -61
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-PYRAMID-ANALYZER.md +0 -61
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TRADEOFF-COSTS.md +0 -67
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TRADEOFF-STAKEHOLDERS.md +0 -65
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/VERIFY-COVERAGE.md +0 -74
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/VERIFY-STRENGTH.md +0 -69
- package/dist/templates/cc-native/_cc-native/plan-review/lib/reviewers/base/base-agent.ts +0 -7
- package/dist/templates/core/.codex/workflows/codex.md +0 -17
- package/dist/templates/core/.codex/workflows/handoff.md +0 -5
- package/dist/templates/core/lib-ts/agent-exec/backends/headless.ts +0 -34
- package/dist/templates/core/lib-ts/agent-exec/backends/index.ts +0 -6
- package/dist/templates/core/lib-ts/agent-exec/backends/tmux.ts +0 -148
- package/dist/templates/core/lib-ts/agent-exec/execution-backend.ts +0 -50
- package/dist/templates/core/lib-ts/agent-exec/index.ts +0 -6
- package/dist/templates/core/lib-ts/agent-exec/structured-output.ts +0 -165
- /package/dist/templates/core/{.cognition → .devin}/config.json +0 -0
|
@@ -4,51 +4,51 @@
|
|
|
4
4
|
* Public API re-exports for programmatic use from hooks/agents.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
export {
|
|
7
|
+
export {
|
|
8
|
+
CURRENT_SCHEMA_VERSION,
|
|
9
|
+
CLAUDE_PROJECTS_DIR,
|
|
10
|
+
RLM_INDEX_DIR,
|
|
11
|
+
RLM_VECTOR_DB_PATH,
|
|
12
|
+
OLLAMA_BASE_URL,
|
|
13
|
+
OLLAMA_EMBED_MODEL,
|
|
14
|
+
EMBED_DIMENSIONS,
|
|
15
|
+
VECTOR_TOP_K,
|
|
16
|
+
MAX_LOADER_CHARS,
|
|
17
|
+
MAX_PARALLEL_SUMMARIZERS,
|
|
18
|
+
TOP_N_HEAP,
|
|
19
|
+
WEIGHT,
|
|
20
|
+
type SessionIndex,
|
|
21
|
+
type SearchResult,
|
|
22
|
+
type LoadedSegment,
|
|
23
|
+
type IndexSegment,
|
|
24
|
+
type VectorSearchResult,
|
|
25
|
+
type ChunkSummary,
|
|
26
|
+
type RankedSession,
|
|
27
|
+
type RetrievalResult,
|
|
28
|
+
} from "./types.js";
|
|
8
29
|
|
|
9
30
|
export {
|
|
10
31
|
discoverSessions,
|
|
11
32
|
indexSession,
|
|
33
|
+
writeIndex,
|
|
12
34
|
needsIndexing,
|
|
13
35
|
runBatch,
|
|
14
|
-
writeIndex,
|
|
15
36
|
} from "./transcript-indexer.js";
|
|
16
37
|
|
|
17
|
-
export {
|
|
38
|
+
export { search, scoreIndex, tokenize, type SearchOptions } from "./transcript-searcher.js";
|
|
18
39
|
|
|
19
|
-
export {
|
|
40
|
+
export { loadTranscript } from "./transcript-loader.js";
|
|
20
41
|
|
|
21
|
-
export {
|
|
22
|
-
type ChunkSummary,
|
|
23
|
-
CLAUDE_PROJECTS_DIR,
|
|
24
|
-
CURRENT_SCHEMA_VERSION,
|
|
25
|
-
EMBED_DIMENSIONS,
|
|
26
|
-
type IndexSegment,
|
|
27
|
-
type LoadedSegment,
|
|
28
|
-
MAX_LOADER_CHARS,
|
|
29
|
-
MAX_PARALLEL_SUMMARIZERS,
|
|
30
|
-
OLLAMA_BASE_URL,
|
|
31
|
-
OLLAMA_EMBED_MODEL,
|
|
32
|
-
type RankedSession,
|
|
33
|
-
type RetrievalResult,
|
|
34
|
-
RLM_INDEX_DIR,
|
|
35
|
-
RLM_VECTOR_DB_PATH,
|
|
36
|
-
type SearchResult,
|
|
37
|
-
type SessionIndex,
|
|
38
|
-
TOP_N_HEAP,
|
|
39
|
-
VECTOR_TOP_K,
|
|
40
|
-
type VectorSearchResult,
|
|
41
|
-
WEIGHT,
|
|
42
|
-
} from "./types.js";
|
|
42
|
+
export { checkOllamaHealth, embed, embedOne, type OllamaConfig } from "./ollama-client.js";
|
|
43
43
|
|
|
44
44
|
export {
|
|
45
|
-
|
|
46
|
-
deleteSessionChunks,
|
|
47
|
-
getStats,
|
|
45
|
+
openVectorDb,
|
|
48
46
|
insertChunks,
|
|
49
|
-
isSessionEmbedded,
|
|
50
47
|
markSessionEmbedded,
|
|
51
|
-
|
|
48
|
+
isSessionEmbedded,
|
|
49
|
+
deleteSessionChunks,
|
|
52
50
|
searchKnn,
|
|
51
|
+
getStats,
|
|
52
|
+
type ChunkRow,
|
|
53
53
|
type VectorStats,
|
|
54
54
|
} from "./vector-store.js";
|
|
@@ -25,18 +25,16 @@ try {
|
|
|
25
25
|
logDebug = mod.logDebug;
|
|
26
26
|
} catch {
|
|
27
27
|
// Fallback: minimal stderr+file logger for standalone CLI execution
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const fallback = (level: string) => {
|
|
29
|
+
return (hookName: string, message: string, opts?: Record<string, unknown>) => {
|
|
30
30
|
const shouldStderr = opts?.stderr === true || level === "error";
|
|
31
31
|
if (shouldStderr) {
|
|
32
32
|
process.stderr.write(`[${hookName}] ${message}\n`);
|
|
33
33
|
}
|
|
34
34
|
// Also try JSONL file logging
|
|
35
35
|
try {
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports, no-undef -- dynamic require in fallback path
|
|
39
|
-
const path = require("node:path");
|
|
36
|
+
const fs = require("fs");
|
|
37
|
+
const path = require("path");
|
|
40
38
|
const logDir = path.join(process.cwd(), "_output");
|
|
41
39
|
fs.mkdirSync(logDir, { recursive: true });
|
|
42
40
|
const entry = JSON.stringify({
|
|
@@ -50,10 +48,11 @@ try {
|
|
|
50
48
|
// Never crash on logging failure
|
|
51
49
|
}
|
|
52
50
|
};
|
|
51
|
+
};
|
|
53
52
|
logInfo = fallback("info");
|
|
54
53
|
logWarn = fallback("warn");
|
|
55
54
|
logError = fallback("error");
|
|
56
55
|
logDebug = fallback("debug");
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
export {
|
|
58
|
+
export { logInfo, logWarn, logError, logDebug };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable n/no-unsupported-features/node-builtins -- Bun runtime provides fetch */
|
|
2
1
|
/**
|
|
3
2
|
* Ollama HTTP client for local embeddings.
|
|
4
3
|
*
|
|
@@ -7,14 +6,13 @@
|
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
8
|
import { z } from "zod";
|
|
10
|
-
|
|
11
|
-
import { logDebug } from "./logger.js";
|
|
12
9
|
import {
|
|
13
10
|
OLLAMA_BASE_URL,
|
|
14
11
|
OLLAMA_EMBED_MODEL,
|
|
15
12
|
EMBED_DIMENSIONS,
|
|
16
13
|
HYDE_OLLAMA_MODEL,
|
|
17
14
|
} from "./types.js";
|
|
15
|
+
import { logDebug, logError } from "./logger.js";
|
|
18
16
|
|
|
19
17
|
const HOOK_NAME = "rlm_ollama";
|
|
20
18
|
const BATCH_SIZE = 32;
|
|
@@ -54,7 +52,7 @@ export async function checkOllamaHealth(
|
|
|
54
52
|
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
55
53
|
try {
|
|
56
54
|
const resp = await fetch(`${cfg.baseUrl}/api/tags`, {
|
|
57
|
-
signal: AbortSignal.timeout(
|
|
55
|
+
signal: AbortSignal.timeout(5_000),
|
|
58
56
|
});
|
|
59
57
|
if (!resp.ok) {
|
|
60
58
|
return { ok: false, error: `Ollama responded with ${resp.status}` };
|
|
@@ -76,8 +74,8 @@ export async function checkOllamaHealth(
|
|
|
76
74
|
};
|
|
77
75
|
}
|
|
78
76
|
return { ok: true };
|
|
79
|
-
} catch (
|
|
80
|
-
const msg =
|
|
77
|
+
} catch (e: unknown) {
|
|
78
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
81
79
|
return {
|
|
82
80
|
ok: false,
|
|
83
81
|
error: `Cannot reach Ollama at ${cfg.baseUrl}: ${msg}. Is Ollama running?`,
|
|
@@ -119,7 +117,7 @@ export async function embed(
|
|
|
119
117
|
throw new Error(`Invalid Ollama embed response: ${parseResult.error.message}`);
|
|
120
118
|
}
|
|
121
119
|
|
|
122
|
-
const
|
|
120
|
+
const data = parseResult.data;
|
|
123
121
|
if (data.embeddings.length !== batch.length) {
|
|
124
122
|
throw new Error(
|
|
125
123
|
`Expected ${batch.length} embeddings, got ${data.embeddings.length}`,
|
|
@@ -199,11 +197,11 @@ export async function generateText(
|
|
|
199
197
|
text: data.response || "",
|
|
200
198
|
latency_ms: Date.now() - startTime,
|
|
201
199
|
};
|
|
202
|
-
} catch (
|
|
200
|
+
} catch (e) {
|
|
203
201
|
return {
|
|
204
202
|
success: false,
|
|
205
203
|
text: "",
|
|
206
|
-
error: String(
|
|
204
|
+
error: String(e),
|
|
207
205
|
latency_ms: Date.now() - startTime,
|
|
208
206
|
};
|
|
209
207
|
}
|
|
@@ -13,11 +13,6 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { z } from "zod";
|
|
16
|
-
|
|
17
|
-
import { hydeQueryEmbedding } from "./hyde.js";
|
|
18
|
-
import { logInfo, logWarn, logError } from "./logger.js";
|
|
19
|
-
import { checkOllamaHealth, embedOne } from "./ollama-client.js";
|
|
20
|
-
import { loadTranscript } from "./transcript-loader.js";
|
|
21
16
|
import {
|
|
22
17
|
VECTOR_TOP_K,
|
|
23
18
|
MAX_PARALLEL_SUMMARIZERS,
|
|
@@ -31,7 +26,11 @@ import {
|
|
|
31
26
|
type RankedSession,
|
|
32
27
|
type RetrievalResult,
|
|
33
28
|
} from "./types.js";
|
|
29
|
+
import { logInfo, logWarn, logError, logDebug } from "./logger.js";
|
|
30
|
+
import { checkOllamaHealth, embedOne } from "./ollama-client.js";
|
|
34
31
|
import { openVectorDb, searchKnn } from "./vector-store.js";
|
|
32
|
+
import { loadTranscript } from "./transcript-loader.js";
|
|
33
|
+
import { hydeQueryEmbedding } from "./hyde.js";
|
|
35
34
|
|
|
36
35
|
const HOOK_NAME = "rlm_retrieve";
|
|
37
36
|
|
|
@@ -79,12 +78,10 @@ if (!query) {
|
|
|
79
78
|
);
|
|
80
79
|
process.exitCode = 1;
|
|
81
80
|
} else {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
} catch (error) {
|
|
85
|
-
logError(HOOK_NAME, `Fatal: ${error}`, { stderr: true });
|
|
81
|
+
runPipeline(query, topK, projectFilter).catch((e) => {
|
|
82
|
+
logError(HOOK_NAME, `Fatal: ${e}`, { stderr: true });
|
|
86
83
|
process.exitCode = 1;
|
|
87
|
-
}
|
|
84
|
+
});
|
|
88
85
|
}
|
|
89
86
|
|
|
90
87
|
// ---------------------------------------------------------------------------
|
|
@@ -130,8 +127,8 @@ async function runPipeline(
|
|
|
130
127
|
});
|
|
131
128
|
hydeTiming = Date.now() - hydeStart;
|
|
132
129
|
logInfo(HOOK_NAME, `HyDE query embedding completed in ${hydeTiming}ms`);
|
|
133
|
-
} catch (
|
|
134
|
-
logWarn(HOOK_NAME, `HyDE failed: ${
|
|
130
|
+
} catch (e) {
|
|
131
|
+
logWarn(HOOK_NAME, `HyDE failed: ${e}, falling back to direct query embedding`);
|
|
135
132
|
queryEmbedding = await embedOne(query);
|
|
136
133
|
}
|
|
137
134
|
} else {
|
|
@@ -185,7 +182,7 @@ async function runPipeline(
|
|
|
185
182
|
}
|
|
186
183
|
}
|
|
187
184
|
}
|
|
188
|
-
const sessions =
|
|
185
|
+
const sessions = Array.from(sessionMap.values());
|
|
189
186
|
logInfo(
|
|
190
187
|
HOOK_NAME,
|
|
191
188
|
`Stage 2: ${results.length} chunks → ${sessions.length} sessions`,
|
|
@@ -257,10 +254,10 @@ async function summarizeSessions(
|
|
|
257
254
|
const promises = batch.map(async (session) => {
|
|
258
255
|
try {
|
|
259
256
|
return await summarizeOneSession(query, session);
|
|
260
|
-
} catch (
|
|
257
|
+
} catch (e) {
|
|
261
258
|
logWarn(
|
|
262
259
|
HOOK_NAME,
|
|
263
|
-
`Summarize failed for ${session.result.session_id}: ${
|
|
260
|
+
`Summarize failed for ${session.result.session_id}: ${e}`,
|
|
264
261
|
);
|
|
265
262
|
return null;
|
|
266
263
|
}
|
|
@@ -400,8 +397,8 @@ async function rankSessions(
|
|
|
400
397
|
key_findings: r.key_findings,
|
|
401
398
|
};
|
|
402
399
|
}).filter((r): r is RankedSession => r !== null);
|
|
403
|
-
} catch (
|
|
404
|
-
logWarn(HOOK_NAME, `Rank parse failed: ${
|
|
400
|
+
} catch (e) {
|
|
401
|
+
logWarn(HOOK_NAME, `Rank parse failed: ${e}, marking all as relevant`);
|
|
405
402
|
return summaries.map((s) => ({
|
|
406
403
|
session_id: s.session_id,
|
|
407
404
|
project: s.project,
|
|
@@ -12,18 +12,18 @@
|
|
|
12
12
|
* bun transcript-indexer.ts --batch --project=aiwcli # Index matching project only
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { join, basename } from "
|
|
18
|
-
import { createInterface } from "
|
|
19
|
-
|
|
20
|
-
import { logInfo, logWarn, logError } from "./logger.js";
|
|
15
|
+
import { readdir, stat, mkdir, readFile, writeFile } from "fs/promises";
|
|
16
|
+
import { createReadStream, existsSync, readFileSync } from "fs";
|
|
17
|
+
import { join, basename } from "path";
|
|
18
|
+
import { createInterface } from "readline";
|
|
21
19
|
import {
|
|
22
20
|
CURRENT_SCHEMA_VERSION,
|
|
23
21
|
CLAUDE_PROJECTS_DIR,
|
|
24
22
|
RLM_INDEX_DIR,
|
|
25
23
|
type SessionIndex,
|
|
24
|
+
type IndexSegment,
|
|
26
25
|
} from "./types.js";
|
|
26
|
+
import { logInfo, logWarn, logError, logDebug } from "./logger.js";
|
|
27
27
|
|
|
28
28
|
const HOOK_NAME = "rlm_indexer";
|
|
29
29
|
|
|
@@ -39,12 +39,10 @@ const projectArg = args.find((a) => a.startsWith("--project="));
|
|
|
39
39
|
const projectFilter = projectArg ? projectArg.split("=")[1] : null;
|
|
40
40
|
|
|
41
41
|
if (isBatch) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} catch (error) {
|
|
45
|
-
logError(HOOK_NAME, `Fatal: ${error}`, { stderr: true });
|
|
42
|
+
runBatch().catch((e) => {
|
|
43
|
+
logError(HOOK_NAME, `Fatal: ${e}`, { stderr: true });
|
|
46
44
|
process.exitCode = 1;
|
|
47
|
-
}
|
|
45
|
+
});
|
|
48
46
|
}
|
|
49
47
|
|
|
50
48
|
// ---------------------------------------------------------------------------
|
|
@@ -91,24 +89,22 @@ async function discoverSessions(): Promise<SessionFile[]> {
|
|
|
91
89
|
return sessions;
|
|
92
90
|
}
|
|
93
91
|
|
|
94
|
-
function needsIndexing(session: SessionFile,
|
|
92
|
+
function needsIndexing(session: SessionFile, sourceMtime: number): boolean {
|
|
95
93
|
const indexPath = join(RLM_INDEX_DIR, session.project, `${session.sessionId}.index.json`);
|
|
96
94
|
if (!existsSync(indexPath)) return true;
|
|
97
95
|
try {
|
|
98
96
|
// Fast path: Read only first 100 bytes to check schema_version
|
|
99
97
|
// If version matches, skip without checking mtime (schema bumps trigger full reindex anyway)
|
|
100
|
-
|
|
101
|
-
const nodeFs = require("node:fs");
|
|
102
|
-
const fd = nodeFs.openSync(indexPath, "r");
|
|
98
|
+
const fd = require("fs").openSync(indexPath, "r");
|
|
103
99
|
const buffer = Buffer.alloc(100);
|
|
104
|
-
const bytesRead =
|
|
105
|
-
|
|
100
|
+
const bytesRead = require("fs").readSync(fd, buffer, 0, 100, 0);
|
|
101
|
+
require("fs").closeSync(fd);
|
|
106
102
|
|
|
107
103
|
const partial = buffer.toString("utf-8", 0, bytesRead);
|
|
108
104
|
const versionMatch = partial.match(/"schema_version"\s*:\s*(\d+)/);
|
|
109
105
|
|
|
110
106
|
// If version matches, skip (no mtime check needed - schema version bump handles major changes)
|
|
111
|
-
if (versionMatch && parseInt(versionMatch[1]
|
|
107
|
+
if (versionMatch && parseInt(versionMatch[1]) === CURRENT_SCHEMA_VERSION) {
|
|
112
108
|
return false; // Skip - index is current
|
|
113
109
|
}
|
|
114
110
|
|
|
@@ -156,9 +152,9 @@ async function runBatch(): Promise<void> {
|
|
|
156
152
|
if (indexed % 10 === 0 || indexed === 1) {
|
|
157
153
|
logInfo(HOOK_NAME, `Indexing: ${indexed} indexed, ${skipped} skipped, ${errors} errors (of ${allSessions.length} total)`, { stderr: true });
|
|
158
154
|
}
|
|
159
|
-
} catch (
|
|
155
|
+
} catch (e) {
|
|
160
156
|
errors++;
|
|
161
|
-
logError(HOOK_NAME, `Error indexing ${session.sessionId}: ${
|
|
157
|
+
logError(HOOK_NAME, `Error indexing ${session.sessionId}: ${e}`);
|
|
162
158
|
}
|
|
163
159
|
}
|
|
164
160
|
|
|
@@ -238,7 +234,7 @@ async function indexSession(session: SessionFile, sourceMtime: number): Promise<
|
|
|
238
234
|
index.user_message_count++;
|
|
239
235
|
const msg = obj.message as Record<string, unknown> | undefined;
|
|
240
236
|
if (msg) {
|
|
241
|
-
const
|
|
237
|
+
const content = msg.content;
|
|
242
238
|
if (typeof content === "string") {
|
|
243
239
|
const snippet = content.slice(0, 200);
|
|
244
240
|
userSnippets.push(snippet);
|
|
@@ -248,7 +244,7 @@ async function indexSession(session: SessionFile, sourceMtime: number): Promise<
|
|
|
248
244
|
} else if (Array.isArray(content)) {
|
|
249
245
|
for (const block of content) {
|
|
250
246
|
if (typeof block === "object" && block !== null && "text" in block) {
|
|
251
|
-
const
|
|
247
|
+
const text = (block as Record<string, unknown>).text;
|
|
252
248
|
if (typeof text === "string") {
|
|
253
249
|
extractKeywords(text, keywordBag);
|
|
254
250
|
extractKeywords(text, segmentKeywordBag);
|
|
@@ -259,8 +255,8 @@ async function indexSession(session: SessionFile, sourceMtime: number): Promise<
|
|
|
259
255
|
// Extract cwd for context
|
|
260
256
|
const cwd = obj.cwd as string | undefined;
|
|
261
257
|
if (cwd) {
|
|
262
|
-
const parts = cwd.
|
|
263
|
-
const last = parts.
|
|
258
|
+
const parts = cwd.replace(/\\/g, "/").split("/");
|
|
259
|
+
const last = parts[parts.length - 1];
|
|
264
260
|
if (last) addKeyword(keywordBag, last);
|
|
265
261
|
}
|
|
266
262
|
// Git branch
|
|
@@ -273,7 +269,7 @@ async function indexSession(session: SessionFile, sourceMtime: number): Promise<
|
|
|
273
269
|
index.assistant_message_count++;
|
|
274
270
|
const msg = obj.message as Record<string, unknown> | undefined;
|
|
275
271
|
if (msg) {
|
|
276
|
-
const
|
|
272
|
+
const content = msg.content;
|
|
277
273
|
if (Array.isArray(content)) {
|
|
278
274
|
for (const block of content) {
|
|
279
275
|
if (typeof block !== "object" || block === null) continue;
|
|
@@ -344,19 +340,19 @@ async function indexSession(session: SessionFile, sourceMtime: number): Promise<
|
|
|
344
340
|
// ---------------------------------------------------------------------------
|
|
345
341
|
|
|
346
342
|
const STOP_WORDS = new Set([
|
|
347
|
-
"
|
|
348
|
-
"
|
|
349
|
-
"
|
|
350
|
-
"
|
|
351
|
-
"
|
|
352
|
-
"
|
|
353
|
-
"
|
|
354
|
-
"
|
|
355
|
-
"
|
|
356
|
-
"
|
|
357
|
-
"
|
|
358
|
-
"
|
|
359
|
-
"
|
|
343
|
+
"the", "a", "an", "is", "are", "was", "were", "be", "been", "being",
|
|
344
|
+
"have", "has", "had", "do", "does", "did", "will", "would", "shall",
|
|
345
|
+
"should", "may", "might", "must", "can", "could", "of", "in", "to",
|
|
346
|
+
"for", "with", "on", "at", "from", "by", "about", "as", "into",
|
|
347
|
+
"through", "during", "before", "after", "above", "below", "between",
|
|
348
|
+
"and", "but", "or", "nor", "not", "no", "so", "yet", "both", "either",
|
|
349
|
+
"neither", "each", "every", "all", "any", "few", "more", "most", "other",
|
|
350
|
+
"some", "such", "than", "too", "very", "just", "also", "now", "then",
|
|
351
|
+
"here", "there", "when", "where", "why", "how", "what", "which", "who",
|
|
352
|
+
"this", "that", "these", "those", "it", "its", "i", "me", "my", "we",
|
|
353
|
+
"our", "you", "your", "he", "she", "they", "them", "their", "if",
|
|
354
|
+
"true", "false", "null", "undefined", "function", "return", "const",
|
|
355
|
+
"let", "var", "import", "export", "default", "class", "new", "type",
|
|
360
356
|
]);
|
|
361
357
|
|
|
362
358
|
function extractKeywords(text: string, bag: Map<string, number>): void {
|
|
@@ -395,9 +391,9 @@ function extractToolMetadata(
|
|
|
395
391
|
// File paths from Read, Edit, Write, Glob
|
|
396
392
|
const filePath = input.file_path as string | undefined;
|
|
397
393
|
if (filePath) {
|
|
398
|
-
const normalized = filePath.
|
|
394
|
+
const normalized = filePath.replace(/\\/g, "/");
|
|
399
395
|
const parts = normalized.split("/");
|
|
400
|
-
const fileName = parts.
|
|
396
|
+
const fileName = parts[parts.length - 1];
|
|
401
397
|
if (fileName) {
|
|
402
398
|
files.add(fileName);
|
|
403
399
|
addKeyword(keywords, fileName.replace(/\.[^.]+$/, "")); // stem
|
|
@@ -447,4 +443,4 @@ async function writeIndex(project: string, sessionId: string, index: SessionInde
|
|
|
447
443
|
// Exports for programmatic use
|
|
448
444
|
// ---------------------------------------------------------------------------
|
|
449
445
|
|
|
450
|
-
export { discoverSessions, indexSession, needsIndexing, runBatch
|
|
446
|
+
export { discoverSessions, indexSession, writeIndex, needsIndexing, runBatch };
|
|
@@ -11,12 +11,11 @@
|
|
|
11
11
|
* bun transcript-loader.ts <jsonl-path> --lines=46-120
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { createReadStream } from "
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
import { logInfo, logError } from "./logger.js";
|
|
14
|
+
import { createReadStream } from "fs";
|
|
15
|
+
import { createInterface } from "readline";
|
|
16
|
+
import { basename } from "path";
|
|
19
17
|
import { MAX_LOADER_CHARS, type LoadedSegment } from "./types.js";
|
|
18
|
+
import { logInfo, logWarn, logError } from "./logger.js";
|
|
20
19
|
|
|
21
20
|
const HOOK_NAME = "rlm_loader";
|
|
22
21
|
|
|
@@ -36,16 +35,17 @@ if (linesArg) {
|
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
if (jsonlPath && !process.env.RLM_LIB_MODE) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
loadTranscript(jsonlPath, lineRange)
|
|
39
|
+
.then((seg) => {
|
|
40
|
+
process.stdout.write(seg.content);
|
|
41
|
+
if (seg.truncated) {
|
|
42
|
+
logInfo(HOOK_NAME, "Output truncated at 50K chars", { stderr: true });
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
.catch((e) => {
|
|
46
|
+
logError(HOOK_NAME, `Load failed: ${e}`, { stderr: true });
|
|
47
|
+
process.exitCode = 1;
|
|
48
|
+
});
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// ---------------------------------------------------------------------------
|
|
@@ -135,9 +135,9 @@ async function loadTranscript(
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
// Derive project from path
|
|
138
|
-
const pathParts = filePath.
|
|
138
|
+
const pathParts = filePath.replace(/\\/g, "/").split("/");
|
|
139
139
|
const projectsIdx = pathParts.indexOf("projects");
|
|
140
|
-
if (projectsIdx
|
|
140
|
+
if (projectsIdx >= 0 && projectsIdx + 1 < pathParts.length) {
|
|
141
141
|
project = pathParts[projectsIdx + 1];
|
|
142
142
|
}
|
|
143
143
|
|
|
@@ -155,7 +155,7 @@ async function loadTranscript(
|
|
|
155
155
|
// ---------------------------------------------------------------------------
|
|
156
156
|
|
|
157
157
|
function extractContent(msg: Record<string, unknown>): string | null {
|
|
158
|
-
const
|
|
158
|
+
const content = msg.content;
|
|
159
159
|
if (typeof content === "string") return content;
|
|
160
160
|
if (Array.isArray(content)) {
|
|
161
161
|
const texts: string[] = [];
|
|
@@ -187,7 +187,7 @@ function extractAssistantContent(msg: Record<string, unknown>): {
|
|
|
187
187
|
text: string;
|
|
188
188
|
toolUses: ToolUse[];
|
|
189
189
|
} {
|
|
190
|
-
const
|
|
190
|
+
const content = msg.content;
|
|
191
191
|
let text = "";
|
|
192
192
|
const toolUses: ToolUse[] = [];
|
|
193
193
|
|
|
@@ -219,36 +219,26 @@ function extractAssistantContent(msg: Record<string, unknown>): {
|
|
|
219
219
|
function summarizeToolInput(toolName: string, input?: Record<string, unknown>): string {
|
|
220
220
|
if (!input) return "";
|
|
221
221
|
switch (toolName) {
|
|
222
|
-
case "
|
|
223
|
-
return input.command ? `${(input.command as string).slice(0, 80)}` : "";
|
|
224
|
-
}
|
|
225
|
-
case "Edit": {
|
|
222
|
+
case "Read":
|
|
226
223
|
return input.file_path ? `${input.file_path}` : "";
|
|
227
|
-
|
|
228
|
-
|
|
224
|
+
case "Write":
|
|
225
|
+
return input.file_path ? `${input.file_path}` : "";
|
|
226
|
+
case "Edit":
|
|
227
|
+
return input.file_path ? `${input.file_path}` : "";
|
|
228
|
+
case "Bash":
|
|
229
|
+
return input.command ? `${(input.command as string).slice(0, 80)}` : "";
|
|
230
|
+
case "Glob":
|
|
229
231
|
return input.pattern ? `${input.pattern}` : "";
|
|
230
|
-
|
|
231
|
-
case "Grep": {
|
|
232
|
+
case "Grep":
|
|
232
233
|
return input.pattern ? `/${input.pattern}/` : "";
|
|
233
|
-
|
|
234
|
-
case "Read": {
|
|
235
|
-
return input.file_path ? `${input.file_path}` : "";
|
|
236
|
-
}
|
|
237
|
-
case "Task": {
|
|
234
|
+
case "Task":
|
|
238
235
|
return input.description ? `${input.description}` : "";
|
|
239
|
-
|
|
240
|
-
case "WebFetch": {
|
|
241
|
-
return input.url ? `${input.url}` : "";
|
|
242
|
-
}
|
|
243
|
-
case "WebSearch": {
|
|
236
|
+
case "WebSearch":
|
|
244
237
|
return input.query ? `"${input.query}"` : "";
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
default: {
|
|
238
|
+
case "WebFetch":
|
|
239
|
+
return input.url ? `${input.url}` : "";
|
|
240
|
+
default:
|
|
250
241
|
return Object.keys(input).slice(0, 3).join(", ");
|
|
251
|
-
}
|
|
252
242
|
}
|
|
253
243
|
}
|
|
254
244
|
|
|
@@ -11,11 +11,12 @@
|
|
|
11
11
|
* bun transcript-searcher.ts "plan review" --project=aiwcli
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { join } from "
|
|
14
|
+
import { readdir, readFile } from "fs/promises";
|
|
15
|
+
import { existsSync } from "fs";
|
|
16
|
+
import { join } from "path";
|
|
17
|
+
import { logInfo, logWarn, logError, logDebug } from "./logger.js";
|
|
17
18
|
|
|
18
|
-
|
|
19
|
+
const HOOK_NAME = "rlm_searcher";
|
|
19
20
|
import {
|
|
20
21
|
CURRENT_SCHEMA_VERSION,
|
|
21
22
|
CLAUDE_PROJECTS_DIR,
|
|
@@ -27,8 +28,6 @@ import {
|
|
|
27
28
|
type IndexSegment,
|
|
28
29
|
} from "./types.js";
|
|
29
30
|
|
|
30
|
-
const HOOK_NAME = "rlm_searcher";
|
|
31
|
-
|
|
32
31
|
// ---------------------------------------------------------------------------
|
|
33
32
|
// CLI entry
|
|
34
33
|
// ---------------------------------------------------------------------------
|
|
@@ -41,19 +40,20 @@ const projectArg = args.find((a) => a.startsWith("--project="));
|
|
|
41
40
|
const projectFilter = projectArg ? projectArg.split("=")[1] : null;
|
|
42
41
|
|
|
43
42
|
if (query && !process.env.RLM_LIB_MODE) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
search(query, { topN, projectFilter })
|
|
44
|
+
.then((results) => {
|
|
45
|
+
if (typeof results === "string") {
|
|
46
|
+
logWarn(HOOK_NAME, results, { stderr: true });
|
|
47
|
+
process.exitCode = 1;
|
|
48
|
+
} else {
|
|
49
|
+
logInfo(HOOK_NAME, `Search returned ${results.length} results`);
|
|
50
|
+
process.stdout.write(JSON.stringify(results, null, 2) + "\n");
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
.catch((e) => {
|
|
54
|
+
logError(HOOK_NAME, `Search failed: ${e}`, { stderr: true });
|
|
48
55
|
process.exitCode = 1;
|
|
49
|
-
}
|
|
50
|
-
logInfo(HOOK_NAME, `Search returned ${results.length} results`);
|
|
51
|
-
process.stdout.write(JSON.stringify(results, null, 2) + "\n");
|
|
52
|
-
}
|
|
53
|
-
} catch (error) {
|
|
54
|
-
logError(HOOK_NAME, `Search failed: ${error}`, { stderr: true });
|
|
55
|
-
process.exitCode = 1;
|
|
56
|
-
}
|
|
56
|
+
});
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// ---------------------------------------------------------------------------
|
|
@@ -251,7 +251,7 @@ function tokenize(query: string): string[] {
|
|
|
251
251
|
return query
|
|
252
252
|
.toLowerCase()
|
|
253
253
|
.split(/\s+/)
|
|
254
|
-
.map((t) => t.
|
|
254
|
+
.map((t) => t.replace(/[^a-z0-9_-]/g, ""))
|
|
255
255
|
.filter((t) => t.length >= 2);
|
|
256
256
|
}
|
|
257
257
|
|
|
@@ -271,4 +271,4 @@ function insertSorted(arr: SearchResult[], item: SearchResult, maxSize: number):
|
|
|
271
271
|
// Exports
|
|
272
272
|
// ---------------------------------------------------------------------------
|
|
273
273
|
|
|
274
|
-
export { scoreIndex,
|
|
274
|
+
export { search, scoreIndex, tokenize, type SearchOptions };
|