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.
Files changed (134) hide show
  1. package/dist/commands/clean.d.ts +7 -0
  2. package/dist/commands/clean.js +17 -8
  3. package/dist/commands/clear.d.ts +85 -0
  4. package/dist/commands/clear.js +455 -347
  5. package/dist/commands/init/index.d.ts +15 -0
  6. package/dist/commands/init/index.js +79 -38
  7. package/dist/lib/gitignore-manager.js +12 -13
  8. package/dist/lib/settings-hierarchy.d.ts +13 -1
  9. package/dist/lib/settings-hierarchy.js +1 -1
  10. package/dist/lib/template-linter.d.ts +4 -0
  11. package/dist/lib/template-linter.js +1 -1
  12. package/dist/lib/tty-detection.d.ts +1 -0
  13. package/dist/lib/tty-detection.js +1 -0
  14. package/dist/templates/CLAUDE.md +27 -0
  15. package/dist/templates/_shared/.claude/settings.json +7 -7
  16. package/dist/templates/_shared/.claude/{commands/handoff.md → skills/handoff/SKILL.md} +4 -3
  17. package/dist/templates/_shared/.claude/{commands/handoff-resume.md → skills/handoff-resume/SKILL.md} +3 -2
  18. package/dist/templates/_shared/.claude/skills/meta-plan/SKILL.md +43 -0
  19. package/dist/templates/_shared/.codex/workflows/handoff.md +1 -1
  20. package/dist/templates/_shared/.codex/workflows/meta-plan.md +347 -0
  21. package/dist/templates/_shared/.windsurf/workflows/handoff.md +1 -1
  22. package/dist/templates/_shared/.windsurf/workflows/meta-plan.md +347 -0
  23. package/dist/templates/_shared/hooks-ts/lint_after_edit.ts +59 -0
  24. package/dist/templates/_shared/hooks-ts/session_end.ts +11 -10
  25. package/dist/templates/_shared/hooks-ts/session_start.ts +15 -12
  26. package/dist/templates/_shared/hooks-ts/user_prompt_submit.ts +12 -12
  27. package/dist/templates/_shared/lib-ts/CLAUDE.md +3 -3
  28. package/dist/templates/_shared/lib-ts/base/constants.ts +324 -306
  29. package/dist/templates/_shared/lib-ts/base/hook-utils.ts +26 -7
  30. package/dist/templates/_shared/lib-ts/base/inference.ts +19 -19
  31. package/dist/templates/_shared/lib-ts/base/lint-dispatch.ts +287 -0
  32. package/dist/templates/_shared/lib-ts/base/state-io.ts +4 -3
  33. package/dist/templates/_shared/lib-ts/base/subprocess-utils.ts +3 -3
  34. package/dist/templates/_shared/lib-ts/context/CLAUDE.md +134 -0
  35. package/dist/templates/_shared/lib-ts/context/context-formatter.ts +16 -15
  36. package/dist/templates/_shared/lib-ts/context/context-selector.ts +16 -16
  37. package/dist/templates/_shared/lib-ts/context/context-store.ts +15 -14
  38. package/dist/templates/_shared/lib-ts/context/plan-manager.ts +2 -2
  39. package/dist/templates/_shared/scripts/resolve-run.ts +61 -0
  40. package/dist/templates/_shared/scripts/resolve_context.ts +1 -1
  41. package/dist/templates/_shared/scripts/status_line.ts +100 -94
  42. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/CLAUDE.md +433 -421
  43. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/lib/document-generator.ts +5 -4
  44. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/lib/handoff-reader.ts +2 -1
  45. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/scripts/resume_handoff.ts +6 -6
  46. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/scripts/save_handoff.ts +16 -17
  47. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/workflows/handoff-resume.md +2 -2
  48. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/workflows/handoff.md +3 -3
  49. package/dist/templates/_shared/skills/meta-plan/CLAUDE.md +44 -0
  50. package/dist/templates/_shared/skills/meta-plan/workflows/meta-plan.md +347 -0
  51. package/dist/templates/cc-native/.claude/commands/cc-native/specdev.md +1 -1
  52. package/dist/templates/cc-native/.claude/settings.json +86 -57
  53. package/dist/templates/cc-native/_cc-native/artifacts/CLAUDE.md +64 -0
  54. package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/format.ts +599 -597
  55. package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/index.ts +26 -26
  56. package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/tracker.ts +107 -106
  57. package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/write.ts +119 -118
  58. package/dist/templates/cc-native/_cc-native/hooks/CLAUDE.md +237 -247
  59. package/dist/templates/cc-native/_cc-native/hooks/cc-native-plan-review.ts +76 -74
  60. package/dist/templates/cc-native/_cc-native/hooks/validate_task_prompt.ts +76 -0
  61. package/dist/templates/cc-native/_cc-native/lib-ts/aggregate-agents.ts +163 -156
  62. package/dist/templates/cc-native/_cc-native/lib-ts/cc-native-state.ts +15 -16
  63. package/dist/templates/cc-native/_cc-native/lib-ts/index.ts +116 -116
  64. package/dist/templates/cc-native/_cc-native/lib-ts/plan-discovery.ts +3 -3
  65. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/embedding-indexer.ts +16 -12
  66. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/hyde.ts +2 -3
  67. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/index.ts +31 -31
  68. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/logger.ts +7 -6
  69. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/ollama-client.ts +9 -7
  70. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/retrieval-pipeline.ts +17 -14
  71. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-indexer.ts +41 -37
  72. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-loader.ts +43 -33
  73. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-searcher.ts +20 -20
  74. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/types.ts +9 -8
  75. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/vector-store.ts +4 -3
  76. package/dist/templates/cc-native/_cc-native/lib-ts/settings.ts +9 -10
  77. package/dist/templates/cc-native/_cc-native/lib-ts/state.ts +20 -19
  78. package/dist/templates/cc-native/_cc-native/lib-ts/types.ts +329 -329
  79. package/dist/templates/cc-native/_cc-native/plan-review/CLAUDE.md +149 -0
  80. package/dist/templates/cc-native/_cc-native/plan-review/agents/CLAUDE.md +143 -0
  81. package/dist/templates/cc-native/_cc-native/plan-review/agents/PLAN-ORCHESTRATOR.md +213 -0
  82. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-questions/PLAN-QUESTIONER.md +70 -0
  83. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-EVOLUTION.md +62 -0
  84. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-PATTERNS.md +61 -0
  85. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-STRUCTURE.md +62 -0
  86. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ASSUMPTION-TRACER.md +56 -0
  87. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/CLARITY-AUDITOR.md +53 -0
  88. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-FEASIBILITY.md +66 -0
  89. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-GAPS.md +70 -0
  90. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-ORDERING.md +62 -0
  91. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/CONSTRAINT-VALIDATOR.md +72 -0
  92. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DESIGN-ADR-VALIDATOR.md +61 -0
  93. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DESIGN-SCALE-MATCHER.md +64 -0
  94. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DEVILS-ADVOCATE.md +56 -0
  95. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DOCUMENTATION-PHILOSOPHY.md +86 -0
  96. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/HANDOFF-READINESS.md +59 -0
  97. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/HIDDEN-COMPLEXITY.md +58 -0
  98. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/INCREMENTAL-DELIVERY.md +66 -0
  99. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-DEPENDENCY.md +62 -0
  100. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-FMEA.md +66 -0
  101. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-PREMORTEM.md +71 -0
  102. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-REVERSIBILITY.md +74 -0
  103. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SCOPE-BOUNDARY.md +77 -0
  104. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SIMPLICITY-GUARDIAN.md +62 -0
  105. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SKEPTIC.md +68 -0
  106. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-BEHAVIOR-AUDITOR.md +61 -0
  107. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-CHARACTERIZATION.md +71 -0
  108. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-FIRST-VALIDATOR.md +61 -0
  109. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-PYRAMID-ANALYZER.md +61 -0
  110. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TRADEOFF-COSTS.md +67 -0
  111. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TRADEOFF-STAKEHOLDERS.md +65 -0
  112. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/VERIFY-COVERAGE.md +74 -0
  113. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/VERIFY-STRENGTH.md +69 -0
  114. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/agent-selection.ts +162 -163
  115. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/corroboration.ts +119 -119
  116. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/graduation.ts +132 -132
  117. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/orchestrator.ts +70 -70
  118. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/output-builder.ts +121 -130
  119. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/plan-questions.ts +101 -102
  120. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/review-pipeline.ts +507 -511
  121. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/agent.ts +73 -74
  122. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/base/base-agent.ts +217 -217
  123. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/index.ts +12 -12
  124. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/claude-agent.ts +66 -66
  125. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/codex-agent.ts +185 -185
  126. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/gemini-agent.ts +39 -39
  127. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/orchestrator-claude-agent.ts +196 -196
  128. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/schemas.ts +201 -201
  129. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/types.ts +23 -23
  130. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/verdict.ts +72 -72
  131. package/dist/templates/cc-native/_cc-native/{workflows → plan-review/workflows}/specdev.md +9 -9
  132. package/oclif.manifest.json +1 -1
  133. package/package.json +6 -5
  134. 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
- // Agent aggregation
7
- export {
8
- aggregateAgents,
9
- extractBody,
10
- extractFrontmatter,
11
- } from "./aggregate-agents.js";
12
-
13
- // Artifacts
14
- export {
15
- buildCombinedJson,
16
- buildHighIssuesDocument,
17
- buildInlineReviewSummary,
18
- extractTopIssuesText,
19
- formatCombinedMarkdown,
20
- formatReviewMarkdown,
21
- generateReviewIndex,
22
- writeCombinedArtifacts,
23
- } from "./artifacts.js";
24
-
25
- // CC-native state
26
- export {
27
- getCcNativeState,
28
- isPlanAlreadyReviewed,
29
- markPlanReviewed,
30
- markQuestionsAsked,
31
- saveCcNativeState,
32
- wasPlanPreviouslyDenied,
33
- wasQuestionsAsked,
34
- } from "./cc-native-state.js";
35
-
36
- // CLI output parsing
37
- export { parseCliOutput } from "./cli-output-parser.js";
38
-
39
- // Configuration
40
- export { getDisplaySettings, loadConfig } from "./config.js";
41
-
42
- // Constants & security
43
- export {
44
- ENABLE_PLAN_NOTIFICATIONS,
45
- ENABLE_ROBUST_PLAN_WRITES,
46
- MAX_ERROR_FILE_SIZE,
47
- MAX_PLAN_PATH_LENGTH,
48
- MAX_RETRY_ATTEMPTS,
49
- MAX_TOTAL_RETRY_TIME_MS,
50
- PLANS_DIR,
51
- RETRY_BACKOFF_MS,
52
- validatePlanPath,
53
- } from "./constants.js";
54
-
55
- // Debug logging
56
- export { cleanupDebugFolder, debugLog, debugRaw, getDebugDir } from "./debug.js";
57
-
58
- // JSON parsing
59
- export { coerceToReview, parseJsonMaybe } from "./json-parser.js";
60
-
61
- // Orchestrator
62
- export { buildOrchestratorSchema, runOrchestrator } from "./orchestrator.js";
63
-
64
- // Reviewers
65
- export {
66
- AgentReviewer,
67
- runAgentReview,
68
- } from "./reviewers/index.js";
69
-
70
- // Iteration state
71
- export {
72
- DEFAULT_REVIEW_ITERATIONS,
73
- deleteState,
74
- getIterationState,
75
- getStateFilePath,
76
- loadState,
77
- saveStateToPlan,
78
- shouldContinueIterating,
79
- updateIterationState,
80
- } from "./state.js";
81
-
82
- // Types & schemas
83
- export type {
84
- AgentConfig,
85
- CcNativeState,
86
- CombinedReviewResult,
87
- ComplexityCategory,
88
- DisplaySettings,
89
- IterationEntry,
90
- IterationState,
91
- OrchestratorConfig,
92
- OrchestratorResult,
93
- PlanReviewConfig,
94
- PlanReviewState,
95
- QuestionsAskedState,
96
- ReviewData,
97
- ReviewDecision,
98
- ReviewDecisionResult,
99
- Reviewer,
100
- ReviewerResult,
101
- ReviewIssue,
102
- ReviewOptions,
103
- Verdict,
104
- } from "./types.js";
105
-
106
- export {
107
- AGENT_REVIEW_PROMPT_PREFIX,
108
- DEFAULT_DISPLAY,
109
- DEFAULT_SANITIZATION,
110
- ORCHESTRATOR_SCHEMA,
111
- REVIEW_PROMPT_PREFIX,
112
- REVIEW_SCHEMA,
113
- } from "./types.js";
114
-
115
- // Verdict aggregation
116
- export { computeReviewDecision, worstVerdict } from "./verdict.js";
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 crypto from "node:crypto";
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 { readdir } from "fs/promises";
17
- import { readFileSync, existsSync, readdirSync } from "fs";
18
- import { join } from "path";
19
- import { homedir } from "os";
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
- import { RLM_INDEX_DIR, type SessionIndex } from "./types.js";
22
- import { logInfo, logWarn, logError, logDebug } from "./logger.js";
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
- runBatch().catch((e) => {
68
- logError(HOOK_NAME, `Fatal: ${e}`, { stderr: true });
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 (e) {
239
+ } catch (error) {
236
240
  errors++;
237
- logWarn(HOOK_NAME, `Error embedding ${indexFile}: ${e}`);
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 }, (_, i) =>
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 { checkOllamaHealth, embed, embedOne, type OllamaConfig } from "./ollama-client.js";
19
+ export { scoreIndex, search, type SearchOptions, tokenize } from "./transcript-searcher.js";
43
20
 
44
21
  export {
45
- openVectorDb,
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
- deleteSessionChunks,
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
- const fallback = (level: string) => {
29
- return (hookName: string, message: string, opts?: Record<string, unknown>) => {
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
- const fs = require("fs");
37
- const path = require("path");
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 { logInfo, logWarn, logError, logDebug };
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(5_000),
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 (e: unknown) {
78
- const msg = e instanceof Error ? e.message : String(e);
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.data;
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 (e) {
202
+ } catch (error) {
201
203
  return {
202
204
  success: false,
203
205
  text: "",
204
- error: String(e),
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
- runPipeline(query, topK, projectFilter).catch((e) => {
82
- logError(HOOK_NAME, `Fatal: ${e}`, { stderr: true });
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 (e) {
131
- logWarn(HOOK_NAME, `HyDE failed: ${e}, falling back to direct query embedding`);
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 = Array.from(sessionMap.values());
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 (e) {
260
+ } catch (error) {
258
261
  logWarn(
259
262
  HOOK_NAME,
260
- `Summarize failed for ${session.result.session_id}: ${e}`,
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 (e) {
401
- logWarn(HOOK_NAME, `Rank parse failed: ${e}, marking all as relevant`);
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,