@cesarandreslopez/occ 0.9.3 → 0.11.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 (165) hide show
  1. package/README.md +35 -6
  2. package/dist/src/cli.d.ts +16 -0
  3. package/dist/src/cli.js +46 -4
  4. package/dist/src/cli.js.map +1 -1
  5. package/dist/src/code/build.d.ts +22 -0
  6. package/dist/src/code/build.js +47 -13
  7. package/dist/src/code/build.js.map +1 -1
  8. package/dist/src/code/cache.js +30 -1
  9. package/dist/src/code/cache.js.map +1 -1
  10. package/dist/src/code/check.d.ts +39 -0
  11. package/dist/src/code/check.js +282 -0
  12. package/dist/src/code/check.js.map +1 -0
  13. package/dist/src/code/command.js +156 -64
  14. package/dist/src/code/command.js.map +1 -1
  15. package/dist/src/code/context.d.ts +54 -0
  16. package/dist/src/code/context.js +67 -0
  17. package/dist/src/code/context.js.map +1 -0
  18. package/dist/src/code/diff.d.ts +12 -2
  19. package/dist/src/code/diff.js +15 -3
  20. package/dist/src/code/diff.js.map +1 -1
  21. package/dist/src/code/discover.d.ts +2 -2
  22. package/dist/src/code/discover.js +8 -10
  23. package/dist/src/code/discover.js.map +1 -1
  24. package/dist/src/code/focus.js +34 -26
  25. package/dist/src/code/focus.js.map +1 -1
  26. package/dist/src/code/incremental.js +1 -1
  27. package/dist/src/code/incremental.js.map +1 -1
  28. package/dist/src/code/index-io.js +10 -2
  29. package/dist/src/code/index-io.js.map +1 -1
  30. package/dist/src/code/isolated-chunk-runner.js +17 -2
  31. package/dist/src/code/isolated-chunk-runner.js.map +1 -1
  32. package/dist/src/code/isolated-runner.js +17 -3
  33. package/dist/src/code/isolated-runner.js.map +1 -1
  34. package/dist/src/code/isolated.js +32 -6
  35. package/dist/src/code/isolated.js.map +1 -1
  36. package/dist/src/code/languages.d.ts +13 -0
  37. package/dist/src/code/languages.js +138 -5
  38. package/dist/src/code/languages.js.map +1 -1
  39. package/dist/src/code/map.d.ts +56 -0
  40. package/dist/src/code/map.js +161 -12
  41. package/dist/src/code/map.js.map +1 -1
  42. package/dist/src/code/parsers.js +367 -26
  43. package/dist/src/code/parsers.js.map +1 -1
  44. package/dist/src/code/preview.js +24 -22
  45. package/dist/src/code/preview.js.map +1 -1
  46. package/dist/src/code/query.js +0 -0
  47. package/dist/src/code/query.js.map +1 -1
  48. package/dist/src/code/search.d.ts +39 -0
  49. package/dist/src/code/search.js +154 -0
  50. package/dist/src/code/search.js.map +1 -0
  51. package/dist/src/code/session.d.ts +8 -2
  52. package/dist/src/code/session.js +16 -4
  53. package/dist/src/code/session.js.map +1 -1
  54. package/dist/src/code/slim.d.ts +2 -0
  55. package/dist/src/code/slim.js +16 -1
  56. package/dist/src/code/slim.js.map +1 -1
  57. package/dist/src/code/source.d.ts +44 -0
  58. package/dist/src/code/source.js +102 -0
  59. package/dist/src/code/source.js.map +1 -0
  60. package/dist/src/code/store.d.ts +23 -0
  61. package/dist/src/code/store.js +61 -6
  62. package/dist/src/code/store.js.map +1 -1
  63. package/dist/src/code/tree-sitter.d.ts +21 -0
  64. package/dist/src/code/tree-sitter.js +128 -0
  65. package/dist/src/code/tree-sitter.js.map +1 -0
  66. package/dist/src/code/types.d.ts +3 -0
  67. package/dist/src/code/types.js +2 -0
  68. package/dist/src/code/types.js.map +1 -1
  69. package/dist/src/doc/batch.d.ts +2 -0
  70. package/dist/src/doc/batch.js +3 -1
  71. package/dist/src/doc/batch.js.map +1 -1
  72. package/dist/src/doc/discover.js +2 -2
  73. package/dist/src/doc/discover.js.map +1 -1
  74. package/dist/src/doc/inspect-odt.js +3 -1
  75. package/dist/src/doc/inspect-odt.js.map +1 -1
  76. package/dist/src/doc/inspect-pdf.d.ts +6 -0
  77. package/dist/src/doc/inspect-pdf.js +11 -1
  78. package/dist/src/doc/inspect-pdf.js.map +1 -1
  79. package/dist/src/doc/inspect.js +2 -2
  80. package/dist/src/doc/inspect.js.map +1 -1
  81. package/dist/src/doc/types.d.ts +1 -0
  82. package/dist/src/doc/types.js +7 -0
  83. package/dist/src/doc/types.js.map +1 -1
  84. package/dist/src/git/api.d.ts +2 -1
  85. package/dist/src/git/api.js +15 -9
  86. package/dist/src/git/api.js.map +1 -1
  87. package/dist/src/git/client.js +5 -1
  88. package/dist/src/git/client.js.map +1 -1
  89. package/dist/src/git/output.js +2 -1
  90. package/dist/src/git/output.js.map +1 -1
  91. package/dist/src/git/parse.js +131 -2
  92. package/dist/src/git/parse.js.map +1 -1
  93. package/dist/src/git/types.d.ts +5 -5
  94. package/dist/src/health.d.ts +8 -0
  95. package/dist/src/health.js +12 -0
  96. package/dist/src/health.js.map +1 -1
  97. package/dist/src/index.d.ts +20 -6
  98. package/dist/src/index.js +13 -3
  99. package/dist/src/index.js.map +1 -1
  100. package/dist/src/inspect/xlsx-cells.js +4 -2
  101. package/dist/src/inspect/xlsx-cells.js.map +1 -1
  102. package/dist/src/markdown/convert.d.ts +9 -0
  103. package/dist/src/markdown/convert.js +23 -1
  104. package/dist/src/markdown/convert.js.map +1 -1
  105. package/dist/src/parsers/odf.js +4 -2
  106. package/dist/src/parsers/odf.js.map +1 -1
  107. package/dist/src/skills/command.d.ts +6 -0
  108. package/dist/src/skills/command.js +18 -3
  109. package/dist/src/skills/command.js.map +1 -1
  110. package/dist/src/slide/inspect-odp.js +3 -2
  111. package/dist/src/slide/inspect-odp.js.map +1 -1
  112. package/dist/src/slide/inspect-pptx.js +4 -3
  113. package/dist/src/slide/inspect-pptx.js.map +1 -1
  114. package/dist/src/stats.js +3 -1
  115. package/dist/src/stats.js.map +1 -1
  116. package/dist/src/structure/extract.js +16 -3
  117. package/dist/src/structure/extract.js.map +1 -1
  118. package/dist/src/utils.d.ts +7 -0
  119. package/dist/src/utils.js +19 -0
  120. package/dist/src/utils.js.map +1 -1
  121. package/dist/src/walker.js +15 -3
  122. package/dist/src/walker.js.map +1 -1
  123. package/dist/src/workspace/analyze.d.ts +3 -0
  124. package/dist/src/workspace/analyze.js +26 -15
  125. package/dist/src/workspace/analyze.js.map +1 -1
  126. package/dist/src/workspace/bundle.js +11 -3
  127. package/dist/src/workspace/bundle.js.map +1 -1
  128. package/dist/src/workspace/command.d.ts +6 -0
  129. package/dist/src/workspace/command.js +73 -44
  130. package/dist/src/workspace/command.js.map +1 -1
  131. package/dist/src/workspace/describe.js +22 -13
  132. package/dist/src/workspace/describe.js.map +1 -1
  133. package/dist/src/workspace/documents.d.ts +3 -0
  134. package/dist/src/workspace/documents.js +25 -14
  135. package/dist/src/workspace/documents.js.map +1 -1
  136. package/dist/src/workspace/prepare.js +3 -1
  137. package/dist/src/workspace/prepare.js.map +1 -1
  138. package/package.json +28 -12
  139. package/skills/occ/SKILL.md +17 -5
  140. package/skills/occ/reference/code.md +76 -3
  141. package/skills/occ/reference/commands.md +3 -1
  142. package/vendor/tree-sitter/c/grammar.wasm +0 -0
  143. package/vendor/tree-sitter/c/tags.scm +4 -0
  144. package/vendor/tree-sitter/c-sharp/grammar.wasm +0 -0
  145. package/vendor/tree-sitter/c-sharp/tags.scm +6 -0
  146. package/vendor/tree-sitter/cpp/grammar.wasm +0 -0
  147. package/vendor/tree-sitter/cpp/tags.scm +5 -0
  148. package/vendor/tree-sitter/go/grammar.wasm +0 -0
  149. package/vendor/tree-sitter/go/tags.scm +4 -0
  150. package/vendor/tree-sitter/java/grammar.wasm +0 -0
  151. package/vendor/tree-sitter/java/tags.scm +7 -0
  152. package/vendor/tree-sitter/kotlin/grammar.wasm +0 -0
  153. package/vendor/tree-sitter/kotlin/tags.scm +4 -0
  154. package/vendor/tree-sitter/php/grammar.wasm +0 -0
  155. package/vendor/tree-sitter/php/tags.scm +8 -0
  156. package/vendor/tree-sitter/python/grammar.wasm +0 -0
  157. package/vendor/tree-sitter/python/tags.scm +3 -0
  158. package/vendor/tree-sitter/ruby/grammar.wasm +0 -0
  159. package/vendor/tree-sitter/ruby/tags.scm +5 -0
  160. package/vendor/tree-sitter/rust/grammar.wasm +0 -0
  161. package/vendor/tree-sitter/rust/tags.scm +5 -0
  162. package/vendor/tree-sitter/scala/grammar.wasm +0 -0
  163. package/vendor/tree-sitter/scala/tags.scm +5 -0
  164. package/vendor/tree-sitter/swift/grammar.wasm +0 -0
  165. package/vendor/tree-sitter/swift/tags.scm +4 -0
@@ -1,7 +1,8 @@
1
1
  # Code exploration for agents
2
2
 
3
- `occ code` builds an in-memory code graph (no database, no daemon) for JS/TS,
4
- Vue SFC, and Python. Shared flags on every `code` subcommand: `--path
3
+ `occ code` builds an in-memory code graph (no database, no daemon) for JS/TS
4
+ and Vue SFC (type-accurate) plus Python, Go, Rust, Java, C/C++, C#, Kotlin,
5
+ Scala, Swift, Ruby, and PHP (tree-sitter). Shared flags on every `code` subcommand: `--path
5
6
  <repo-root>` (default cwd), `--format json`, `-o <file>`, `--exclude-dir`,
6
7
  `--no-gitignore`, `--content-mode none|excerpt|full`, `--max-file-size-bytes
7
8
  <n>`, `--max-lines <n>`.
@@ -41,6 +42,38 @@ occ code map --path . --changed-from main --map-tokens 4096 # diff-focused map
41
42
 
42
43
  All accept `--limit <n>` (default 50) and `--format json`.
43
44
 
45
+ ## Source reads — `occ code source`
46
+
47
+ Use `source` when you already know the symbol and need its exact body without
48
+ reading the whole file. Prefer this for named symbols; use `rg`/shell reads for
49
+ text, config, and quick facts.
50
+
51
+ ```bash
52
+ occ code map --path . --map-format json --map-tokens 4096 -o map.json
53
+ occ code source --path . --node-id "<nodeId>" --format json
54
+ occ code source bootstrap --path . --file src/main.ts --type function --format json
55
+ ```
56
+
57
+ JSON repo-map symbols include `nodeId`, `endLine`, and `containerName`. The
58
+ current node-id contract is OCC's existing graph id derived from the indexed
59
+ node: `<type>:<absolute-path>:<name>:<line>[:<containerName>]`. The line number
60
+ is part of the address, so ids can change after edits; re-run `code map` or
61
+ `code find name` after moving a symbol.
62
+
63
+ ## Syntax checks — `occ code check`
64
+
65
+ Use `check` as a lightweight post-edit parse gate before wider tests. It supports
66
+ TS/JS, Vue SFCs, Python, and the vendored tree-sitter languages (Go, Rust, Java,
67
+ C/C++, C#, Kotlin, Scala, Swift, Ruby, PHP); unsupported files exit 0 with
68
+ `status: "unsupported"` so they do not fail CI accidentally.
69
+
70
+ ```bash
71
+ occ code check src/main.ts --format json
72
+ occ code check src/App.vue --format json
73
+ ```
74
+
75
+ `occ code check` exits nonzero only when `valid` is `false`.
76
+
44
77
  ## Relationships — `occ code analyze <kind>`
45
78
 
46
79
  - `occ code analyze calls <fn>` — what a function calls (outgoing).
@@ -66,4 +99,44 @@ occ code history buildRepoMap --format json # git line history f
66
99
  ## Full index — `occ code index`
67
100
 
68
101
  Build/dump the full codebase index (files, symbols, edges, capabilities). Heavy;
69
- prefer `map`/`find`/`analyze` for targeted questions.
102
+ prefer `map`/`find`/`analyze` for targeted questions. Each `files[].symbols[]`
103
+ entry carries a `nodeId`, so a consumer can jump from a file symbol straight to
104
+ its graph node (and to `occ code source --node-id <id>`) without scanning
105
+ `nodes`.
106
+
107
+ ## Programmatic surface — for long-running hosts
108
+
109
+ Editor/agent integrations that embed `occ` — holding an index or a
110
+ `CodeQuerySession` across turns instead of shelling out per call — have
111
+ in-process equivalents for the verbs above, plus a few probes with no CLI:
112
+
113
+ - **`searchSymbols(index, query, { limit, kinds, pathFilter })`** /
114
+ `session.searchSymbols(...)` — fuzzy symbol search across name,
115
+ container-qualified name, and file path. Each result carries a `score`, the
116
+ matched `positions`/`span` (for highlighting), and a `nodeId` for a follow-up
117
+ source read. The corpus is memoized per index, so repeated queries in a
118
+ long-lived host pay the build once. Facade: `createOcc().code.searchSymbols`.
119
+ From the shell, reach for `occ code find` instead.
120
+ - **`buildCodeContext(index)`** / `session.projectContext()` — project a full or
121
+ slim index down to per-file exported symbols, a deduplicated local import
122
+ graph, and external dependency roots. Pure and synchronous; the shape hosts
123
+ hand to a model or a graph view. Facade: `createOcc().code.context`.
124
+ - **`buildChangedRepoMap(index, { changed: { base, head } | { staged: true }, ...mapOptions })`**
125
+ — the `--changed-from` map on the API: changed files join the focus set and
126
+ admitted entries carry `changed`/`churn`. `toRepoMapChangeContext` /
127
+ `stampRepoMapChanges` are exported for callers that already hold a diff
128
+ summary. Facade: `createOcc().code.mapChanged`.
129
+ - **`store.peekMetadata()` / `store.isFresh()`** — probe a persisted
130
+ `CodeIndexStore` without deserializing or parsing. `peekMetadata()` returns the
131
+ on-disk metadata (available before the first `getSession()` of a process);
132
+ `isFresh()` stat-diffs the working tree against the persisted manifest
133
+ (`added`/`modified`/`deleted` counts). Both validate the cache entry belongs to
134
+ this repo, options, and occ version — use them to decide whether to rebuild
135
+ before serving a session.
136
+ - **`health().features`** — a map of stable feature identifiers (e.g.
137
+ `code.searchSymbols`, `store.isFresh`, `code.map.changed`). Feature-detect
138
+ against it (`health.features?.['store.isFresh'] === true`) instead of
139
+ `typeof`-probing when a host must support multiple occ versions.
140
+
141
+ `createCodeQuerySession(options, onProgress?, signal?)` and
142
+ `session.refresh(onProgress?, signal?)` accept an `AbortSignal` for cancellation.
@@ -33,11 +33,13 @@ tabular|json`, `-o <file>`, and `--ci`.
33
33
 
34
34
  - `occ table inspect <file>` — Extract structured table data from DOCX, XLSX, PPTX, ODT, or ODP documents.
35
35
 
36
- ## `occ code` — Explore code structure with first-class JS/TS and Python support
36
+ ## `occ code` — Explore code structure (type-accurate JS/TS + Vue SFC, tree-sitter for 12 more languages)
37
37
 
38
38
  - `occ code map` — Token-budgeted, importance-ranked repo map (top symbol signatures per file).
39
39
  - `occ code pack` — Token-budgeted, importance-ranked pack (file content, optionally compressed).
40
40
  - `occ code index` — Build the full codebase index (files, symbols, edges, capabilities).
41
+ - `occ code source <name>` — Read one symbol body by node id (`--node-id`) or disambiguated name.
42
+ - `occ code check <file>` — Check a file's syntax without a language server (exits nonzero only when invalid).
41
43
  - `occ code find name <name>` — Find code elements by exact name.
42
44
  - `occ code find pattern <pattern>` — Find code elements by substring pattern.
43
45
  - `occ code find type <nodeType>` — List all nodes of a given type.
@@ -0,0 +1,4 @@
1
+ (function_definition) @definition.function
2
+ (struct_specifier) @definition.class
3
+ (enum_specifier) @definition.enum
4
+ (call_expression) @reference.call
@@ -0,0 +1,6 @@
1
+ (method_declaration) @definition.method
2
+ (constructor_declaration) @definition.method
3
+ (class_declaration) @definition.class
4
+ (interface_declaration) @definition.interface
5
+ (invocation_expression) @reference.call
6
+ (object_creation_expression) @reference.call
@@ -0,0 +1,5 @@
1
+ (function_definition) @definition.function
2
+ (class_specifier) @definition.class
3
+ (struct_specifier) @definition.class
4
+ (enum_specifier) @definition.enum
5
+ (call_expression) @reference.call
@@ -0,0 +1,4 @@
1
+ (function_declaration) @definition.function
2
+ (method_declaration) @definition.method
3
+ (type_declaration) @definition.type
4
+ (call_expression) @reference.call
@@ -0,0 +1,7 @@
1
+ (method_declaration) @definition.method
2
+ (constructor_declaration) @definition.method
3
+ (class_declaration) @definition.class
4
+ (interface_declaration) @definition.interface
5
+ (enum_declaration) @definition.enum
6
+ (method_invocation) @reference.call
7
+ (object_creation_expression) @reference.call
@@ -0,0 +1,4 @@
1
+ (function_declaration) @definition.function
2
+ (class_declaration) @definition.class
3
+ (object_declaration) @definition.class
4
+ (call_expression) @reference.call
@@ -0,0 +1,8 @@
1
+ (function_definition) @definition.function
2
+ (method_declaration) @definition.method
3
+ (class_declaration) @definition.class
4
+ (interface_declaration) @definition.interface
5
+ (trait_declaration) @definition.class
6
+ (function_call_expression) @reference.call
7
+ (member_call_expression) @reference.call
8
+ (scoped_call_expression) @reference.call
@@ -0,0 +1,3 @@
1
+ (function_definition) @definition.function
2
+ (class_definition) @definition.class
3
+ (call) @reference.call
@@ -0,0 +1,5 @@
1
+ (method) @definition.method
2
+ (singleton_method) @definition.method
3
+ (class) @definition.class
4
+ (module) @definition.class
5
+ (call) @reference.call
@@ -0,0 +1,5 @@
1
+ (function_item) @definition.function
2
+ (struct_item) @definition.class
3
+ (enum_item) @definition.enum
4
+ (trait_item) @definition.interface
5
+ (call_expression) @reference.call
@@ -0,0 +1,5 @@
1
+ (function_definition) @definition.function
2
+ (class_definition) @definition.class
3
+ (object_definition) @definition.class
4
+ (trait_definition) @definition.interface
5
+ (call_expression) @reference.call
@@ -0,0 +1,4 @@
1
+ (function_declaration) @definition.function
2
+ (class_declaration) @definition.class
3
+ (protocol_declaration) @definition.interface
4
+ (call_expression) @reference.call