aiwcli 0.12.7 → 0.13.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/dist/commands/clean.d.ts +7 -0
- package/dist/commands/clean.js +17 -8
- package/dist/commands/clear.d.ts +85 -0
- package/dist/commands/clear.js +455 -347
- package/dist/commands/init/index.d.ts +15 -0
- package/dist/commands/init/index.js +79 -38
- package/dist/lib/gitignore-manager.js +12 -13
- package/dist/lib/settings-hierarchy.d.ts +13 -1
- package/dist/lib/settings-hierarchy.js +1 -1
- package/dist/lib/template-linter.d.ts +4 -0
- package/dist/lib/template-linter.js +1 -1
- package/dist/lib/tty-detection.d.ts +1 -0
- package/dist/lib/tty-detection.js +1 -0
- package/dist/templates/CLAUDE.md +27 -0
- package/dist/templates/_shared/.claude/settings.json +7 -7
- package/dist/templates/_shared/.claude/{commands/handoff.md → skills/handoff/SKILL.md} +4 -3
- package/dist/templates/_shared/.claude/{commands/handoff-resume.md → skills/handoff-resume/SKILL.md} +3 -2
- package/dist/templates/_shared/.claude/skills/meta-plan/SKILL.md +43 -0
- package/dist/templates/_shared/.codex/workflows/handoff.md +1 -1
- package/dist/templates/_shared/.codex/workflows/meta-plan.md +347 -0
- package/dist/templates/_shared/.windsurf/workflows/handoff.md +1 -1
- package/dist/templates/_shared/.windsurf/workflows/meta-plan.md +347 -0
- package/dist/templates/_shared/hooks-ts/lint_after_edit.ts +59 -0
- package/dist/templates/_shared/hooks-ts/session_end.ts +11 -10
- package/dist/templates/_shared/hooks-ts/session_start.ts +15 -12
- package/dist/templates/_shared/hooks-ts/user_prompt_submit.ts +12 -12
- package/dist/templates/_shared/lib-ts/CLAUDE.md +3 -3
- package/dist/templates/_shared/lib-ts/base/constants.ts +324 -306
- package/dist/templates/_shared/lib-ts/base/hook-utils.ts +26 -7
- package/dist/templates/_shared/lib-ts/base/inference.ts +19 -19
- package/dist/templates/_shared/lib-ts/base/lint-dispatch.ts +287 -0
- package/dist/templates/_shared/lib-ts/base/state-io.ts +4 -3
- package/dist/templates/_shared/lib-ts/base/subprocess-utils.ts +3 -3
- package/dist/templates/_shared/lib-ts/context/CLAUDE.md +134 -0
- package/dist/templates/_shared/lib-ts/context/context-formatter.ts +16 -15
- package/dist/templates/_shared/lib-ts/context/context-selector.ts +16 -16
- package/dist/templates/_shared/lib-ts/context/context-store.ts +15 -14
- package/dist/templates/_shared/lib-ts/context/plan-manager.ts +2 -2
- package/dist/templates/_shared/scripts/resolve-run.ts +61 -0
- package/dist/templates/_shared/scripts/resolve_context.ts +1 -1
- package/dist/templates/_shared/scripts/status_line.ts +100 -94
- package/dist/templates/_shared/{handoff-system → skills/handoff-system}/CLAUDE.md +433 -421
- package/dist/templates/_shared/{handoff-system → skills/handoff-system}/lib/document-generator.ts +5 -4
- package/dist/templates/_shared/{handoff-system → skills/handoff-system}/lib/handoff-reader.ts +2 -1
- package/dist/templates/_shared/{handoff-system → skills/handoff-system}/scripts/resume_handoff.ts +6 -6
- package/dist/templates/_shared/{handoff-system → skills/handoff-system}/scripts/save_handoff.ts +16 -17
- package/dist/templates/_shared/{handoff-system → skills/handoff-system}/workflows/handoff-resume.md +2 -2
- package/dist/templates/_shared/{handoff-system → skills/handoff-system}/workflows/handoff.md +3 -3
- package/dist/templates/_shared/skills/meta-plan/CLAUDE.md +44 -0
- package/dist/templates/_shared/skills/meta-plan/workflows/meta-plan.md +347 -0
- package/dist/templates/cc-native/.claude/commands/cc-native/specdev.md +1 -1
- package/dist/templates/cc-native/.claude/settings.json +86 -57
- package/dist/templates/cc-native/_cc-native/artifacts/CLAUDE.md +64 -0
- package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/format.ts +599 -597
- package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/index.ts +26 -26
- package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/tracker.ts +107 -106
- package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/write.ts +119 -118
- package/dist/templates/cc-native/_cc-native/hooks/CLAUDE.md +237 -247
- package/dist/templates/cc-native/_cc-native/hooks/cc-native-plan-review.ts +76 -74
- package/dist/templates/cc-native/_cc-native/hooks/validate_task_prompt.ts +76 -0
- package/dist/templates/cc-native/_cc-native/lib-ts/aggregate-agents.ts +163 -156
- package/dist/templates/cc-native/_cc-native/lib-ts/cc-native-state.ts +15 -16
- package/dist/templates/cc-native/_cc-native/lib-ts/index.ts +116 -116
- package/dist/templates/cc-native/_cc-native/lib-ts/plan-discovery.ts +3 -3
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/embedding-indexer.ts +16 -12
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/hyde.ts +2 -3
- 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 +7 -6
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/ollama-client.ts +9 -7
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/retrieval-pipeline.ts +17 -14
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-indexer.ts +41 -37
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-loader.ts +43 -33
- 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 +9 -8
- package/dist/templates/cc-native/_cc-native/lib-ts/rlm/vector-store.ts +4 -3
- package/dist/templates/cc-native/_cc-native/lib-ts/settings.ts +9 -10
- package/dist/templates/cc-native/_cc-native/lib-ts/state.ts +20 -19
- package/dist/templates/cc-native/_cc-native/lib-ts/types.ts +329 -329
- package/dist/templates/cc-native/_cc-native/plan-review/CLAUDE.md +149 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/CLAUDE.md +143 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/PLAN-ORCHESTRATOR.md +213 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-questions/PLAN-QUESTIONER.md +70 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-EVOLUTION.md +62 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-PATTERNS.md +61 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-STRUCTURE.md +62 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ASSUMPTION-TRACER.md +56 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/CLARITY-AUDITOR.md +53 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-FEASIBILITY.md +66 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-GAPS.md +70 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-ORDERING.md +62 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/CONSTRAINT-VALIDATOR.md +72 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DESIGN-ADR-VALIDATOR.md +61 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DESIGN-SCALE-MATCHER.md +64 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DEVILS-ADVOCATE.md +56 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DOCUMENTATION-PHILOSOPHY.md +86 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/HANDOFF-READINESS.md +59 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/HIDDEN-COMPLEXITY.md +58 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/INCREMENTAL-DELIVERY.md +66 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-DEPENDENCY.md +62 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-FMEA.md +66 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-PREMORTEM.md +71 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-REVERSIBILITY.md +74 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SCOPE-BOUNDARY.md +77 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SIMPLICITY-GUARDIAN.md +62 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SKEPTIC.md +68 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-BEHAVIOR-AUDITOR.md +61 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-CHARACTERIZATION.md +71 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-FIRST-VALIDATOR.md +61 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-PYRAMID-ANALYZER.md +61 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TRADEOFF-COSTS.md +67 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TRADEOFF-STAKEHOLDERS.md +65 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/VERIFY-COVERAGE.md +74 -0
- package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/VERIFY-STRENGTH.md +69 -0
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/agent-selection.ts +162 -163
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/corroboration.ts +119 -119
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/graduation.ts +132 -132
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/orchestrator.ts +70 -70
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/output-builder.ts +121 -130
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/plan-questions.ts +101 -102
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/review-pipeline.ts +507 -511
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/agent.ts +73 -74
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/base/base-agent.ts +217 -217
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/index.ts +12 -12
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/claude-agent.ts +66 -66
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/codex-agent.ts +185 -185
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/gemini-agent.ts +39 -39
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/orchestrator-claude-agent.ts +196 -196
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/schemas.ts +201 -201
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/types.ts +23 -23
- package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/verdict.ts +72 -72
- package/dist/templates/cc-native/_cc-native/{workflows → plan-review/workflows}/specdev.md +9 -9
- package/oclif.manifest.json +1 -1
- package/package.json +6 -5
- package/dist/templates/cc-native/_cc-native/lib-ts/artifacts.ts +0 -21
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CC-Native plan review library — package entry point.
|
|
3
|
-
* Re-exports the public API from all modules.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
} from "./
|
|
69
|
-
|
|
70
|
-
//
|
|
71
|
-
export {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
1
|
+
/**
|
|
2
|
+
* CC-Native plan review library — package entry point.
|
|
3
|
+
* Re-exports the public API from all modules.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Artifacts
|
|
7
|
+
export {
|
|
8
|
+
buildCombinedJson,
|
|
9
|
+
buildHighIssuesDocument,
|
|
10
|
+
buildInlineReviewSummary,
|
|
11
|
+
extractTopIssuesText,
|
|
12
|
+
formatCombinedMarkdown,
|
|
13
|
+
formatReviewMarkdown,
|
|
14
|
+
generateReviewIndex,
|
|
15
|
+
writeCombinedArtifacts,
|
|
16
|
+
} from "../artifacts/lib/index.js";
|
|
17
|
+
|
|
18
|
+
// Orchestrator
|
|
19
|
+
export { buildOrchestratorSchema, runOrchestrator } from "../plan-review/lib/orchestrator.js";
|
|
20
|
+
|
|
21
|
+
// Reviewers
|
|
22
|
+
export {
|
|
23
|
+
AgentReviewer,
|
|
24
|
+
runAgentReview,
|
|
25
|
+
} from "../plan-review/lib/reviewers/index.js";
|
|
26
|
+
|
|
27
|
+
// Verdict aggregation
|
|
28
|
+
export { computeReviewDecision, worstVerdict } from "../plan-review/lib/verdict.js";
|
|
29
|
+
|
|
30
|
+
// Agent aggregation
|
|
31
|
+
export {
|
|
32
|
+
aggregateAgents,
|
|
33
|
+
extractBody,
|
|
34
|
+
extractFrontmatter,
|
|
35
|
+
} from "./aggregate-agents.js";
|
|
36
|
+
|
|
37
|
+
// CC-native state
|
|
38
|
+
export {
|
|
39
|
+
getCcNativeState,
|
|
40
|
+
isPlanAlreadyReviewed,
|
|
41
|
+
markPlanReviewed,
|
|
42
|
+
markQuestionsAsked,
|
|
43
|
+
saveCcNativeState,
|
|
44
|
+
wasPlanPreviouslyDenied,
|
|
45
|
+
wasQuestionsAsked,
|
|
46
|
+
} from "./cc-native-state.js";
|
|
47
|
+
|
|
48
|
+
// CLI output parsing
|
|
49
|
+
export { parseCliOutput } from "./cli-output-parser.js";
|
|
50
|
+
|
|
51
|
+
// Configuration
|
|
52
|
+
export { getDisplaySettings, loadConfig } from "./config.js";
|
|
53
|
+
|
|
54
|
+
// Constants & security
|
|
55
|
+
export {
|
|
56
|
+
ENABLE_PLAN_NOTIFICATIONS,
|
|
57
|
+
ENABLE_ROBUST_PLAN_WRITES,
|
|
58
|
+
MAX_ERROR_FILE_SIZE,
|
|
59
|
+
MAX_PLAN_PATH_LENGTH,
|
|
60
|
+
MAX_RETRY_ATTEMPTS,
|
|
61
|
+
MAX_TOTAL_RETRY_TIME_MS,
|
|
62
|
+
PLANS_DIR,
|
|
63
|
+
RETRY_BACKOFF_MS,
|
|
64
|
+
validatePlanPath,
|
|
65
|
+
} from "./constants.js";
|
|
66
|
+
|
|
67
|
+
// Debug logging
|
|
68
|
+
export { cleanupDebugFolder, debugLog, debugRaw, getDebugDir } from "./debug.js";
|
|
69
|
+
|
|
70
|
+
// JSON parsing
|
|
71
|
+
export { coerceToReview, parseJsonMaybe } from "./json-parser.js";
|
|
72
|
+
|
|
73
|
+
// Iteration state
|
|
74
|
+
export {
|
|
75
|
+
DEFAULT_REVIEW_ITERATIONS,
|
|
76
|
+
deleteState,
|
|
77
|
+
getIterationState,
|
|
78
|
+
getStateFilePath,
|
|
79
|
+
loadState,
|
|
80
|
+
saveStateToPlan,
|
|
81
|
+
shouldContinueIterating,
|
|
82
|
+
updateIterationState,
|
|
83
|
+
} from "./state.js";
|
|
84
|
+
|
|
85
|
+
// Types & schemas
|
|
86
|
+
export type {
|
|
87
|
+
AgentConfig,
|
|
88
|
+
CcNativeState,
|
|
89
|
+
CombinedReviewResult,
|
|
90
|
+
ComplexityCategory,
|
|
91
|
+
DisplaySettings,
|
|
92
|
+
IterationEntry,
|
|
93
|
+
IterationState,
|
|
94
|
+
OrchestratorConfig,
|
|
95
|
+
OrchestratorResult,
|
|
96
|
+
PlanReviewConfig,
|
|
97
|
+
PlanReviewState,
|
|
98
|
+
QuestionsAskedState,
|
|
99
|
+
ReviewData,
|
|
100
|
+
ReviewDecision,
|
|
101
|
+
ReviewDecisionResult,
|
|
102
|
+
Reviewer,
|
|
103
|
+
ReviewerResult,
|
|
104
|
+
ReviewIssue,
|
|
105
|
+
ReviewOptions,
|
|
106
|
+
Verdict,
|
|
107
|
+
} from "./types.js";
|
|
108
|
+
|
|
109
|
+
export {
|
|
110
|
+
AGENT_REVIEW_PROMPT_PREFIX,
|
|
111
|
+
DEFAULT_DISPLAY,
|
|
112
|
+
DEFAULT_SANITIZATION,
|
|
113
|
+
ORCHESTRATOR_SCHEMA,
|
|
114
|
+
REVIEW_PROMPT_PREFIX,
|
|
115
|
+
REVIEW_SCHEMA,
|
|
116
|
+
} from "./types.js";
|
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
* Extracted from cc-native-plan-review.ts.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import * as crypto from "node:crypto";
|
|
6
7
|
import * as fs from "node:fs";
|
|
7
|
-
import * as path from "node:path";
|
|
8
8
|
import * as os from "node:os";
|
|
9
|
-
import * as
|
|
9
|
+
import * as path from "node:path";
|
|
10
10
|
|
|
11
|
+
import type { DiscoveredPlan } from "./types.js";
|
|
11
12
|
import { logInfo, logDebug } from "../../_shared/lib-ts/base/logger.js";
|
|
12
13
|
import { findPlanPathInTranscript } from "../../_shared/lib-ts/context/plan-manager.js";
|
|
13
14
|
|
|
14
|
-
import type { DiscoveredPlan } from "./types.js";
|
|
15
15
|
|
|
16
16
|
const HOOK = "plan-discovery";
|
|
17
17
|
|
|
@@ -13,14 +13,17 @@
|
|
|
13
13
|
* bun embedding-indexer.ts --stats # Show index statistics
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
16
|
+
import { readFileSync, existsSync, readdirSync } from "node:fs";
|
|
17
|
+
import { readdir } from "node:fs/promises";
|
|
18
|
+
import { homedir } from "node:os";
|
|
19
|
+
import { join } from "node:path";
|
|
20
|
+
|
|
20
21
|
import { z } from "zod";
|
|
21
|
-
|
|
22
|
-
import { logInfo, logWarn, logError
|
|
22
|
+
|
|
23
|
+
import { logInfo, logWarn, logError } from "./logger.js";
|
|
23
24
|
import { checkOllamaHealth, embed } from "./ollama-client.js";
|
|
25
|
+
import { loadTranscript } from "./transcript-loader.js";
|
|
26
|
+
import { RLM_INDEX_DIR } from "./types.js";
|
|
24
27
|
import {
|
|
25
28
|
openVectorDb,
|
|
26
29
|
insertChunks,
|
|
@@ -30,7 +33,6 @@ import {
|
|
|
30
33
|
getStats,
|
|
31
34
|
type ChunkRow,
|
|
32
35
|
} from "./vector-store.js";
|
|
33
|
-
import { loadTranscript } from "./transcript-loader.js";
|
|
34
36
|
|
|
35
37
|
const HOOK_NAME = "rlm_embed_idx";
|
|
36
38
|
const MAX_EMBED_CHARS = 8000;
|
|
@@ -64,10 +66,12 @@ const projectFilter = projectArg ? projectArg.split("=")[1] : null;
|
|
|
64
66
|
if (isStats) {
|
|
65
67
|
showStats();
|
|
66
68
|
} else if (isBatch) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
try {
|
|
70
|
+
await runBatch();
|
|
71
|
+
} catch (error) {
|
|
72
|
+
logError(HOOK_NAME, `Fatal: ${error}`, { stderr: true });
|
|
69
73
|
process.exitCode = 1;
|
|
70
|
-
}
|
|
74
|
+
}
|
|
71
75
|
} else {
|
|
72
76
|
process.stderr.write(
|
|
73
77
|
"Usage: bun embedding-indexer.ts --batch [--limit=N] [--project=name]\n" +
|
|
@@ -232,9 +236,9 @@ async function runBatch(): Promise<void> {
|
|
|
232
236
|
if (embedded % 50 === 0) {
|
|
233
237
|
logInfo(HOOK_NAME, `Progress: ${embedded} sessions embedded`, { stderr: true });
|
|
234
238
|
}
|
|
235
|
-
} catch (
|
|
239
|
+
} catch (error) {
|
|
236
240
|
errors++;
|
|
237
|
-
logWarn(HOOK_NAME, `Error embedding ${indexFile}: ${
|
|
241
|
+
logWarn(HOOK_NAME, `Error embedding ${indexFile}: ${error}`);
|
|
238
242
|
}
|
|
239
243
|
}
|
|
240
244
|
|
|
@@ -11,9 +11,8 @@
|
|
|
11
11
|
* See: Gao et al., "Precise Zero-Shot Dense Retrieval without Relevance Labels" (ACL 2023)
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { generateText } from "./ollama-client.js";
|
|
15
|
-
import { embed, embedOne } from "./ollama-client.js";
|
|
16
14
|
import { logDebug, logInfo, logWarn } from "./logger.js";
|
|
15
|
+
import { generateText , embed, embedOne } from "./ollama-client.js";
|
|
17
16
|
|
|
18
17
|
const HOOK_NAME = "rlm_hyde";
|
|
19
18
|
|
|
@@ -105,7 +104,7 @@ export async function hydeQueryEmbedding(
|
|
|
105
104
|
logInfo(HOOK_NAME, `Generating ${config.numResponses} hypothetical responses via Ollama`);
|
|
106
105
|
|
|
107
106
|
// Step 1: Generate N hypothetical responses in parallel
|
|
108
|
-
const promises = Array.from({ length: config.numResponses }, (_
|
|
107
|
+
const promises = Array.from({ length: config.numResponses }, (_) =>
|
|
109
108
|
generateText(query, {
|
|
110
109
|
systemPrompt: HYDE_SYSTEM_PROMPT,
|
|
111
110
|
maxTokens: config.maxTokens,
|
|
@@ -4,51 +4,51 @@
|
|
|
4
4
|
* Public API re-exports for programmatic use from hooks/agents.
|
|
5
5
|
*/
|
|
6
6
|
|
|
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";
|
|
7
|
+
export { checkOllamaHealth, embed, embedOne, type OllamaConfig } from "./ollama-client.js";
|
|
29
8
|
|
|
30
9
|
export {
|
|
31
10
|
discoverSessions,
|
|
32
11
|
indexSession,
|
|
33
|
-
writeIndex,
|
|
34
12
|
needsIndexing,
|
|
35
13
|
runBatch,
|
|
14
|
+
writeIndex,
|
|
36
15
|
} from "./transcript-indexer.js";
|
|
37
16
|
|
|
38
|
-
export { search, scoreIndex, tokenize, type SearchOptions } from "./transcript-searcher.js";
|
|
39
|
-
|
|
40
17
|
export { loadTranscript } from "./transcript-loader.js";
|
|
41
18
|
|
|
42
|
-
export {
|
|
19
|
+
export { scoreIndex, search, type SearchOptions, tokenize } from "./transcript-searcher.js";
|
|
43
20
|
|
|
44
21
|
export {
|
|
45
|
-
|
|
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";
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
type ChunkRow,
|
|
46
|
+
deleteSessionChunks,
|
|
47
|
+
getStats,
|
|
46
48
|
insertChunks,
|
|
47
|
-
markSessionEmbedded,
|
|
48
49
|
isSessionEmbedded,
|
|
49
|
-
|
|
50
|
+
markSessionEmbedded,
|
|
51
|
+
openVectorDb,
|
|
50
52
|
searchKnn,
|
|
51
|
-
getStats,
|
|
52
|
-
type ChunkRow,
|
|
53
53
|
type VectorStats,
|
|
54
54
|
} from "./vector-store.js";
|
|
@@ -25,16 +25,18 @@ try {
|
|
|
25
25
|
logDebug = mod.logDebug;
|
|
26
26
|
} catch {
|
|
27
27
|
// Fallback: minimal stderr+file logger for standalone CLI execution
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
// eslint-disable-next-line unicorn/consistent-function-scoping -- must be inside catch for conditional init
|
|
29
|
+
const fallback = (level: string) => (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
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, no-undef -- dynamic require in fallback path
|
|
37
|
+
const fs = require("node:fs");
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, no-undef -- dynamic require in fallback path
|
|
39
|
+
const path = require("node:path");
|
|
38
40
|
const logDir = path.join(process.cwd(), "_output");
|
|
39
41
|
fs.mkdirSync(logDir, { recursive: true });
|
|
40
42
|
const entry = JSON.stringify({
|
|
@@ -48,11 +50,10 @@ try {
|
|
|
48
50
|
// Never crash on logging failure
|
|
49
51
|
}
|
|
50
52
|
};
|
|
51
|
-
};
|
|
52
53
|
logInfo = fallback("info");
|
|
53
54
|
logWarn = fallback("warn");
|
|
54
55
|
logError = fallback("error");
|
|
55
56
|
logDebug = fallback("debug");
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
export {
|
|
59
|
+
export { logDebug, logError, logInfo, logWarn };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable n/no-unsupported-features/node-builtins -- Bun runtime provides fetch */
|
|
1
2
|
/**
|
|
2
3
|
* Ollama HTTP client for local embeddings.
|
|
3
4
|
*
|
|
@@ -6,13 +7,14 @@
|
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
import { z } from "zod";
|
|
10
|
+
|
|
11
|
+
import { logDebug } from "./logger.js";
|
|
9
12
|
import {
|
|
10
13
|
OLLAMA_BASE_URL,
|
|
11
14
|
OLLAMA_EMBED_MODEL,
|
|
12
15
|
EMBED_DIMENSIONS,
|
|
13
16
|
HYDE_OLLAMA_MODEL,
|
|
14
17
|
} from "./types.js";
|
|
15
|
-
import { logDebug, logError } from "./logger.js";
|
|
16
18
|
|
|
17
19
|
const HOOK_NAME = "rlm_ollama";
|
|
18
20
|
const BATCH_SIZE = 32;
|
|
@@ -52,7 +54,7 @@ export async function checkOllamaHealth(
|
|
|
52
54
|
const cfg = { ...DEFAULT_CONFIG, ...config };
|
|
53
55
|
try {
|
|
54
56
|
const resp = await fetch(`${cfg.baseUrl}/api/tags`, {
|
|
55
|
-
signal: AbortSignal.timeout(
|
|
57
|
+
signal: AbortSignal.timeout(5000),
|
|
56
58
|
});
|
|
57
59
|
if (!resp.ok) {
|
|
58
60
|
return { ok: false, error: `Ollama responded with ${resp.status}` };
|
|
@@ -74,8 +76,8 @@ export async function checkOllamaHealth(
|
|
|
74
76
|
};
|
|
75
77
|
}
|
|
76
78
|
return { ok: true };
|
|
77
|
-
} catch (
|
|
78
|
-
const msg =
|
|
79
|
+
} catch (error: unknown) {
|
|
80
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
79
81
|
return {
|
|
80
82
|
ok: false,
|
|
81
83
|
error: `Cannot reach Ollama at ${cfg.baseUrl}: ${msg}. Is Ollama running?`,
|
|
@@ -117,7 +119,7 @@ export async function embed(
|
|
|
117
119
|
throw new Error(`Invalid Ollama embed response: ${parseResult.error.message}`);
|
|
118
120
|
}
|
|
119
121
|
|
|
120
|
-
const data = parseResult
|
|
122
|
+
const {data} = parseResult;
|
|
121
123
|
if (data.embeddings.length !== batch.length) {
|
|
122
124
|
throw new Error(
|
|
123
125
|
`Expected ${batch.length} embeddings, got ${data.embeddings.length}`,
|
|
@@ -197,11 +199,11 @@ export async function generateText(
|
|
|
197
199
|
text: data.response || "",
|
|
198
200
|
latency_ms: Date.now() - startTime,
|
|
199
201
|
};
|
|
200
|
-
} catch (
|
|
202
|
+
} catch (error) {
|
|
201
203
|
return {
|
|
202
204
|
success: false,
|
|
203
205
|
text: "",
|
|
204
|
-
error: String(
|
|
206
|
+
error: String(error),
|
|
205
207
|
latency_ms: Date.now() - startTime,
|
|
206
208
|
};
|
|
207
209
|
}
|
|
@@ -13,6 +13,11 @@
|
|
|
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";
|
|
16
21
|
import {
|
|
17
22
|
VECTOR_TOP_K,
|
|
18
23
|
MAX_PARALLEL_SUMMARIZERS,
|
|
@@ -26,11 +31,7 @@ import {
|
|
|
26
31
|
type RankedSession,
|
|
27
32
|
type RetrievalResult,
|
|
28
33
|
} from "./types.js";
|
|
29
|
-
import { logInfo, logWarn, logError, logDebug } from "./logger.js";
|
|
30
|
-
import { checkOllamaHealth, embedOne } from "./ollama-client.js";
|
|
31
34
|
import { openVectorDb, searchKnn } from "./vector-store.js";
|
|
32
|
-
import { loadTranscript } from "./transcript-loader.js";
|
|
33
|
-
import { hydeQueryEmbedding } from "./hyde.js";
|
|
34
35
|
|
|
35
36
|
const HOOK_NAME = "rlm_retrieve";
|
|
36
37
|
|
|
@@ -78,10 +79,12 @@ if (!query) {
|
|
|
78
79
|
);
|
|
79
80
|
process.exitCode = 1;
|
|
80
81
|
} else {
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
try {
|
|
83
|
+
await runPipeline(query, topK, projectFilter);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
logError(HOOK_NAME, `Fatal: ${error}`, { stderr: true });
|
|
83
86
|
process.exitCode = 1;
|
|
84
|
-
}
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
// ---------------------------------------------------------------------------
|
|
@@ -127,8 +130,8 @@ async function runPipeline(
|
|
|
127
130
|
});
|
|
128
131
|
hydeTiming = Date.now() - hydeStart;
|
|
129
132
|
logInfo(HOOK_NAME, `HyDE query embedding completed in ${hydeTiming}ms`);
|
|
130
|
-
} catch (
|
|
131
|
-
logWarn(HOOK_NAME, `HyDE failed: ${
|
|
133
|
+
} catch (error) {
|
|
134
|
+
logWarn(HOOK_NAME, `HyDE failed: ${error}, falling back to direct query embedding`);
|
|
132
135
|
queryEmbedding = await embedOne(query);
|
|
133
136
|
}
|
|
134
137
|
} else {
|
|
@@ -182,7 +185,7 @@ async function runPipeline(
|
|
|
182
185
|
}
|
|
183
186
|
}
|
|
184
187
|
}
|
|
185
|
-
const sessions =
|
|
188
|
+
const sessions = [...sessionMap.values()];
|
|
186
189
|
logInfo(
|
|
187
190
|
HOOK_NAME,
|
|
188
191
|
`Stage 2: ${results.length} chunks → ${sessions.length} sessions`,
|
|
@@ -254,10 +257,10 @@ async function summarizeSessions(
|
|
|
254
257
|
const promises = batch.map(async (session) => {
|
|
255
258
|
try {
|
|
256
259
|
return await summarizeOneSession(query, session);
|
|
257
|
-
} catch (
|
|
260
|
+
} catch (error) {
|
|
258
261
|
logWarn(
|
|
259
262
|
HOOK_NAME,
|
|
260
|
-
`Summarize failed for ${session.result.session_id}: ${
|
|
263
|
+
`Summarize failed for ${session.result.session_id}: ${error}`,
|
|
261
264
|
);
|
|
262
265
|
return null;
|
|
263
266
|
}
|
|
@@ -397,8 +400,8 @@ async function rankSessions(
|
|
|
397
400
|
key_findings: r.key_findings,
|
|
398
401
|
};
|
|
399
402
|
}).filter((r): r is RankedSession => r !== null);
|
|
400
|
-
} catch (
|
|
401
|
-
logWarn(HOOK_NAME, `Rank parse failed: ${
|
|
403
|
+
} catch (error) {
|
|
404
|
+
logWarn(HOOK_NAME, `Rank parse failed: ${error}, marking all as relevant`);
|
|
402
405
|
return summaries.map((s) => ({
|
|
403
406
|
session_id: s.session_id,
|
|
404
407
|
project: s.project,
|