@cesarandreslopez/occ 0.11.0 → 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 (61) hide show
  1. package/README.md +27 -6
  2. package/dist/src/code/command.js +162 -3
  3. package/dist/src/code/command.js.map +1 -1
  4. package/dist/src/code/diff.d.ts +2 -2
  5. package/dist/src/code/hash.d.ts +19 -0
  6. package/dist/src/code/hash.js +85 -0
  7. package/dist/src/code/hash.js.map +1 -0
  8. package/dist/src/code/output.d.ts +6 -1
  9. package/dist/src/code/output.js +78 -0
  10. package/dist/src/code/output.js.map +1 -1
  11. package/dist/src/code/query.d.ts +6 -0
  12. package/dist/src/code/query.js +0 -0
  13. package/dist/src/code/query.js.map +1 -1
  14. package/dist/src/code/seams.d.ts +39 -0
  15. package/dist/src/code/seams.js +154 -0
  16. package/dist/src/code/seams.js.map +1 -0
  17. package/dist/src/code/session.d.ts +7 -1
  18. package/dist/src/code/session.js +15 -0
  19. package/dist/src/code/session.js.map +1 -1
  20. package/dist/src/code/source.d.ts +10 -11
  21. package/dist/src/code/source.js +8 -2
  22. package/dist/src/code/source.js.map +1 -1
  23. package/dist/src/code/tree.d.ts +7 -0
  24. package/dist/src/code/tree.js +364 -0
  25. package/dist/src/code/tree.js.map +1 -0
  26. package/dist/src/code/types.d.ts +439 -0
  27. package/dist/src/code/types.js +146 -0
  28. package/dist/src/code/types.js.map +1 -1
  29. package/dist/src/git/api.d.ts +13 -1
  30. package/dist/src/git/api.js +22 -1
  31. package/dist/src/git/api.js.map +1 -1
  32. package/dist/src/git/client.d.ts +6 -0
  33. package/dist/src/git/client.js +12 -0
  34. package/dist/src/git/client.js.map +1 -1
  35. package/dist/src/git/command.js +22 -2
  36. package/dist/src/git/command.js.map +1 -1
  37. package/dist/src/git/output.d.ts +2 -1
  38. package/dist/src/git/output.js +5 -0
  39. package/dist/src/git/output.js.map +1 -1
  40. package/dist/src/git/parse.d.ts +2 -1
  41. package/dist/src/git/parse.js +97 -6
  42. package/dist/src/git/parse.js.map +1 -1
  43. package/dist/src/git/types.d.ts +44 -0
  44. package/dist/src/git/types.js +21 -0
  45. package/dist/src/git/types.js.map +1 -1
  46. package/dist/src/health.js +5 -0
  47. package/dist/src/health.js.map +1 -1
  48. package/dist/src/index.d.ts +16 -6
  49. package/dist/src/index.js +11 -3
  50. package/dist/src/index.js.map +1 -1
  51. package/dist/src/output/tabular.js +33 -16
  52. package/dist/src/output/tabular.js.map +1 -1
  53. package/dist/src/scc.d.ts +3 -0
  54. package/dist/src/scc.js +2 -0
  55. package/dist/src/scc.js.map +1 -1
  56. package/dist/src/workspace/types.d.ts +4 -0
  57. package/package.json +2 -1
  58. package/skills/occ/SKILL.md +31 -25
  59. package/skills/occ/reference/code.md +74 -1
  60. package/skills/occ/reference/commands.md +4 -0
  61. package/skills/occ/reference/git.md +17 -1
@@ -9,12 +9,12 @@ description: >-
9
9
  "occ sheet inspect", "occ slide inspect", and "occ table inspect"; and code
10
10
  exploration for JS/TS, Vue SFC, Python, Go, Rust, Java, C/C++, Kotlin, and
11
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
12
+ "occ code check", "occ code find", "occ code analyze", "occ code dirtree",
13
+ "occ code diff", and "occ git diff"/"occ git cochange". Reach for it whenever you need to understand a codebase or a set of
14
14
  office files without burning context reading everything, or whenever the user
15
15
  mentions occ.
16
16
  metadata:
17
- version: 0.11.0
17
+ version: 0.13.0
18
18
  license: MIT
19
19
  ---
20
20
 
@@ -49,27 +49,30 @@ Run `occ --help` or `occ <group> --help` to see every flag.
49
49
 
50
50
  ## Decision table — pick the right command
51
51
 
52
- | If you need to… | Start with | Deep reference |
53
- | ------------------------------------------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------ |
54
- | Tell what kind of project a directory is | `occ describe <dir> --format json` | [reference/workspace.md](reference/workspace.md) |
55
- | Inventory a whole workspace (code + docs + structure) | `occ workspace analyze <dir> --format json -o ws.json` | [reference/workspace.md](reference/workspace.md) |
56
- | Inventory / cross-reference office docs in a tree | `occ workspace documents <dir> --format json` | [reference/workspace.md](reference/workspace.md) |
57
- | Get document + code metrics for some directories | `occ <dirs> --format json --structure` | [reference/workspace.md](reference/workspace.md) |
58
- | Preflight one DOCX / PDF / ODT before reading it | `occ doc inspect <file> --format json` | [reference/documents.md](reference/documents.md) |
59
- | Preflight an XLSX workbook (schema, sheets, risks) | `occ sheet inspect <file> --format json` | [reference/documents.md](reference/documents.md) |
60
- | Preflight a PPTX / ODP deck | `occ slide inspect <file> --format json` | [reference/documents.md](reference/documents.md) |
61
- | Extract structured table data from a document | `occ table inspect <file> --format json` | [reference/documents.md](reference/documents.md) |
62
- | Pull entities/keywords (emails, URLs, dates) from a doc | `occ doc entities <file>` | [reference/documents.md](reference/documents.md) |
63
- | Get oriented in an unfamiliar codebase | `occ code map --path . --map-tokens 8000 --tokenizer o200k_base -o map.md` | [reference/code.md](reference/code.md) |
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) |
65
- | Find a symbol / concept (best-effort) | `occ code find fused "<query>" --format json` | [reference/code.md](reference/code.md) |
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) |
69
- | See who calls X / what X calls | `occ code analyze callers <fn>` · `occ code analyze calls <fn>` | [reference/code.md](reference/code.md) |
70
- | Inspect imports / module coupling | `occ code analyze deps <target>` · `occ code analyze coupling <target>` | [reference/code.md](reference/code.md) |
71
- | See which _symbols_ changed in a diff | `occ code diff --base <ref> --map-tokens 4096 --format json` | [reference/code.md](reference/code.md) |
72
- | List changed files / bounded patch / churn | `occ git changed` · `occ git diff --patch --map-tokens 2048` · `occ git churn` | [reference/git.md](reference/git.md) |
52
+ | If you need to… | Start with | Deep reference |
53
+ | ------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
54
+ | Tell what kind of project a directory is | `occ describe <dir> --format json` | [reference/workspace.md](reference/workspace.md) |
55
+ | Inventory a whole workspace (code + docs + structure) | `occ workspace analyze <dir> --format json -o ws.json` | [reference/workspace.md](reference/workspace.md) |
56
+ | Inventory / cross-reference office docs in a tree | `occ workspace documents <dir> --format json` | [reference/workspace.md](reference/workspace.md) |
57
+ | Get document + code metrics for some directories | `occ <dirs> --format json --structure` | [reference/workspace.md](reference/workspace.md) |
58
+ | Preflight one DOCX / PDF / ODT before reading it | `occ doc inspect <file> --format json` | [reference/documents.md](reference/documents.md) |
59
+ | Preflight an XLSX workbook (schema, sheets, risks) | `occ sheet inspect <file> --format json` | [reference/documents.md](reference/documents.md) |
60
+ | Preflight a PPTX / ODP deck | `occ slide inspect <file> --format json` | [reference/documents.md](reference/documents.md) |
61
+ | Extract structured table data from a document | `occ table inspect <file> --format json` | [reference/documents.md](reference/documents.md) |
62
+ | Pull entities/keywords (emails, URLs, dates) from a doc | `occ doc entities <file>` | [reference/documents.md](reference/documents.md) |
63
+ | Get oriented in an unfamiliar codebase | `occ code map --path . --map-tokens 8000 --tokenizer o200k_base -o map.md` | [reference/code.md](reference/code.md) |
64
+ | See an ignore-aware directory tree | `occ code dirtree --path . --mode map --format json` | [reference/code.md](reference/code.md) |
65
+ | 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) |
66
+ | Find a symbol / concept (best-effort) | `occ code find fused "<query>" --format json` | [reference/code.md](reference/code.md) |
67
+ | Find an exact symbol by name or type | `occ code find name <Name> --format json` | [reference/code.md](reference/code.md) |
68
+ | Read one known symbol body | `occ code source --node-id <nodeId> --format json` | [reference/code.md](reference/code.md) |
69
+ | Hash a symbol body / re-check it later for drift | `occ code symbol-hash --file <path> --name <name> --format json` | [reference/code.md](reference/code.md) |
70
+ | Check parse syntax after edits | `occ code check <file> --format json` | [reference/code.md](reference/code.md) |
71
+ | See who calls X / what X calls | `occ code analyze callers <fn>` · `occ code analyze calls <fn>` | [reference/code.md](reference/code.md) |
72
+ | Inspect imports / module coupling | `occ code analyze deps <target>` · `occ code analyze coupling <target>` | [reference/code.md](reference/code.md) |
73
+ | List / re-check cross-module seams (+ co-change) | `occ code seams --since "90 days ago" --format json` · `occ code seams --resolve <seamKey>` | [reference/code.md](reference/code.md) |
74
+ | See which _symbols_ changed in a diff | `occ code diff --base <ref> --map-tokens 4096 --format json` | [reference/code.md](reference/code.md) |
75
+ | List changed files / bounded patch / churn / co-change | `occ git changed` · `occ git diff --patch --map-tokens 2048` · `occ git churn` · `occ git cochange` | [reference/git.md](reference/git.md) |
73
76
 
74
77
  ## Recommended agent workflows
75
78
 
@@ -79,6 +82,9 @@ Run `occ --help` or `occ <group> --help` to see every flag.
79
82
  - **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
83
  - **Post-edit syntax gate:** run `occ code check <changed-file> --format json`; it exits nonzero only when `valid` is `false`.
81
84
  - **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.
85
+ - **Estimate blast radius:** `occ git cochange --target <path> --format json` for historically coupled files, then use `occ code dirtree --focus-path <dir> --mode map` for structural neighborhood context.
86
+ - **Pin a symbol, detect drift later:** `occ code symbol-hash --file <path> --name <name> --format json`, persist `key` + `bodyHash`, later rerun the same query — a changed hash means the body changed even if the symbol moved lines; `not_found`/`ambiguous` means the key itself drifted.
87
+ - **Map the strongest module relationships:** `occ code seams --since "90 days ago" --format json` ranks cross-module seams by co-change lift; persist `seamKey` and re-check with `occ code seams --resolve <seamKey>` (a `missing` answer is drift, not clean).
82
88
  - **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.
83
89
 
84
90
  ## Notes
@@ -86,4 +92,4 @@ Run `occ --help` or `occ <group> --help` to see every flag.
86
92
  - For the full flag list of every command, read [reference/commands.md](reference/commands.md).
87
93
  - Languages with first-class code support: JavaScript, TypeScript, Vue SFC, Python, Go, Rust, Java, C/C++, Kotlin, Ruby, PHP, C#, Scala, and Swift.
88
94
  - `--format json` is the integration surface; tabular output is for humans.
89
- - Embedding `occ` in a long-running host (an editor/agent integration that holds an index across turns)? The code graph also has an in-process API — fuzzy `searchSymbols`, index-to-context projection, changed-focus repo maps, store freshness probes, and a `health().features` map to feature-detect across versions. See the programmatic surface in [reference/code.md](reference/code.md).
95
+ - Embedding `occ` in a long-running host (an editor/agent integration that holds an index across turns)? The code graph also has an in-process API — fuzzy `searchSymbols`, index-to-context projection, changed-focus repo maps, directory trees, git co-change, store freshness probes, and a `health().features` map to feature-detect across versions. See the programmatic surface in [reference/code.md](reference/code.md).
@@ -31,6 +31,23 @@ occ code map --path . --query "auth token refresh" --focus-path src/auth --map-t
31
31
  occ code map --path . --changed-from main --map-tokens 4096 # diff-focused map
32
32
  ```
33
33
 
34
+ ## Directory tree — `occ code dirtree`
35
+
36
+ Bounded, ignore-aware tree derived from the built code index, not from a raw
37
+ filesystem walk. Use this when you need package/folder shape plus truncation
38
+ breadcrumbs for drill-in.
39
+
40
+ ```bash
41
+ occ code dirtree --path . --format json
42
+ occ code dirtree --path . --mode map --map-tokens 4096 --tokenizer o200k_base
43
+ occ code dirtree --path . --focus-path src/code --depth 4 --max-entries 25
44
+ ```
45
+
46
+ Modes: `compact` (default, collapses single-child directory chains), `verbose`,
47
+ and `map` (compact plus top symbol signatures from the highest-ranked file per
48
+ directory). JSON output includes `truncatedPaths`; call again with
49
+ `--focus-path <path>` and higher caps to drill into an elided subtree.
50
+
34
51
  ## Search — `occ code find <mode>`
35
52
 
36
53
  - `occ code find fused "<query>"` — combines name + pattern + content search with
@@ -60,6 +77,25 @@ node: `<type>:<absolute-path>:<name>:<line>[:<containerName>]`. The line number
60
77
  is part of the address, so ids can change after edits; re-run `code map` or
61
78
  `code find name` after moving a symbol.
62
79
 
80
+ ## Symbol drift — `occ code symbol-hash`
81
+
82
+ Hash symbol bodies by a stable, line-independent key
83
+ (`{relativePath, name, kind?, containerName?}`). Node ids embed the line, so
84
+ they churn on any edit above the symbol; symbol keys do not. Persist the
85
+ returned `bodyHash` (frozen contract: full 64-hex sha256 of the exact source
86
+ span) and rerun the same query later — a different hash means the body changed.
87
+
88
+ ```bash
89
+ occ code symbol-hash --path . --file src/main.ts --name bootstrap --format json
90
+ occ code symbol-hash --path . --queries-json queries.json --format json # batch; - reads stdin
91
+ ```
92
+
93
+ Per-query statuses: `resolved` / `not_found` / `ambiguous` (with candidates —
94
+ add `--kind` or `--container` to disambiguate) / `error`. Batch entries are
95
+ independent; results align positionally with the queries. Any non-resolved
96
+ result exits nonzero. `spanExact: false` means the parser only gave a
97
+ declaration line (regex-fallback languages) — fall back to file-level hashing.
98
+
63
99
  ## Syntax checks — `occ code check`
64
100
 
65
101
  Use `check` as a lightweight post-edit parse gate before wider tests. It supports
@@ -86,6 +122,26 @@ occ code check src/App.vue --format json
86
122
  `calls`/`callers`/`tree` accept `--file <path>` to disambiguate. Relationships
87
123
  report `resolved` / `ambiguous` / `unresolved` status explicitly.
88
124
 
125
+ ## Seams — `occ code seams`
126
+
127
+ Enumerate cross-module seams: import/call edges between directory-modules,
128
+ optionally weighted by git co-change. Use it to find the strongest ungoverned
129
+ relationships in a repo and to durably reference one.
130
+
131
+ ```bash
132
+ occ code seams --path . --since "90 days ago" --limit 20 --format json
133
+ occ code seams --path . --resolve "seam:src::src/code" --format json
134
+ ```
135
+
136
+ Each seam carries `seamKey` (`seam:` + both modules sorted, `::`-joined),
137
+ `importEdgeCount`, `callEdgeCount`, optional `cochange {count, lift,
138
+ lastCochangedAt}`, and `rank`. `--since` aggregates co-change over full HEAD
139
+ history bounded by the window and works with `--path` below the git toplevel.
140
+ `--min-lift <n>` filters by lift (needs `--since`); `--resolve` answers
141
+ `resolved`/`missing` per key and exits nonzero when anything is missing. A
142
+ directory rename changes the key by design — treat `missing` as drift, never
143
+ as clean.
144
+
89
145
  ## Change-aware — `occ code diff` / `occ code history`
90
146
 
91
147
  ```bash
@@ -126,6 +182,23 @@ in-process equivalents for the verbs above, plus a few probes with no CLI:
126
182
  admitted entries carry `changed`/`churn`. `toRepoMapChangeContext` /
127
183
  `stampRepoMapChanges` are exported for callers that already hold a diff
128
184
  summary. Facade: `createOcc().code.mapChanged`.
185
+ - **`buildDirectoryTree(index, options)`** / `session.getDirectoryTree(options)`
186
+ / `createOcc().code.directoryTree(index, options)` — bounded directory tree
187
+ over indexed files, with `compact`/`verbose`/`map` modes and
188
+ `truncatedPaths` drill-in hints.
189
+ - **`hashCodeSymbols(index, queries, options?)`** / `session.hashSymbols(...)`
190
+ — the batch body-hash primitive behind `occ code symbol-hash`. Facade:
191
+ `createOcc().code.symbolHash`. Gate on
192
+ `health.features?.['code.symbol.bodyHash'] === true`.
193
+ - **`listCodeSeams(index, { cochange?, minLift?, limit? })`** /
194
+ `resolveCodeSeams(index, seamKeys, options?)` / `session.seams(...)` /
195
+ `session.resolveSeams(...)` — seam enumeration and freshness checks. Pure:
196
+ pass a `GitCochangeSummary` from `getGitCochange` to attach co-change (use
197
+ `scope: 'history'` with `since` for a windowed history join, and
198
+ `rebaseCochangeToIndexRoot(summary, prefix)` when the index root sits below
199
+ the git toplevel — git paths are toplevel-relative). Facade:
200
+ `createOcc().code.seams` / `.resolveSeams`; `seamKeyFor(moduleA, moduleB)` is
201
+ exported for key construction. Gate on `health.features?.['code.seams']`.
129
202
  - **`store.peekMetadata()` / `store.isFresh()`** — probe a persisted
130
203
  `CodeIndexStore` without deserializing or parsing. `peekMetadata()` returns the
131
204
  on-disk metadata (available before the first `getSession()` of a process);
@@ -134,7 +207,7 @@ in-process equivalents for the verbs above, plus a few probes with no CLI:
134
207
  this repo, options, and occ version — use them to decide whether to rebuild
135
208
  before serving a session.
136
209
  - **`health().features`** — a map of stable feature identifiers (e.g.
137
- `code.searchSymbols`, `store.isFresh`, `code.map.changed`). Feature-detect
210
+ `code.searchSymbols`, `code.directoryTree`, `store.isFresh`, `code.map.changed`). Feature-detect
138
211
  against it (`health.features?.['store.isFresh'] === true`) instead of
139
212
  `typeof`-probing when a host must support multiple occ versions.
140
213
 
@@ -39,7 +39,9 @@ tabular|json`, `-o <file>`, and `--ci`.
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
41
  - `occ code source <name>` — Read one symbol body by node id (`--node-id`) or disambiguated name.
42
+ - `occ code symbol-hash` — Hash symbol bodies by stable line-independent key (sha256 of the exact source span).
42
43
  - `occ code check <file>` — Check a file's syntax without a language server (exits nonzero only when invalid).
44
+ - `occ code dirtree` — Render a bounded directory tree from the built code index.
43
45
  - `occ code find name <name>` — Find code elements by exact name.
44
46
  - `occ code find pattern <pattern>` — Find code elements by substring pattern.
45
47
  - `occ code find type <nodeType>` — List all nodes of a given type.
@@ -51,6 +53,7 @@ tabular|json`, `-o <file>`, and `--ci`.
51
53
  - `occ code analyze deps <target>` — Show module/file import relationships.
52
54
  - `occ code analyze coupling <target>` — Show module-level coupling metrics.
53
55
  - `occ code analyze tree <className>` — Show class/interface inheritance relationships.
56
+ - `occ code seams` — Enumerate cross-module seams (`--since` joins co-change, `--resolve` re-checks keys).
54
57
  - `occ code diff` — Show changed symbols for a git diff range.
55
58
  - `occ code history <symbol>` — Show git line history for a symbol.
56
59
 
@@ -60,6 +63,7 @@ tabular|json`, `-o <file>`, and `--ci`.
60
63
  - `occ git diff` — Summarize or render the resolved diff (`--patch` for a bounded raw patch).
61
64
  - `occ git history [file]` — Show commit history for a range or file.
62
65
  - `occ git churn` — Rank changed files by churn.
66
+ - `occ git cochange` — Rank file pairs that historically change together (count + lift).
63
67
 
64
68
  ## `occ skills` — Install and inspect the Agent Skills bundled with occ
65
69
 
@@ -1,6 +1,6 @@
1
1
  # Git context
2
2
 
3
- Inspect git changes, history, and churn. Shared flags: `--path <repo-root>`
3
+ Inspect git changes, history, churn, and file-level co-change. Shared flags: `--path <repo-root>`
4
4
  (default cwd), `--base <ref>`, `--head <ref>`, `--staged`, `--format
5
5
  tabular|json`, `-o <file>`. The diff range is resolved from `--base`/`--head`/
6
6
  `--staged` (defaults to the working-tree changes when unspecified).
@@ -49,6 +49,22 @@ occ git churn --sort churn --limit 20 --format json
49
49
  Flags: `--sort churn|commits|added|deleted|net` (default churn), `--limit <n>`,
50
50
  `--since <date>`.
51
51
 
52
+ ## `occ git cochange`
53
+
54
+ Rank file pairs that historically change together. Use this for file-level
55
+ blast-radius hints before editing a known path.
56
+
57
+ ```bash
58
+ occ git cochange --limit 20 --format json
59
+ occ git cochange --target src/cli.ts --format json
60
+ occ git cochange --since 2025-01-01 --max-commit-files 30
61
+ ```
62
+
63
+ Flags: `--limit <n>`, `--since <date>`, `--target <path>`, and
64
+ `--max-commit-files <n>` (default 50). JSON pairs include `fileA`, `fileB`,
65
+ `count`, `lift`, and `lastCochangedAt`. Co-change is file-level only; use
66
+ `occ code diff` for symbol-level changed-code context.
67
+
52
68
  ## Symbol-level changes
53
69
 
54
70
  To see which _symbols_ (not just files/lines) changed, use `occ code diff`