pi-tropos 0.0.0-stage → 0.3.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 (89) hide show
  1. package/README.md +34 -2
  2. package/index.ts +10 -0
  3. package/node_modules/pi-smritikosh/README.md +92 -0
  4. package/node_modules/pi-smritikosh/index.ts +43 -0
  5. package/node_modules/pi-smritikosh/package.json +45 -0
  6. package/node_modules/pi-smritikosh/python/LICENSE +201 -0
  7. package/node_modules/pi-smritikosh/python/pyproject.toml +137 -0
  8. package/node_modules/pi-smritikosh/python/smk_progress.py +79 -0
  9. package/node_modules/pi-smritikosh/python/smritikosh/__init__.py +0 -0
  10. package/node_modules/pi-smritikosh/python/smritikosh/__main__.py +11 -0
  11. package/node_modules/pi-smritikosh/python/smritikosh/adapters/__init__.py +0 -0
  12. package/node_modules/pi-smritikosh/python/smritikosh/adapters/_arrow.py +42 -0
  13. package/node_modules/pi-smritikosh/python/smritikosh/adapters/embedder/__init__.py +15 -0
  14. package/node_modules/pi-smritikosh/python/smritikosh/adapters/embedder/fastembed.py +164 -0
  15. package/node_modules/pi-smritikosh/python/smritikosh/adapters/embedder/mps.py +223 -0
  16. package/node_modules/pi-smritikosh/python/smritikosh/adapters/embedder/resolver.py +79 -0
  17. package/node_modules/pi-smritikosh/python/smritikosh/adapters/file_source/__init__.py +0 -0
  18. package/node_modules/pi-smritikosh/python/smritikosh/adapters/file_source/local.py +46 -0
  19. package/node_modules/pi-smritikosh/python/smritikosh/adapters/retrieval/__init__.py +1 -0
  20. package/node_modules/pi-smritikosh/python/smritikosh/adapters/retrieval/duckdb.py +325 -0
  21. package/node_modules/pi-smritikosh/python/smritikosh/adapters/retrieval/source.py +587 -0
  22. package/node_modules/pi-smritikosh/python/smritikosh/adapters/storage/__init__.py +0 -0
  23. package/node_modules/pi-smritikosh/python/smritikosh/adapters/storage/duckdb.py +210 -0
  24. package/node_modules/pi-smritikosh/python/smritikosh/adapters/vector_store/__init__.py +0 -0
  25. package/node_modules/pi-smritikosh/python/smritikosh/adapters/vector_store/duckdb.py +203 -0
  26. package/node_modules/pi-smritikosh/python/smritikosh/cli.py +272 -0
  27. package/node_modules/pi-smritikosh/python/smritikosh/constants.py +26 -0
  28. package/node_modules/pi-smritikosh/python/smritikosh/engine/__init__.py +50 -0
  29. package/node_modules/pi-smritikosh/python/smritikosh/engine/_batch.py +217 -0
  30. package/node_modules/pi-smritikosh/python/smritikosh/engine/_context.py +148 -0
  31. package/node_modules/pi-smritikosh/python/smritikosh/engine/_decorators.py +116 -0
  32. package/node_modules/pi-smritikosh/python/smritikosh/engine/_engine.py +124 -0
  33. package/node_modules/pi-smritikosh/python/smritikosh/engine/_fingerprint.py +64 -0
  34. package/node_modules/pi-smritikosh/python/smritikosh/engine/_memo.py +121 -0
  35. package/node_modules/pi-smritikosh/python/smritikosh/exploration.py +23 -0
  36. package/node_modules/pi-smritikosh/python/smritikosh/exploration_cli.py +479 -0
  37. package/node_modules/pi-smritikosh/python/smritikosh/indexing/__init__.py +3 -0
  38. package/node_modules/pi-smritikosh/python/smritikosh/indexing/chunker.py +14 -0
  39. package/node_modules/pi-smritikosh/python/smritikosh/indexing/discovery.py +63 -0
  40. package/node_modules/pi-smritikosh/python/smritikosh/indexing/extractor.py +53 -0
  41. package/node_modules/pi-smritikosh/python/smritikosh/indexing/file_router.py +124 -0
  42. package/node_modules/pi-smritikosh/python/smritikosh/indexing/parser.py +48 -0
  43. package/node_modules/pi-smritikosh/python/smritikosh/indexing/pipeline/__init__.py +41 -0
  44. package/node_modules/pi-smritikosh/python/smritikosh/indexing/pipeline/_pipeline.py +275 -0
  45. package/node_modules/pi-smritikosh/python/smritikosh/indexing/pipeline/_router.py +49 -0
  46. package/node_modules/pi-smritikosh/python/smritikosh/indexing/pipeline/_stages.py +40 -0
  47. package/node_modules/pi-smritikosh/python/smritikosh/indexing/strategies/__init__.py +25 -0
  48. package/node_modules/pi-smritikosh/python/smritikosh/indexing/strategies/_helpers.py +250 -0
  49. package/node_modules/pi-smritikosh/python/smritikosh/indexing/strategies/ast.py +173 -0
  50. package/node_modules/pi-smritikosh/python/smritikosh/indexing/strategies/regex.py +64 -0
  51. package/node_modules/pi-smritikosh/python/smritikosh/indexing/strategies/section.py +739 -0
  52. package/node_modules/pi-smritikosh/python/smritikosh/indexing/vector_index.py +68 -0
  53. package/node_modules/pi-smritikosh/python/smritikosh/models/__init__.py +45 -0
  54. package/node_modules/pi-smritikosh/python/smritikosh/models/retrieval.py +158 -0
  55. package/node_modules/pi-smritikosh/python/smritikosh/models/types.py +111 -0
  56. package/node_modules/pi-smritikosh/python/smritikosh/ports/__init__.py +0 -0
  57. package/node_modules/pi-smritikosh/python/smritikosh/ports/embedder.py +85 -0
  58. package/node_modules/pi-smritikosh/python/smritikosh/ports/file_source.py +28 -0
  59. package/node_modules/pi-smritikosh/python/smritikosh/ports/retrieval.py +58 -0
  60. package/node_modules/pi-smritikosh/python/smritikosh/ports/source_reader.py +127 -0
  61. package/node_modules/pi-smritikosh/python/smritikosh/ports/storage.py +72 -0
  62. package/node_modules/pi-smritikosh/python/smritikosh/ports/vector_store.py +63 -0
  63. package/node_modules/pi-smritikosh/python/smritikosh/queries/__init__.py +5 -0
  64. package/node_modules/pi-smritikosh/python/smritikosh/queries/java/tags.scm +53 -0
  65. package/node_modules/pi-smritikosh/python/smritikosh/queries/javascript/tags.scm +78 -0
  66. package/node_modules/pi-smritikosh/python/smritikosh/queries/json/tags.scm +47 -0
  67. package/node_modules/pi-smritikosh/python/smritikosh/queries/kotlin/tags.scm +75 -0
  68. package/node_modules/pi-smritikosh/python/smritikosh/queries/markdown/tags.scm +23 -0
  69. package/node_modules/pi-smritikosh/python/smritikosh/queries/python/tags.scm +105 -0
  70. package/node_modules/pi-smritikosh/python/smritikosh/queries/typescript/tags.scm +88 -0
  71. package/node_modules/pi-smritikosh/python/smritikosh/retrieval/__init__.py +6 -0
  72. package/node_modules/pi-smritikosh/python/smritikosh/retrieval/definitions.py +118 -0
  73. package/node_modules/pi-smritikosh/python/smritikosh/retrieval/fusion.py +132 -0
  74. package/node_modules/pi-smritikosh/python/smritikosh/retrieval/hybrid.py +52 -0
  75. package/node_modules/pi-smritikosh/python/smritikosh/retrieval/priors.py +101 -0
  76. package/node_modules/pi-smritikosh/python/smritikosh/retrieval/selection.py +119 -0
  77. package/node_modules/pi-smritikosh/python/smritikosh/retrieval/service.py +107 -0
  78. package/node_modules/pi-smritikosh/python/smritikosh/retrieval/tokenizer.py +40 -0
  79. package/node_modules/pi-smritikosh/src/client.ts +153 -0
  80. package/node_modules/pi-smritikosh/src/commands.ts +67 -0
  81. package/node_modules/pi-smritikosh/src/config.ts +28 -0
  82. package/node_modules/pi-smritikosh/src/enforce.ts +70 -0
  83. package/node_modules/pi-smritikosh/src/indexer.ts +221 -0
  84. package/node_modules/pi-smritikosh/src/state.ts +9 -0
  85. package/node_modules/pi-smritikosh/src/tools.ts +291 -0
  86. package/node_modules/pi-smritikosh/src/ui.ts +219 -0
  87. package/package.json +42 -4
  88. package/src/dumbzone.ts +149 -0
  89. package/src/sessions.ts +95 -0
package/README.md CHANGED
@@ -1,3 +1,35 @@
1
- # Temporary Holding Version
1
+ # pi-tropos
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ τρόπος (tropos) — *way, manner, style*. My way of pi.
4
+
5
+ Personal pi customization bundle. One package, installable anywhere.
6
+
7
+ ## Features
8
+
9
+ - **Dumb-zone detection** — footer status `ctx Nk · N%`, colored dim → yellow → red
10
+ by the 100k-tokens / 40%-of-window rule (warns from 80% of that line).
11
+ When a run settles in the dumb zone, a one-time confirm offers to auto-run `/fresh`;
12
+ decline suppresses it until the session drops out of the dumb zone.
13
+ - **`/fresh`** — summarize the current session, edit the summary, continue in a fresh
14
+ session seeded with it. Old session preserved and linked via `parentSession`.
15
+ - **`/sessions [all]`** — browse and resume past sessions (project-scoped or everything).
16
+ Unnamed sessions are auto-named from the first user message.
17
+ - **pi-smritikosh** — semantic codebase search, bundled as a dependency. One install
18
+ gets everything; don't also install `npm:pi-smritikosh` separately or it loads twice.
19
+
20
+ ## Install
21
+
22
+ ```bash
23
+ pi install npm:pi-tropos # from npm
24
+ pi install git:github.com/devsarvesh92/pi-tropos # from git
25
+ pi -e /path/to/oh-my-pi # try once, no install
26
+ ```
27
+
28
+ ## Develop
29
+
30
+ ```bash
31
+ npm install
32
+ npm run typecheck
33
+ ```
34
+
35
+ No build step — pi loads the TypeScript directly.
package/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import smritikosh from "pi-smritikosh/index.js";
3
+ import dumbzone from "./src/dumbzone.js";
4
+ import sessions from "./src/sessions.js";
5
+
6
+ export default function (pi: ExtensionAPI) {
7
+ dumbzone(pi);
8
+ sessions(pi);
9
+ smritikosh(pi);
10
+ }
@@ -0,0 +1,92 @@
1
+ # pi-smritikosh
2
+
3
+ Semantic codebase exploration for the [pi coding agent](https://pi.dev), powered by
4
+ [smritikosh](https://github.com/smritikosh/smritikosh) — a semantic vector search CLI.
5
+
6
+ The smritikosh Python source is **vendored inside this package** (`python/`), so there is
7
+ nothing separate to install from PyPI. On first run it self-bootstraps into a
8
+ package-private venv using [uv](https://docs.astral.sh/uv/) (which brings its own Python).
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ pi install npm:pi-smritikosh # or: pi install /path/to/pi-smritikosh
14
+ ```
15
+
16
+ ## What you get
17
+
18
+ **Tools the agent uses automatically** (with system-prompt guidelines steering it to
19
+ prefer them over grep/read for exploration):
20
+
21
+ | Tool | Wraps | Purpose |
22
+ |---|---|---|
23
+ | `smritikosh_search` | `explore search` | 1–8 facet queries in, ranked file locations out |
24
+ | `smritikosh_chunks` | `explore chunks` | Read exact code ranges / outlines from those locations |
25
+ | `smritikosh_index` | `index` | Build or incrementally refresh a repo's index |
26
+
27
+ If a repo has no index, `smritikosh_search` builds one automatically first
28
+ (disable with `"autoIndex": false`).
29
+
30
+ **IntelliJ-style background indexing:** on session start, the extension checks
31
+ the current repo and builds or refreshes its index in the background — search
32
+ is ready before you ask your first question. A footer status shows progress.
33
+ With `"watch": true`, it instead keeps `smritikosh index -L` alive for the
34
+ session so the index tracks your file saves in real time (killed automatically
35
+ when the session ends). Searches issued while indexing is in flight wait for
36
+ the run rather than racing it.
37
+
38
+ **Search enforcement:** bash commands that search the repo (`grep`, `rg`, `ag`,
39
+ `ack`, `find`, `fd`, `tree` as command starters) are blocked with a message
40
+ redirecting the model to `smritikosh_search`. Piped uses (`npm test | grep FAIL`)
41
+ are not repo searches and stay allowed, as do `ls`/`cat`/`head` orientation
42
+ commands. For genuine literal-string searches the model may retry the identical
43
+ command once. Disable with `"enforceSearchTools": false`.
44
+
45
+ **Commands:**
46
+
47
+ - `/smritikosh-setup` — install the bundled CLI into the package venv (consent-gated, requires uv)
48
+ - `/smritikosh-status` — show resolved binary, version, and index status
49
+
50
+ **Terminal UI** (commandcode.ai-inspired): the footer shows a `⌘ smritikosh`
51
+ brand mark with an accent progress bar while indexing, and all three tools
52
+ render custom TUI output — indigo file paths, green result counts, dim line
53
+ numbers and facet tags, with collapsed summaries that expand via ctrl+e.
54
+
55
+ ## First run
56
+
57
+ 1. The extension resolves the binary in order: config `path` → `$SMRITIKOSH_BIN` →
58
+ package venv → `PATH` → `~/.local/bin/smritikosh`.
59
+ 2. If nothing is found, you get one warning per session; run `/smritikosh-setup` and
60
+ confirm — it runs `uv venv` + `uv pip install ./python` inside the package.
61
+ 3. If the CLI is absent, the tools degrade gracefully: they tell the agent to fall back
62
+ to grep/read instead of failing.
63
+
64
+ ## Config
65
+
66
+ `~/.pi/agent/pi-smritikosh.json`:
67
+
68
+ ```json
69
+ {
70
+ "path": "/custom/path/to/smritikosh",
71
+ "autoIndex": true,
72
+ "indexOnStart": true,
73
+ "watch": false,
74
+ "enforceSearchTools": true
75
+ }
76
+ ```
77
+
78
+ ## Updating the vendored smritikosh
79
+
80
+ ```bash
81
+ SMRITIKOSH_SRC=/path/to/smritikosh/repo npm run sync:smritikosh
82
+ ```
83
+
84
+ (Src defaults to `../smritikosh`.) Then bump `version` in `package.json` and republish.
85
+
86
+ ## Development
87
+
88
+ ```bash
89
+ npm install # dev deps for typechecking
90
+ npm run typecheck
91
+ pi -e . # try the extension without installing it
92
+ ```
@@ -0,0 +1,43 @@
1
+ /**
2
+ * pi-smritikosh
3
+ *
4
+ * Semantic codebase exploration for pi, powered by the smritikosh CLI.
5
+ * The CLI source is vendored under python/ and self-bootstraps into a
6
+ * package-private venv (via uv) on first run — see /smritikosh-setup.
7
+ *
8
+ * Config: ~/.pi/agent/pi-smritikosh.json ({ "path": "...", "autoIndex": true })
9
+ * Commands: /smritikosh-setup, /smritikosh-status
10
+ */
11
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
12
+ import { loadConfig } from "./src/config.js";
13
+ import type { SmritikoshState } from "./src/state.js";
14
+ import { registerSmritikoshCommands, resolveOnSessionStart } from "./src/commands.js";
15
+ import { registerSmritikoshTools } from "./src/tools.js";
16
+ import { indexOnSessionStart, stopIndexer } from "./src/indexer.js";
17
+ import { registerEnforcement } from "./src/enforce.js";
18
+
19
+ export default function (pi: ExtensionAPI) {
20
+ const state: SmritikoshState = {
21
+ config: loadConfig(),
22
+ bin: null,
23
+ warnedMissing: false,
24
+ };
25
+
26
+ pi.on("session_start", (_event, ctx) => {
27
+ state.config = loadConfig();
28
+ resolveOnSessionStart(state, ctx);
29
+ // IntelliJ-style: kick off background indexing immediately, never block startup.
30
+ indexOnSessionStart(state, ctx);
31
+ });
32
+
33
+ pi.on("session_shutdown", () => {
34
+ stopIndexer();
35
+ });
36
+
37
+ // Tools and commands are registered unconditionally at load time; the
38
+ // tools themselves gate on state.bin so they degrade gracefully when the
39
+ // CLI is not installed yet.
40
+ registerSmritikoshTools(pi, state);
41
+ registerSmritikoshCommands(pi, state);
42
+ registerEnforcement(pi, state);
43
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "pi-smritikosh",
3
+ "version": "0.2.3",
4
+ "description": "Semantic codebase exploration for pi via the smritikosh CLI — bundled, self-bootstrapping",
5
+ "type": "module",
6
+ "keywords": [
7
+ "pi-package",
8
+ "pi-coding-agent",
9
+ "semantic-search",
10
+ "code-search",
11
+ "exploration"
12
+ ],
13
+ "license": "MIT",
14
+ "files": [
15
+ "index.ts",
16
+ "src",
17
+ "python"
18
+ ],
19
+ "pi": {
20
+ "extensions": [
21
+ "./index.ts"
22
+ ]
23
+ },
24
+ "scripts": {
25
+ "typecheck": "tsc -p tsconfig.json",
26
+ "clean": "rm -rf python/build python/*.egg-info .venv",
27
+ "prepublishOnly": "rm -rf python/build python/*.egg-info && npm run typecheck",
28
+ "sync:smritikosh": "rsync -a --delete --exclude __pycache__ --exclude '*.egg-info' --exclude 'smritikosh.duckdb' \"${SMRITIKOSH_SRC:-../smritikosh}/smritikosh/\" python/smritikosh/ && cp \"${SMRITIKOSH_SRC:-../smritikosh}/pyproject.toml\" \"${SMRITIKOSH_SRC:-../smritikosh}/LICENSE\" python/"
29
+ },
30
+ "peerDependencies": {
31
+ "@earendil-works/pi-coding-agent": "*",
32
+ "@earendil-works/pi-tui": "*",
33
+ "typebox": "*"
34
+ },
35
+ "devDependencies": {
36
+ "@earendil-works/pi-coding-agent": "^0.86.1",
37
+ "@earendil-works/pi-tui": "^0.80.10",
38
+ "@types/node": "^22.20.4",
39
+ "typebox": "^1.3.27",
40
+ "typescript": "^5.9.3"
41
+ },
42
+ "engines": {
43
+ "node": ">=22.19.0"
44
+ }
45
+ }
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,137 @@
1
+ [project]
2
+ name = "smritikosh"
3
+ version = "0.3.0"
4
+ description = "Semantic vector search over a codebase"
5
+ readme = "README.md"
6
+ license = "Apache-2.0"
7
+ license-files = ["LICENSE"]
8
+ authors = [
9
+ { name = "Shantanu Vashishtha", email = "vashishthashantanu3@gmail.com" },
10
+ { name = "Sarvesh Sawant", email = "sarveshdev92@gmail.com" },
11
+ ]
12
+ keywords = [
13
+ "code-search",
14
+ "semantic-search",
15
+ "embeddings",
16
+ "tree-sitter",
17
+ "duckdb",
18
+ "vector-search",
19
+ "rag",
20
+ ]
21
+ classifiers = [
22
+ "Development Status :: 3 - Alpha",
23
+ "Environment :: Console",
24
+ "Intended Audience :: Developers",
25
+ "Operating System :: OS Independent",
26
+ "Programming Language :: Python :: 3",
27
+ "Programming Language :: Python :: 3.10",
28
+ "Programming Language :: Python :: 3.11",
29
+ "Programming Language :: Python :: 3.12",
30
+ "Programming Language :: Python :: 3.13",
31
+ "Topic :: Software Development :: Documentation",
32
+ "Topic :: Text Processing :: Indexing",
33
+ ]
34
+ requires-python = ">=3.10,<3.14"
35
+ dependencies = [
36
+ "click>=8.1",
37
+ "duckdb>=1.0",
38
+ # Vectors are handed to DuckDB as an Arrow FixedSizeListArray. Binding them
39
+ # as Python lists costs ~120 us per float, which made storing the vectors
40
+ # 75 % of an index run; Arrow is a contiguous buffer DuckDB ingests as-is.
41
+ "pyarrow>=15.0",
42
+ "numpy>=1.24",
43
+ # 1.0 renamed the gitignore pattern factory; "gitwildmatch" is deprecated.
44
+ "pathspec>=1.0",
45
+ # fastembed bundles ONNX Runtime — no PyTorch required, runs on any CPU.
46
+ "fastembed>=0.3",
47
+ "tree-sitter>=0.25",
48
+ # Pinned below 1.0: the 1.x line downloads grammar binaries at first use
49
+ # into a user cache. 0.x bundles all grammars in the wheel, so an install
50
+ # is deterministic, offline-safe, and covered by the lock file.
51
+ "tree-sitter-language-pack>=0.13,<1.0",
52
+ "truststore>=0.9",
53
+ "watchfiles>=0.21",
54
+ "toons>=0.7",
55
+ # Apple silicon installs its accelerated runtime automatically. Other
56
+ # platforms skip these dependencies and use the portable ONNX adapter.
57
+ "torch>=2.4 ; sys_platform == 'darwin' and platform_machine == 'arm64'",
58
+ "transformers>=4.40,<5 ; sys_platform == 'darwin' and platform_machine == 'arm64'",
59
+ "sentence-transformers>=3.0 ; sys_platform == 'darwin' and platform_machine == 'arm64'",
60
+ "einops>=0.7 ; sys_platform == 'darwin' and platform_machine == 'arm64'",
61
+ ]
62
+
63
+ [project.scripts]
64
+ smritikosh = "smritikosh.cli:main"
65
+
66
+ [project.urls]
67
+ Homepage = "https://github.com/smritikosh/smritikosh"
68
+ Repository = "https://github.com/smritikosh/smritikosh"
69
+ Issues = "https://github.com/smritikosh/smritikosh/issues"
70
+
71
+ # 77 is the first release that accepts the PEP 639 `license` expression and
72
+ # `license-files` above; earlier versions want the old license classifier.
73
+ [build-system]
74
+ requires = ["setuptools>=77"]
75
+ build-backend = "setuptools.build_meta"
76
+
77
+ [tool.setuptools.packages.find]
78
+ include = ["smritikosh*"]
79
+
80
+ # The per-language directories under queries/ are plain data directories, not
81
+ # packages, so packages.find does not reach them and the .scm files ship only
82
+ # because of this glob. `make check-wheel` guards it.
83
+ [tool.setuptools.package-data]
84
+ "smritikosh.queries" = ["**/*.scm"]
85
+
86
+ # ── Dev dependencies (PEP 735 — understood by both uv and Poetry 2.x) ─────────
87
+ [dependency-groups]
88
+ dev = [
89
+ "pytest>=9.1.1",
90
+ "pytest-asyncio>=1.0",
91
+ "pytest-cov>=6.0",
92
+ # Pinned exactly, and kept in step with .pre-commit-config.yaml: a
93
+ # formatter that drifts between the hook and CI reformats the tree on
94
+ # whichever one runs second.
95
+ "ruff==0.16.7",
96
+ "pre-commit>=4.6.2",
97
+ "duckdb>=1.0",
98
+ ]
99
+
100
+ # Both Mac architectures are supported, so the lock file must carry a
101
+ # resolution for each. uv otherwise resolves only for the machine that ran
102
+ # `uv lock`, which silently drops the other one: an Intel-only lock pins
103
+ # packages that lack macosx_x86_64 wheels (e.g. onnxruntime >= 1.24), while an
104
+ # arm64-only lock is uninstallable on Intel. Listing both keeps each arch on
105
+ # the newest version it has wheels for — currently onnxruntime 1.23.2 on
106
+ # x86_64 and 1.29.0 on arm64.
107
+ [tool.uv]
108
+ required-environments = [
109
+ "sys_platform == 'darwin' and platform_machine == 'x86_64'",
110
+ "sys_platform == 'darwin' and platform_machine == 'arm64'",
111
+ ]
112
+
113
+ [tool.pytest.ini_options]
114
+ testpaths = ["tests"]
115
+ asyncio_mode = "auto"
116
+ # importlib mode lets test files share a basename across directories.
117
+ addopts = "-v --import-mode=importlib"
118
+ markers = ["slow: loads the real embedding model; skip with -m 'not slow'"]
119
+
120
+ [tool.coverage.run]
121
+ source = ["smritikosh"]
122
+
123
+ [tool.coverage.report]
124
+ # Raised from 75 % → 90 % alongside cli, storage, and embedder test suites.
125
+ fail_under = 90
126
+ exclude_lines = [
127
+ "pragma: no cover",
128
+ "if TYPE_CHECKING:",
129
+ "\\.\\.\\.",
130
+ ]
131
+
132
+ [tool.ruff]
133
+ line-length = 88
134
+ target-version = "py310"
135
+
136
+ [tool.ruff.lint]
137
+ select = ["B", "E", "F", "I", "UP"]
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env python3
2
+ """Machine-readable progress wrapper around smritikosh's indexing pipeline.
3
+
4
+ Drives build_index() with the on_file_indexed callback and prints parseable
5
+ progress lines for the pi-smritikosh extension:
6
+
7
+ SMK total <n> — emitted once, after file discovery
8
+ SMK progress <done> <n> — emitted per indexed file
9
+ SMK done <seconds> — emitted on success
10
+ SMK error <message> — emitted on failure (exit code 1)
11
+
12
+ Usage: smk_progress.py REPO_PATH DB_PATH [--full]
13
+ """
14
+ import sys
15
+ import time
16
+
17
+
18
+ def main() -> int:
19
+ if len(sys.argv) < 3:
20
+ print("SMK error usage: smk_progress.py REPO_PATH DB_PATH [--full]", flush=True)
21
+ return 2
22
+
23
+ repo_path, db_path = sys.argv[1], sys.argv[2]
24
+ full = "--full" in sys.argv[3:]
25
+
26
+ try:
27
+ from smritikosh.adapters.embedder.resolver import (
28
+ EmbedderUnavailableError,
29
+ select_embedder,
30
+ )
31
+ from smritikosh.indexing.pipeline import build_index, count_source_files
32
+ from smritikosh.cli import _open_stores
33
+ except ImportError as exc:
34
+ print(f"SMK error failed to import smritikosh: {exc}", flush=True)
35
+ return 1
36
+
37
+ try:
38
+ embedder = select_embedder()
39
+ except EmbedderUnavailableError as exc:
40
+ print(f"SMK error {exc}", flush=True)
41
+ return 1
42
+
43
+ storage = None
44
+ try:
45
+ storage, vector_store = _open_stores(db_path)
46
+ total = count_source_files(repo_path)
47
+ print(f"SMK total {total}", flush=True)
48
+
49
+ state = {"done": 0}
50
+
51
+ def on_file_indexed(_path: str) -> None:
52
+ state["done"] += 1
53
+ print(f"SMK progress {state['done']} {total}", flush=True)
54
+
55
+ started = time.perf_counter()
56
+ build_index(
57
+ repo_path,
58
+ embedder,
59
+ storage,
60
+ vector_store,
61
+ on_file_indexed=on_file_indexed,
62
+ full=full,
63
+ )
64
+ elapsed = time.perf_counter() - started
65
+ print(f"SMK done {elapsed:.1f}", flush=True)
66
+ return 0
67
+ except Exception as exc: # surfaced to the extension for a clean warning
68
+ print(f"SMK error {exc}", flush=True)
69
+ return 1
70
+ finally:
71
+ if storage is not None:
72
+ try:
73
+ storage.close()
74
+ except Exception:
75
+ pass
76
+
77
+
78
+ if __name__ == "__main__":
79
+ sys.exit(main())
@@ -0,0 +1,11 @@
1
+ """Entry point for ``python -m smritikosh``.
2
+
3
+ The ``smritikosh`` console script only works when the installing environment's
4
+ ``bin`` directory is on PATH, which is not the case for ``pip install --user``
5
+ on macOS. Importing the package is enough to reach the CLI this way.
6
+ """
7
+
8
+ from smritikosh.cli import main
9
+
10
+ if __name__ == "__main__":
11
+ main()