sweet-search 2.5.2 → 2.5.4
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/core/cli.js +24 -3
- package/core/graph/graph-expansion.js +215 -36
- package/core/graph/graph-extractor.js +196 -11
- package/core/graph/graph-search.js +395 -92
- package/core/graph/hcgs-generator.js +2 -1
- package/core/graph/index.js +2 -0
- package/core/graph/repo-map.js +28 -6
- package/core/graph/structural-answer-cues.js +168 -0
- package/core/graph/structural-callsite-hints.js +40 -0
- package/core/graph/structural-context-format.js +40 -0
- package/core/graph/structural-context.js +450 -0
- package/core/graph/structural-forward-push.js +156 -0
- package/core/graph/structural-header-context.js +19 -0
- package/core/graph/structural-importance.js +148 -0
- package/core/graph/structural-pagerank.js +197 -0
- package/core/graph/summary-manager.js +13 -9
- package/core/incremental-indexing/application/dirty-scan.mjs +236 -0
- package/core/incremental-indexing/application/file-watcher.mjs +197 -0
- package/core/incremental-indexing/application/maintenance-handlers.mjs +519 -0
- package/core/incremental-indexing/application/maintenance-worker.mjs +380 -0
- package/core/incremental-indexing/application/operator-cli.mjs +554 -0
- package/core/incremental-indexing/application/production-li-delta.mjs +192 -0
- package/core/incremental-indexing/application/production-reconciler-helpers.mjs +107 -0
- package/core/incremental-indexing/application/production-reconciler.mjs +583 -0
- package/core/incremental-indexing/application/reconciler.mjs +477 -0
- package/core/incremental-indexing/application/tombstone-injector.mjs +148 -0
- package/core/incremental-indexing/domain/chunk-identity.mjs +260 -0
- package/core/incremental-indexing/domain/encoder-deps.mjs +193 -0
- package/core/incremental-indexing/domain/encoder-input.mjs +225 -0
- package/core/incremental-indexing/domain/interval-autotune.mjs +255 -0
- package/core/incremental-indexing/domain/reconcile-counters.mjs +149 -0
- package/core/incremental-indexing/domain/watermark-scheduler.mjs +239 -0
- package/core/incremental-indexing/infrastructure/artifact-temp-sweep.mjs +163 -0
- package/core/incremental-indexing/infrastructure/baseline-readiness.mjs +121 -0
- package/core/incremental-indexing/infrastructure/dirty-set.mjs +233 -0
- package/core/incremental-indexing/infrastructure/graph-gc.mjs +314 -0
- package/core/incremental-indexing/infrastructure/hashing.mjs +298 -0
- package/core/incremental-indexing/infrastructure/hcgs-invalidation.mjs +182 -0
- package/core/incremental-indexing/infrastructure/li-segment-merge.mjs +278 -0
- package/core/incremental-indexing/infrastructure/li-segment-state.mjs +173 -0
- package/core/incremental-indexing/infrastructure/lockfile.mjs +119 -0
- package/core/incremental-indexing/infrastructure/maintenance-state-reader.mjs +283 -0
- package/core/incremental-indexing/infrastructure/manifest.mjs +194 -0
- package/core/incremental-indexing/infrastructure/path-filter.mjs +190 -0
- package/core/incremental-indexing/infrastructure/reader-heartbeat.mjs +201 -0
- package/core/incremental-indexing/infrastructure/schema-migrations.mjs +257 -0
- package/core/incremental-indexing/infrastructure/sparse-gram-delta.mjs +335 -0
- package/core/incremental-indexing/infrastructure/sqlite-fts5.mjs +176 -0
- package/core/incremental-indexing/infrastructure/staleness-display.mjs +105 -0
- package/core/incremental-indexing/infrastructure/tombstone-bitmap.mjs +234 -0
- package/core/incremental-indexing/infrastructure/vector-delta-writer.mjs +359 -0
- package/core/incremental-indexing/infrastructure/vector-gc.mjs +133 -0
- package/core/incremental-indexing/infrastructure/worktree-stamp.mjs +155 -0
- package/core/incremental-indexing/infrastructure/wsl2-detect.mjs +115 -0
- package/core/indexing/admission-policy.js +139 -0
- package/core/indexing/artifact-builder.js +29 -12
- package/core/indexing/ast-chunker.js +107 -30
- package/core/indexing/dedup/exemplar-selector.js +19 -1
- package/core/indexing/gitignore-filter.js +223 -0
- package/core/indexing/incremental-tracker.js +99 -30
- package/core/indexing/index-codebase-v21.js +6 -5
- package/core/indexing/index-maintainer.mjs +698 -6
- package/core/indexing/indexer-ann.js +99 -15
- package/core/indexing/indexer-build.js +158 -45
- package/core/indexing/indexer-empty-baseline.js +80 -0
- package/core/indexing/indexer-manifest.js +66 -0
- package/core/indexing/indexer-phases.js +56 -23
- package/core/indexing/indexer-sparse-gram.js +54 -13
- package/core/indexing/indexer-utils.js +26 -208
- package/core/indexing/indexing-file-policy.js +32 -7
- package/core/indexing/maintainer-launcher.mjs +137 -0
- package/core/indexing/merkle-tracker.js +251 -244
- package/core/indexing/model-pool.js +46 -5
- package/core/infrastructure/code-graph-repository.js +758 -6
- package/core/infrastructure/code-graph-visibility.js +157 -0
- package/core/infrastructure/codebase-repository.js +100 -13
- package/core/infrastructure/config/search.js +1 -1
- package/core/infrastructure/db-utils.js +118 -0
- package/core/infrastructure/dedup-hashing.js +10 -13
- package/core/infrastructure/hardware-capability.js +17 -7
- package/core/infrastructure/index.js +8 -2
- package/core/infrastructure/language-patterns/maps.js +4 -1
- package/core/infrastructure/language-patterns/registry-core.js +56 -17
- package/core/infrastructure/language-patterns/registry-object-oriented.js +12 -5
- package/core/infrastructure/language-patterns.js +69 -0
- package/core/infrastructure/model-registry.js +20 -0
- package/core/infrastructure/native-inference.js +7 -12
- package/core/infrastructure/native-resolver.js +52 -37
- package/core/infrastructure/native-sparse-gram.js +261 -20
- package/core/infrastructure/native-tokenizer.js +6 -15
- package/core/infrastructure/simd-distance.js +10 -16
- package/core/infrastructure/sparse-gram-delta-reader.js +76 -0
- package/core/infrastructure/structural-alias-resolver.js +122 -0
- package/core/infrastructure/structural-candidate-ranker.js +34 -0
- package/core/infrastructure/structural-context-repository.js +472 -0
- package/core/infrastructure/structural-context-utils.js +51 -0
- package/core/infrastructure/structural-graph-signals.js +121 -0
- package/core/infrastructure/structural-qualified-resolution.js +15 -0
- package/core/infrastructure/structural-source-definitions.js +100 -0
- package/core/infrastructure/tombstone-bitmap-reader.js +139 -0
- package/core/infrastructure/tree-sitter-provider.js +811 -37
- package/core/prompt-optimization/data/p7-final/sweet-search-system-prompt.md +50 -0
- package/core/query/query-router.js +55 -5
- package/core/ranking/file-kind-ranking.js +2192 -15
- package/core/ranking/late-interaction-index.js +87 -12
- package/core/search/cli-decoration.js +290 -0
- package/core/search/context-expander.js +988 -78
- package/core/search/index.js +1 -0
- package/core/search/output-policy.js +275 -0
- package/core/search/search-anchor.js +499 -0
- package/core/search/search-boost.js +93 -1
- package/core/search/search-cli.js +61 -204
- package/core/search/search-hybrid.js +250 -10
- package/core/search/search-pattern-chunks.js +57 -8
- package/core/search/search-pattern-planner.js +68 -9
- package/core/search/search-pattern-prefilter.js +30 -10
- package/core/search/search-pattern-ripgrep.js +40 -4
- package/core/search/search-pattern-sparse-overlay.js +256 -0
- package/core/search/search-pattern.js +117 -29
- package/core/search/search-postprocess.js +479 -5
- package/core/search/search-read-semantic.js +260 -23
- package/core/search/search-read.js +82 -64
- package/core/search/search-reader-pin.js +71 -0
- package/core/search/search-rrf.js +279 -0
- package/core/search/search-semantic.js +110 -5
- package/core/search/search-server.js +130 -57
- package/core/search/search-trace.js +107 -0
- package/core/search/server-identity.js +93 -0
- package/core/search/session-daemon-prewarm.mjs +33 -10
- package/core/search/sweet-search.js +399 -7
- package/core/skills/sweet-index/SKILL.md +8 -6
- package/core/vector-store/binary-hnsw-index.js +194 -30
- package/core/vector-store/float-vector-store.js +96 -6
- package/core/vector-store/hnsw-index.js +220 -49
- package/eval/agent-read-workflows/bin/_ss-helpers.mjs +471 -0
- package/eval/agent-read-workflows/bin/ss-find +15 -0
- package/eval/agent-read-workflows/bin/ss-grep +12 -0
- package/eval/agent-read-workflows/bin/ss-read +14 -0
- package/eval/agent-read-workflows/bin/ss-search +18 -0
- package/eval/agent-read-workflows/bin/ss-semantic +12 -0
- package/eval/agent-read-workflows/bin/ss-trace +11 -0
- package/mcp/read-tool.js +109 -0
- package/mcp/server.js +55 -15
- package/mcp/tool-handlers.js +14 -124
- package/mcp/trace-tool.js +81 -0
- package/package.json +25 -10
- package/scripts/hooks/intercept-read.mjs +55 -0
- package/scripts/hooks/remind-tools.mjs +40 -0
- package/scripts/init.js +698 -54
- package/scripts/inject-agent-instructions.js +431 -0
- package/scripts/install-prompt-reminders.js +188 -0
- package/scripts/install-tool-enforcement.js +220 -0
- package/scripts/smoke-test.js +12 -9
- package/scripts/uninstall.js +276 -18
- package/scripts/write-claude-rules.js +110 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude-specific rules file under `.claude/rules/sweet-search.md`, plus the
|
|
3
|
+
* `@.claude/rules/sweet-search.md` import line in `CLAUDE.md`.
|
|
4
|
+
*
|
|
5
|
+
* Plan reference: §4B. The Claude Code memory system loads `.claude/rules/*.md`
|
|
6
|
+
* only via documented `CLAUDE.md` imports — we never assume auto-loading. The
|
|
7
|
+
* import is wired by `inject-agent-instructions.js` (which writes the
|
|
8
|
+
* sweet-search marker block in `CLAUDE.md` containing `@AGENTS.md` plus
|
|
9
|
+
* `@.claude/rules/sweet-search.md`).
|
|
10
|
+
*
|
|
11
|
+
* Lifecycle:
|
|
12
|
+
* - init → writes (or rewrites) `.claude/rules/sweet-search.md`
|
|
13
|
+
* - re-init → overwrites idempotently (no diff if content unchanged)
|
|
14
|
+
* - uninstall → removes the rules file (the import line in CLAUDE.md is
|
|
15
|
+
* stripped by `removeAgentInstructions` in inject-agent-instructions.js)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
19
|
+
import { dirname, join } from 'node:path';
|
|
20
|
+
|
|
21
|
+
export const CLAUDE_RULES_REL = '.claude/rules/sweet-search.md';
|
|
22
|
+
|
|
23
|
+
// Sentinel header so we can recognise "this file is sweet-search-managed"
|
|
24
|
+
// without keeping a separate manifest.
|
|
25
|
+
const SENTINEL = '<!-- generated by `sweet-search init`; edit `AGENTS.md` for the canonical policy -->';
|
|
26
|
+
|
|
27
|
+
const BODY = `${SENTINEL}
|
|
28
|
+
|
|
29
|
+
# Sweet Search — Claude-specific rules
|
|
30
|
+
|
|
31
|
+
These supplement the canonical \`AGENTS.md\` policy with Claude Code surface
|
|
32
|
+
nudges. The canonical decision tree is in \`AGENTS.md\`; this file only
|
|
33
|
+
captures Claude-specific behaviour.
|
|
34
|
+
|
|
35
|
+
## Tool selection (Claude harness specifics)
|
|
36
|
+
|
|
37
|
+
- Prefer \`ss-grep\`, \`ss-find\`, \`ss-read\`, \`ss-semantic\` (the sweet-search
|
|
38
|
+
agent wrappers) over native \`Grep\` / \`Read\` for code-discovery and
|
|
39
|
+
code-reading tasks. The sweet-search wrappers ship semantic ranking,
|
|
40
|
+
graph-neighbour expansion, and tight chunk packaging that native tools
|
|
41
|
+
do not provide.
|
|
42
|
+
- Use native \`Read\` only when the file path AND exact line range are already
|
|
43
|
+
known from a prior sweet-search call. Bare \`Read\` of a whole file for
|
|
44
|
+
code-understanding loses the ranked-pack trailer signals.
|
|
45
|
+
- Use native \`Grep\` only for trivial single-token literal lookups in tiny
|
|
46
|
+
scopes where index startup cost dominates (one file, one pattern). For
|
|
47
|
+
anything larger, \`ss-grep\` returns ranked + scored hits in the same
|
|
48
|
+
latency band.
|
|
49
|
+
|
|
50
|
+
## Honour the response trailer
|
|
51
|
+
|
|
52
|
+
When sweet-search returns \`sufficient=YES\` plus a \`presentation=full\` top-1
|
|
53
|
+
result, answer immediately. Calling a second sweet-search tool merely to
|
|
54
|
+
"verify" the first answer wastes turns and tokens — see the STOP rules block
|
|
55
|
+
in \`AGENTS.md\` for the full discipline.
|
|
56
|
+
|
|
57
|
+
## Avoid running sweet-search via Bash when a wrapper exists
|
|
58
|
+
|
|
59
|
+
The agent wrappers (\`ss-grep\`, etc.) have stable argument shapes and are
|
|
60
|
+
safer than constructing \`bash -lc 'sweet-search grep ...'\` invocations on the
|
|
61
|
+
fly. Bash construction also bypasses any \`PreToolUse\` hint hooks the user has
|
|
62
|
+
installed.
|
|
63
|
+
`;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Write `.claude/rules/sweet-search.md`. Idempotent: re-running with
|
|
67
|
+
* unchanged content is a no-op (no mtime bump).
|
|
68
|
+
*
|
|
69
|
+
* @returns 'created' | 'updated' | 'unchanged'
|
|
70
|
+
*/
|
|
71
|
+
export function writeClaudeRules({ projectRoot } = {}) {
|
|
72
|
+
if (!projectRoot) throw new TypeError('write-claude-rules: projectRoot is required');
|
|
73
|
+
const filePath = join(projectRoot, CLAUDE_RULES_REL);
|
|
74
|
+
if (!existsSync(filePath)) {
|
|
75
|
+
mkdirSync(dirname(filePath), { recursive: true });
|
|
76
|
+
writeFileSync(filePath, BODY);
|
|
77
|
+
return 'created';
|
|
78
|
+
}
|
|
79
|
+
const current = readFileSync(filePath, 'utf8');
|
|
80
|
+
if (current === BODY) return 'unchanged';
|
|
81
|
+
// If the existing file is sweet-search-managed (sentinel present), rewrite
|
|
82
|
+
// it. If a user wrote their own file at this path, leave it alone — they
|
|
83
|
+
// can opt out by removing the sentinel-tagged version manually.
|
|
84
|
+
if (!current.startsWith(SENTINEL) && !current.includes(SENTINEL)) {
|
|
85
|
+
return 'preserved-user-file';
|
|
86
|
+
}
|
|
87
|
+
writeFileSync(filePath, BODY);
|
|
88
|
+
return 'updated';
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Remove `.claude/rules/sweet-search.md` if it carries the sweet-search
|
|
93
|
+
* sentinel. The CLAUDE.md import line is stripped by
|
|
94
|
+
* `removeAgentInstructions` in `inject-agent-instructions.js`.
|
|
95
|
+
*
|
|
96
|
+
* @returns 'removed' | 'not-found' | 'preserved-user-file' | 'dry-run'
|
|
97
|
+
*/
|
|
98
|
+
export function removeClaudeRules({ projectRoot, dryRun = false } = {}) {
|
|
99
|
+
if (!projectRoot) throw new TypeError('remove-claude-rules: projectRoot is required');
|
|
100
|
+
const filePath = join(projectRoot, CLAUDE_RULES_REL);
|
|
101
|
+
if (!existsSync(filePath)) return 'not-found';
|
|
102
|
+
const text = readFileSync(filePath, 'utf8');
|
|
103
|
+
if (!text.includes(SENTINEL)) return 'preserved-user-file';
|
|
104
|
+
if (dryRun) return 'dry-run';
|
|
105
|
+
unlinkSync(filePath);
|
|
106
|
+
return 'removed';
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Exposed for tests.
|
|
110
|
+
export const _internal = { BODY, SENTINEL };
|