@cesarandreslopez/occ 0.9.3 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -3
- package/dist/src/code/check.d.ts +39 -0
- package/dist/src/code/check.js +242 -0
- package/dist/src/code/check.js.map +1 -0
- package/dist/src/code/command.js +64 -0
- package/dist/src/code/command.js.map +1 -1
- package/dist/src/code/languages.d.ts +13 -0
- package/dist/src/code/languages.js +115 -2
- package/dist/src/code/languages.js.map +1 -1
- package/dist/src/code/map.d.ts +9 -0
- package/dist/src/code/map.js +6 -0
- package/dist/src/code/map.js.map +1 -1
- package/dist/src/code/parsers.js +262 -0
- package/dist/src/code/parsers.js.map +1 -1
- package/dist/src/code/session.d.ts +2 -0
- package/dist/src/code/session.js +4 -0
- package/dist/src/code/session.js.map +1 -1
- package/dist/src/code/source.d.ts +44 -0
- package/dist/src/code/source.js +102 -0
- package/dist/src/code/source.js.map +1 -0
- package/dist/src/code/tree-sitter.d.ts +20 -0
- package/dist/src/code/tree-sitter.js +127 -0
- package/dist/src/code/tree-sitter.js.map +1 -0
- package/dist/src/index.d.ts +7 -1
- package/dist/src/index.js +5 -1
- package/dist/src/index.js.map +1 -1
- package/package.json +18 -2
- package/skills/occ/SKILL.md +16 -5
- package/skills/occ/reference/code.md +35 -2
- package/skills/occ/reference/commands.md +3 -1
- package/vendor/tree-sitter/c/grammar.wasm +0 -0
- package/vendor/tree-sitter/c/tags.scm +4 -0
- package/vendor/tree-sitter/c-sharp/grammar.wasm +0 -0
- package/vendor/tree-sitter/c-sharp/tags.scm +6 -0
- package/vendor/tree-sitter/cpp/grammar.wasm +0 -0
- package/vendor/tree-sitter/cpp/tags.scm +5 -0
- package/vendor/tree-sitter/go/grammar.wasm +0 -0
- package/vendor/tree-sitter/go/tags.scm +4 -0
- package/vendor/tree-sitter/java/grammar.wasm +0 -0
- package/vendor/tree-sitter/java/tags.scm +7 -0
- package/vendor/tree-sitter/kotlin/grammar.wasm +0 -0
- package/vendor/tree-sitter/kotlin/tags.scm +4 -0
- package/vendor/tree-sitter/php/grammar.wasm +0 -0
- package/vendor/tree-sitter/php/tags.scm +8 -0
- package/vendor/tree-sitter/python/grammar.wasm +0 -0
- package/vendor/tree-sitter/python/tags.scm +3 -0
- package/vendor/tree-sitter/ruby/grammar.wasm +0 -0
- package/vendor/tree-sitter/ruby/tags.scm +5 -0
- package/vendor/tree-sitter/rust/grammar.wasm +0 -0
- package/vendor/tree-sitter/rust/tags.scm +5 -0
- package/vendor/tree-sitter/scala/grammar.wasm +0 -0
- package/vendor/tree-sitter/scala/tags.scm +5 -0
- package/vendor/tree-sitter/swift/grammar.wasm +0 -0
- package/vendor/tree-sitter/swift/tags.scm +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cesarandreslopez/occ",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Office Cloc and Count — document metrics, structure extraction, content inspection, and code exploration for real repositories",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/src/index.js",
|
|
@@ -108,6 +108,14 @@
|
|
|
108
108
|
"types": "./dist/src/code/diff.d.ts",
|
|
109
109
|
"default": "./dist/src/code/diff.js"
|
|
110
110
|
},
|
|
111
|
+
"./code/source": {
|
|
112
|
+
"types": "./dist/src/code/source.d.ts",
|
|
113
|
+
"default": "./dist/src/code/source.js"
|
|
114
|
+
},
|
|
115
|
+
"./code/check": {
|
|
116
|
+
"types": "./dist/src/code/check.d.ts",
|
|
117
|
+
"default": "./dist/src/code/check.js"
|
|
118
|
+
},
|
|
111
119
|
"./git": {
|
|
112
120
|
"types": "./dist/src/git/index.d.ts",
|
|
113
121
|
"default": "./dist/src/git/index.js"
|
|
@@ -282,6 +290,12 @@
|
|
|
282
290
|
"code/diff": [
|
|
283
291
|
"dist/src/code/diff.d.ts"
|
|
284
292
|
],
|
|
293
|
+
"code/source": [
|
|
294
|
+
"dist/src/code/source.d.ts"
|
|
295
|
+
],
|
|
296
|
+
"code/check": [
|
|
297
|
+
"dist/src/code/check.d.ts"
|
|
298
|
+
],
|
|
285
299
|
"git": [
|
|
286
300
|
"dist/src/git/index.d.ts"
|
|
287
301
|
],
|
|
@@ -386,7 +400,8 @@
|
|
|
386
400
|
"files": [
|
|
387
401
|
"dist/",
|
|
388
402
|
"scripts/postinstall.js",
|
|
389
|
-
"skills/"
|
|
403
|
+
"skills/",
|
|
404
|
+
"vendor/tree-sitter/"
|
|
390
405
|
],
|
|
391
406
|
"publishConfig": {
|
|
392
407
|
"access": "public"
|
|
@@ -415,6 +430,7 @@
|
|
|
415
430
|
"pdf-parse": "^1.1.4",
|
|
416
431
|
"turndown": "^7.2.2",
|
|
417
432
|
"typescript": "^5.9.3",
|
|
433
|
+
"web-tree-sitter": "^0.26.10",
|
|
418
434
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
|
|
419
435
|
"zod": "^4.3.6"
|
|
420
436
|
},
|
package/skills/occ/SKILL.md
CHANGED
|
@@ -7,13 +7,14 @@ description: >-
|
|
|
7
7
|
with "occ describe" and "occ workspace analyze"; office-document and table
|
|
8
8
|
triage for DOCX, PDF, XLSX, PPTX, ODT, ODS, and ODP with "occ doc inspect",
|
|
9
9
|
"occ sheet inspect", "occ slide inspect", and "occ table inspect"; and code
|
|
10
|
-
exploration for JS/TS, Vue SFC,
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
exploration for JS/TS, Vue SFC, Python, Go, Rust, Java, C/C++, Kotlin, and
|
|
11
|
+
other tree-sitter-backed languages with "occ code map", "occ code source",
|
|
12
|
+
"occ code check", "occ code find", "occ code analyze", "occ code diff", and
|
|
13
|
+
"occ git diff". Reach for it whenever you need to understand a codebase or a set of
|
|
13
14
|
office files without burning context reading everything, or whenever the user
|
|
14
15
|
mentions occ.
|
|
15
16
|
metadata:
|
|
16
|
-
version: 0.
|
|
17
|
+
version: 0.10.0
|
|
17
18
|
license: MIT
|
|
18
19
|
---
|
|
19
20
|
|
|
@@ -30,6 +31,10 @@ Design principles to lean on:
|
|
|
30
31
|
- **Token-budgeted** — `occ code map/pack` and `occ code diff` accept `--map-tokens <n>`
|
|
31
32
|
(and the root scan accepts `--token-budget <n>`). Pair with `--tokenizer o200k_base`
|
|
32
33
|
(or `cl100k_base`) for an _exact_ BPE budget instead of the default heuristic estimate.
|
|
34
|
+
- **Structural for named symbols/relations, shell for text/config/quick facts** — use
|
|
35
|
+
`occ code map`, `occ code find name`, `occ code source`, and `occ code analyze callers`
|
|
36
|
+
when the target is a symbol, call path, class tree, or import relationship. Use `rg`,
|
|
37
|
+
`grep`, or direct file reads for strings, config keys, generated files, and one-off facts.
|
|
33
38
|
- **Stream large output to a file** — for big maps/packs/analyses, add `-o <file>` and
|
|
34
39
|
read it back selectively rather than flooding the conversation.
|
|
35
40
|
|
|
@@ -59,6 +64,8 @@ Run `occ --help` or `occ <group> --help` to see every flag.
|
|
|
59
64
|
| Pull file _contents_ within a token budget | `occ code pack --path . --map-tokens 8000 --tokenizer o200k_base -o pack.md` | [reference/code.md](reference/code.md) |
|
|
60
65
|
| Find a symbol / concept (best-effort) | `occ code find fused "<query>" --format json` | [reference/code.md](reference/code.md) |
|
|
61
66
|
| Find an exact symbol by name or type | `occ code find name <Name> --format json` | [reference/code.md](reference/code.md) |
|
|
67
|
+
| Read one known symbol body | `occ code source --node-id <nodeId> --format json` | [reference/code.md](reference/code.md) |
|
|
68
|
+
| Check parse syntax after edits | `occ code check <file> --format json` | [reference/code.md](reference/code.md) |
|
|
62
69
|
| See who calls X / what X calls | `occ code analyze callers <fn>` · `occ code analyze calls <fn>` | [reference/code.md](reference/code.md) |
|
|
63
70
|
| Inspect imports / module coupling | `occ code analyze deps <target>` · `occ code analyze coupling <target>` | [reference/code.md](reference/code.md) |
|
|
64
71
|
| See which _symbols_ changed in a diff | `occ code diff --base <ref> --map-tokens 4096 --format json` | [reference/code.md](reference/code.md) |
|
|
@@ -67,11 +74,15 @@ Run `occ --help` or `occ <group> --help` to see every flag.
|
|
|
67
74
|
## Recommended agent workflows
|
|
68
75
|
|
|
69
76
|
- **Land in a new repo:** `occ describe . --format json` → `occ code map --path . --map-tokens 8000 --tokenizer o200k_base -o map.md`, read the map, then drill in with `occ code find` / `occ code analyze`.
|
|
77
|
+
- **Read a symbol precisely:** `occ code map --map-format json` → take `nodeId` from the relevant symbol → `occ code source --node-id <nodeId> --format json`.
|
|
78
|
+
- **Find name then read:** `occ code find name TypeName --format json` → if one match, `occ code source --node-id <nodeId>`; if ambiguous, rerun with `--file` or `--type`.
|
|
79
|
+
- **Trace impact:** `occ code analyze callers targetFn --format json` before broad text search; use candidates and valid node kinds from ambiguous output to refine the query.
|
|
80
|
+
- **Post-edit syntax gate:** run `occ code check <changed-file> --format json`; it exits nonzero only when `valid` is `false`.
|
|
70
81
|
- **Review a change:** `occ git changed` → `occ code diff --base <base> --format json` for symbol-level scope → `occ git diff --patch --map-tokens 4096` for a bounded patch.
|
|
71
82
|
- **Process a document drop:** `occ <dir> --format json` for the inventory → `occ doc/sheet/slide inspect --format json` per file → `occ table inspect` to pull tabular data → read only what matters.
|
|
72
83
|
|
|
73
84
|
## Notes
|
|
74
85
|
|
|
75
86
|
- For the full flag list of every command, read [reference/commands.md](reference/commands.md).
|
|
76
|
-
- Languages with first-class code support: JavaScript, TypeScript, Vue SFC, and
|
|
87
|
+
- Languages with first-class code support: JavaScript, TypeScript, Vue SFC, Python, Go, Rust, Java, C/C++, Kotlin, Ruby, PHP, C#, Scala, and Swift.
|
|
77
88
|
- `--format json` is the integration surface; tabular output is for humans.
|
|
@@ -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
|
|
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).
|
|
@@ -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
|
|
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.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -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
|
|
Binary file
|
|
Binary file
|
|
@@ -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
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|