@codechart/core 0.3.0 → 0.7.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 +7 -3
- package/THIRD_PARTY_NOTICES.md +203 -1
- package/dist/grammars/python-tags.scm +14 -0
- package/dist/grammars/tree-sitter-bash.wasm +0 -0
- package/dist/grammars/tree-sitter-css.wasm +0 -0
- package/dist/grammars/tree-sitter-html.wasm +0 -0
- package/dist/grammars/tree-sitter-json.wasm +0 -0
- package/dist/grammars/tree-sitter-python.wasm +0 -0
- package/dist/grammars/tree-sitter-sql.wasm +0 -0
- package/dist/grammars/tree-sitter-yaml.wasm +0 -0
- package/dist/index.d.ts +294 -13
- package/dist/index.js +3634 -523
- package/package.json +7 -1
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,8 @@ type ValidationResult$1<T> = {
|
|
|
54
54
|
ok: false;
|
|
55
55
|
errors: string[];
|
|
56
56
|
};
|
|
57
|
+
/** `s` in double quotes, with control and invisible characters as `\uXXXX`, so it can't break or reorder an error line. */
|
|
58
|
+
declare const quotedVisible: (s: string) => string;
|
|
57
59
|
declare function formatPath(path: PropertyKey[]): string;
|
|
58
60
|
declare function formatIssues(error: z.ZodError): string[];
|
|
59
61
|
|
|
@@ -827,6 +829,86 @@ interface Config {
|
|
|
827
829
|
ignore: string[];
|
|
828
830
|
rules: Rule[];
|
|
829
831
|
}
|
|
832
|
+
/** What a map rule can make of code (Code model #4). */
|
|
833
|
+
declare const MAP_ENTITY_KINDS: readonly ["table", "model", "service", "endpoint", "component", "config"];
|
|
834
|
+
type MapEntityKind = (typeof MAP_ENTITY_KINDS)[number];
|
|
835
|
+
/** Prefix of a folder box's id: `folder:src/payments`. */
|
|
836
|
+
declare const FOLDER_BOX_PREFIX = "folder:";
|
|
837
|
+
/** Which pinned id this is, by syntax alone: `::` makes a node, a `folder:` prefix a folder box, else a rule box slug. */
|
|
838
|
+
declare function pinnedIdKind(id: string): 'node' | 'folder' | 'rule-box' | undefined;
|
|
839
|
+
declare const mapRuleSchema: z.ZodObject<{
|
|
840
|
+
paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
841
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
842
|
+
lang: z.ZodOptional<z.ZodEnum<{
|
|
843
|
+
typescript: "typescript";
|
|
844
|
+
javascript: "javascript";
|
|
845
|
+
python: "python";
|
|
846
|
+
html: "html";
|
|
847
|
+
css: "css";
|
|
848
|
+
sql: "sql";
|
|
849
|
+
bash: "bash";
|
|
850
|
+
yaml: "yaml";
|
|
851
|
+
json: "json";
|
|
852
|
+
}>>;
|
|
853
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
854
|
+
config: "config";
|
|
855
|
+
table: "table";
|
|
856
|
+
model: "model";
|
|
857
|
+
service: "service";
|
|
858
|
+
endpoint: "endpoint";
|
|
859
|
+
component: "component";
|
|
860
|
+
}>>;
|
|
861
|
+
box: z.ZodOptional<z.ZodString>;
|
|
862
|
+
ignore: z.ZodOptional<z.ZodLiteral<true>>;
|
|
863
|
+
}, z.core.$strict>;
|
|
864
|
+
declare const pinnedEntrySchema: z.ZodObject<{
|
|
865
|
+
name: z.ZodString;
|
|
866
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
867
|
+
}, z.core.$strict>;
|
|
868
|
+
declare const mapSchema: z.ZodObject<{
|
|
869
|
+
rules: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
870
|
+
paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
871
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
872
|
+
lang: z.ZodOptional<z.ZodEnum<{
|
|
873
|
+
typescript: "typescript";
|
|
874
|
+
javascript: "javascript";
|
|
875
|
+
python: "python";
|
|
876
|
+
html: "html";
|
|
877
|
+
css: "css";
|
|
878
|
+
sql: "sql";
|
|
879
|
+
bash: "bash";
|
|
880
|
+
yaml: "yaml";
|
|
881
|
+
json: "json";
|
|
882
|
+
}>>;
|
|
883
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
884
|
+
config: "config";
|
|
885
|
+
table: "table";
|
|
886
|
+
model: "model";
|
|
887
|
+
service: "service";
|
|
888
|
+
endpoint: "endpoint";
|
|
889
|
+
component: "component";
|
|
890
|
+
}>>;
|
|
891
|
+
box: z.ZodOptional<z.ZodString>;
|
|
892
|
+
ignore: z.ZodOptional<z.ZodLiteral<true>>;
|
|
893
|
+
}, z.core.$strict>>>>;
|
|
894
|
+
guidance: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
895
|
+
pinned: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
896
|
+
name: z.ZodString;
|
|
897
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
898
|
+
}, z.core.$strict>>>>;
|
|
899
|
+
}, z.core.$strict>;
|
|
900
|
+
type MapRule = z.infer<typeof mapRuleSchema>;
|
|
901
|
+
type PinnedEntry = z.infer<typeof pinnedEntrySchema>;
|
|
902
|
+
type Pinned = Record<string, PinnedEntry>;
|
|
903
|
+
type MapConfig = z.infer<typeof mapSchema>;
|
|
904
|
+
/** Checks pins before they are written: formatIssues lines, paths starting at `pinned`. */
|
|
905
|
+
declare function parsePinned(input: unknown): {
|
|
906
|
+
ok: true;
|
|
907
|
+
pinned: Pinned;
|
|
908
|
+
} | {
|
|
909
|
+
ok: false;
|
|
910
|
+
errors: string[];
|
|
911
|
+
};
|
|
830
912
|
declare const configFileSchema: z.ZodObject<{
|
|
831
913
|
defaults: z.ZodOptional<z.ZodObject<{
|
|
832
914
|
output: z.ZodOptional<z.ZodEnum<{
|
|
@@ -897,6 +979,38 @@ declare const configFileSchema: z.ZodObject<{
|
|
|
897
979
|
full: "full";
|
|
898
980
|
}>>;
|
|
899
981
|
}, z.core.$strict>>>;
|
|
982
|
+
map: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
983
|
+
rules: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
984
|
+
paths: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
985
|
+
pattern: z.ZodOptional<z.ZodString>;
|
|
986
|
+
lang: z.ZodOptional<z.ZodEnum<{
|
|
987
|
+
typescript: "typescript";
|
|
988
|
+
javascript: "javascript";
|
|
989
|
+
python: "python";
|
|
990
|
+
html: "html";
|
|
991
|
+
css: "css";
|
|
992
|
+
sql: "sql";
|
|
993
|
+
bash: "bash";
|
|
994
|
+
yaml: "yaml";
|
|
995
|
+
json: "json";
|
|
996
|
+
}>>;
|
|
997
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
998
|
+
config: "config";
|
|
999
|
+
table: "table";
|
|
1000
|
+
model: "model";
|
|
1001
|
+
service: "service";
|
|
1002
|
+
endpoint: "endpoint";
|
|
1003
|
+
component: "component";
|
|
1004
|
+
}>>;
|
|
1005
|
+
box: z.ZodOptional<z.ZodString>;
|
|
1006
|
+
ignore: z.ZodOptional<z.ZodLiteral<true>>;
|
|
1007
|
+
}, z.core.$strict>>>>;
|
|
1008
|
+
guidance: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
1009
|
+
pinned: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1010
|
+
name: z.ZodString;
|
|
1011
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
1012
|
+
}, z.core.$strict>>>>;
|
|
1013
|
+
}, z.core.$strict>>>;
|
|
900
1014
|
}, z.core.$strict>;
|
|
901
1015
|
type ConfigFile = z.infer<typeof configFileSchema>;
|
|
902
1016
|
declare function configJsonSchema(): object;
|
|
@@ -932,6 +1046,14 @@ declare function loadConfig(opts: LoadOptions): Config;
|
|
|
932
1046
|
|
|
933
1047
|
declare function findRepoRoot(cwd: string): string | undefined;
|
|
934
1048
|
|
|
1049
|
+
/**
|
|
1050
|
+
* `text` (a `.codechart.yaml`) with `map.pinned` set to `pinned`, sorted by id, so the same pins in any order give the
|
|
1051
|
+
* same bytes. Only that block is rewritten (comments inside it are not kept); the rest of the file stays byte-identical.
|
|
1052
|
+
* New lines indent like the file's `map`, else by 2. No pins removes the block, and `map` when nothing else is in it.
|
|
1053
|
+
* Throws on invalid pins, or a file it can't edit safely: not one block mapping, or `map` using aliases.
|
|
1054
|
+
*/
|
|
1055
|
+
declare function writePinned(text: string, pinned: Pinned): string;
|
|
1056
|
+
|
|
935
1057
|
/** Git's change to a file: added, modified, deleted, or moved (the status is the new path's). */
|
|
936
1058
|
type ChangeStatus = 'A' | 'M' | 'D' | 'R';
|
|
937
1059
|
/** One changed file, repo-relative with `/`. */
|
|
@@ -1784,10 +1906,10 @@ type CodeRange = z.infer<typeof codeRangeSchema>;
|
|
|
1784
1906
|
declare const fileInfoSchema: z.ZodObject<{
|
|
1785
1907
|
path: z.ZodString;
|
|
1786
1908
|
lang: z.ZodEnum<{
|
|
1787
|
-
html: "html";
|
|
1788
1909
|
typescript: "typescript";
|
|
1789
1910
|
javascript: "javascript";
|
|
1790
1911
|
python: "python";
|
|
1912
|
+
html: "html";
|
|
1791
1913
|
css: "css";
|
|
1792
1914
|
sql: "sql";
|
|
1793
1915
|
bash: "bash";
|
|
@@ -1842,6 +1964,8 @@ declare const importSchema: z.ZodObject<{
|
|
|
1842
1964
|
resolved: "resolved";
|
|
1843
1965
|
external: "external";
|
|
1844
1966
|
}>;
|
|
1967
|
+
packageFolder: z.ZodOptional<z.ZodString>;
|
|
1968
|
+
anchored: z.ZodOptional<z.ZodString>;
|
|
1845
1969
|
kind: z.ZodEnum<{
|
|
1846
1970
|
import: "import";
|
|
1847
1971
|
export: "export";
|
|
@@ -1867,9 +1991,18 @@ declare const importSchema: z.ZodObject<{
|
|
|
1867
1991
|
}, z.core.$strip>;
|
|
1868
1992
|
}, z.core.$strip>;
|
|
1869
1993
|
type Import = z.infer<typeof importSchema>;
|
|
1994
|
+
declare const CALL_VIAS: readonly ["bare", "this", "member"];
|
|
1995
|
+
type CallVia = (typeof CALL_VIAS)[number];
|
|
1870
1996
|
declare const callRefSchema: z.ZodObject<{
|
|
1871
1997
|
from: z.ZodString;
|
|
1872
1998
|
name: z.ZodString;
|
|
1999
|
+
via: z.ZodOptional<z.ZodEnum<{
|
|
2000
|
+
bare: "bare";
|
|
2001
|
+
this: "this";
|
|
2002
|
+
member: "member";
|
|
2003
|
+
}>>;
|
|
2004
|
+
receiver: z.ZodOptional<z.ZodString>;
|
|
2005
|
+
receiverPath: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1873
2006
|
to: z.ZodOptional<z.ZodString>;
|
|
1874
2007
|
evidence: z.ZodEnum<{
|
|
1875
2008
|
resolved: "resolved";
|
|
@@ -1889,11 +2022,83 @@ declare const callRefSchema: z.ZodObject<{
|
|
|
1889
2022
|
type CallRef = z.infer<typeof callRefSchema>;
|
|
1890
2023
|
/** Node identity (Live map #9): file + symbol path + kind, so line moves keep the node. */
|
|
1891
2024
|
declare const symbolId: (file: string, path: readonly string[], kind: SymbolKind) => string;
|
|
2025
|
+
/** What files without imports define (Code model #3): SQL tables, workflow jobs and steps, compose services, npm scripts. */
|
|
2026
|
+
declare const ENTITY_KINDS: readonly ["table", "job", "step", "service", "script"];
|
|
2027
|
+
type EntityKind = (typeof ENTITY_KINDS)[number];
|
|
2028
|
+
/**
|
|
2029
|
+
* Like a symbol: `id` is `entityId(file, path, kind)`, `~2`, `~3`… for a repeated identity. `path` holds names from the
|
|
2030
|
+
* outermost in: `['public', 'orders']` for a table, `['deploy', 'ship']` for a step of job `deploy`. Path parts are joined
|
|
2031
|
+
* with `.`, so a name holding a dot (`"a.b"`, a `build.web` script) can share an id with a nested path.
|
|
2032
|
+
*/
|
|
2033
|
+
declare const codeEntitySchema: z.ZodObject<{
|
|
2034
|
+
id: z.ZodString;
|
|
2035
|
+
file: z.ZodString;
|
|
2036
|
+
path: z.ZodArray<z.ZodString>;
|
|
2037
|
+
range: z.ZodObject<{
|
|
2038
|
+
start: z.ZodObject<{
|
|
2039
|
+
line: z.ZodNumber;
|
|
2040
|
+
column: z.ZodNumber;
|
|
2041
|
+
}, z.core.$strip>;
|
|
2042
|
+
end: z.ZodObject<{
|
|
2043
|
+
line: z.ZodNumber;
|
|
2044
|
+
column: z.ZodNumber;
|
|
2045
|
+
}, z.core.$strip>;
|
|
2046
|
+
}, z.core.$strip>;
|
|
2047
|
+
kind: z.ZodEnum<{
|
|
2048
|
+
step: "step";
|
|
2049
|
+
table: "table";
|
|
2050
|
+
service: "service";
|
|
2051
|
+
job: "job";
|
|
2052
|
+
script: "script";
|
|
2053
|
+
}>;
|
|
2054
|
+
}, z.core.$strip>;
|
|
2055
|
+
type CodeEntity = z.infer<typeof codeEntitySchema>;
|
|
2056
|
+
declare const entityId: (file: string, path: readonly string[], kind: EntityKind) => string;
|
|
2057
|
+
/**
|
|
2058
|
+
* `run`: a file a workflow step or npm script runs; `source`: a file a shell script sources; `script` and `link`: an
|
|
2059
|
+
* HTML `<script src>` and `<link href>`; `import`: a CSS `@import`.
|
|
2060
|
+
*/
|
|
2061
|
+
declare const REF_KINDS: readonly ["run", "source", "script", "link", "import"];
|
|
2062
|
+
declare const codeRefSchema: z.ZodObject<{
|
|
2063
|
+
file: z.ZodString;
|
|
2064
|
+
from: z.ZodOptional<z.ZodString>;
|
|
2065
|
+
spec: z.ZodString;
|
|
2066
|
+
written: z.ZodOptional<z.ZodString>;
|
|
2067
|
+
kind: z.ZodEnum<{
|
|
2068
|
+
source: "source";
|
|
2069
|
+
link: "link";
|
|
2070
|
+
import: "import";
|
|
2071
|
+
script: "script";
|
|
2072
|
+
run: "run";
|
|
2073
|
+
}>;
|
|
2074
|
+
candidate: z.ZodOptional<z.ZodString>;
|
|
2075
|
+
resolved: z.ZodOptional<z.ZodString>;
|
|
2076
|
+
status: z.ZodEnum<{
|
|
2077
|
+
unknown: "unknown";
|
|
2078
|
+
resolved: "resolved";
|
|
2079
|
+
external: "external";
|
|
2080
|
+
}>;
|
|
2081
|
+
range: z.ZodObject<{
|
|
2082
|
+
start: z.ZodObject<{
|
|
2083
|
+
line: z.ZodNumber;
|
|
2084
|
+
column: z.ZodNumber;
|
|
2085
|
+
}, z.core.$strip>;
|
|
2086
|
+
end: z.ZodObject<{
|
|
2087
|
+
line: z.ZodNumber;
|
|
2088
|
+
column: z.ZodNumber;
|
|
2089
|
+
}, z.core.$strip>;
|
|
2090
|
+
}, z.core.$strip>;
|
|
2091
|
+
}, z.core.$strip>;
|
|
2092
|
+
type CodeRef = z.infer<typeof codeRefSchema>;
|
|
1892
2093
|
|
|
1893
2094
|
/** A tree-sitter grammar codechart parses symbols with. */
|
|
1894
|
-
type Grammar = 'typescript' | 'tsx' | 'javascript';
|
|
2095
|
+
type Grammar = 'typescript' | 'tsx' | 'javascript' | 'python';
|
|
1895
2096
|
/** The v1 language of a file, from its extension; undefined for files the code layer skips. */
|
|
1896
2097
|
declare function langOf(path: string): Lang | undefined;
|
|
2098
|
+
/** A tree-sitter grammar codechart reads entities and references with (and, for Bash, functions). */
|
|
2099
|
+
type EntityGrammar = 'html' | 'css' | 'sql' | 'bash' | 'yaml' | 'json';
|
|
2100
|
+
/** The grammar that reads a file's entities and references, for the v1 languages without imports. */
|
|
2101
|
+
declare function entityGrammarOf(path: string): EntityGrammar | undefined;
|
|
1897
2102
|
/** The grammar that reads a file's symbols, or undefined while its language has entities only or none yet. */
|
|
1898
2103
|
declare function grammarOf(path: string): Grammar | undefined;
|
|
1899
2104
|
|
|
@@ -1908,23 +2113,50 @@ interface ModuleExports {
|
|
|
1908
2113
|
complete: boolean;
|
|
1909
2114
|
}
|
|
1910
2115
|
|
|
2116
|
+
/**
|
|
2117
|
+
* One name a Python scope binds. `scope` is the id of the function or class whose body binds it, `''` for the module.
|
|
2118
|
+
* `import` points at the file's import by index; `def` is a `def` or `class`; `other` is any other write (assignment,
|
|
2119
|
+
* parameter, loop or `with` target, `del`, `global` write), with `built` set for `name = Name(…)`.
|
|
2120
|
+
*/
|
|
2121
|
+
interface PyBinding {
|
|
2122
|
+
scope: string;
|
|
2123
|
+
name: string;
|
|
2124
|
+
kind: 'import' | 'def' | 'other';
|
|
2125
|
+
import?: number;
|
|
2126
|
+
/** For `import a.b` without an alias: binds `a`, and `a.b` stays reachable through it. */
|
|
2127
|
+
dotted?: boolean;
|
|
2128
|
+
built?: string;
|
|
2129
|
+
}
|
|
2130
|
+
|
|
1911
2131
|
/** One file of the code layer. */
|
|
1912
2132
|
interface ParsedFile {
|
|
1913
2133
|
file: FileInfo;
|
|
1914
2134
|
symbols: CodeSymbol[];
|
|
1915
2135
|
/** Where tree-sitter recovered from a syntax error; empty when the file parses. */
|
|
1916
2136
|
parseErrors: CodeRange[];
|
|
1917
|
-
/** Ids of symbols carried over from the last good parse with their old range, since the broken text no longer shows them. */
|
|
2137
|
+
/** Ids of symbols and entities carried over from the last good parse with their old range, since the broken text no longer shows them. */
|
|
1918
2138
|
kept: string[];
|
|
1919
|
-
/** `unknown` until
|
|
2139
|
+
/** `unknown` until the link pass resolves them against the rest of the repo. */
|
|
1920
2140
|
imports: Import[];
|
|
1921
2141
|
exports: ModuleExports;
|
|
2142
|
+
/** Calls by `from` symbol; `name-only` until the link pass proves a target. */
|
|
2143
|
+
calls: CallRef[];
|
|
2144
|
+
/** Tables, workflow jobs and steps, compose services and npm scripts (Code model #3); empty for languages with imports. */
|
|
2145
|
+
entities: CodeEntity[];
|
|
2146
|
+
/** Files this one runs, sources, loads or imports without an import statement; `unknown` until the link pass. */
|
|
2147
|
+
refs: CodeRef[];
|
|
2148
|
+
/** Python only: every name each scope binds, which decides what a called name means where it is called. */
|
|
2149
|
+
bindings?: PyBinding[];
|
|
2150
|
+
/** The file edits `sys.path`, so its absolute Python imports have no provable target. Absent for other files. */
|
|
2151
|
+
sysPathEdited?: boolean;
|
|
1922
2152
|
}
|
|
2153
|
+
/** The previous parse of a file: symbols, imports and exports that stand in while syntax errors hide them. */
|
|
2154
|
+
type LastGood = ParsedFile | readonly CodeSymbol[];
|
|
1923
2155
|
/**
|
|
1924
|
-
* Parses one file in isolation. `path` is repo-relative with `/`; `lastGood` is the file's previous
|
|
1925
|
-
*
|
|
2156
|
+
* Parses one file in isolation. `path` is repo-relative with `/`; `lastGood` is the file's previous parse, whose
|
|
2157
|
+
* symbols, entities, imports, exports and references stand in for what a syntax error hides.
|
|
1926
2158
|
*/
|
|
1927
|
-
declare function parseCode(path: string, text: string, lastGood?:
|
|
2159
|
+
declare function parseCode(path: string, text: string, lastGood?: LastGood): Promise<ParsedFile | undefined>;
|
|
1928
2160
|
|
|
1929
2161
|
/** Dependencies, build output and minified bundles: never source a map should point at. */
|
|
1930
2162
|
declare const DEFAULT_CODE_IGNORE: string[];
|
|
@@ -1936,28 +2168,77 @@ declare const DEFAULT_CODE_IGNORE: string[];
|
|
|
1936
2168
|
declare function listCodeFiles(root: string, ignore?: readonly string[]): string[];
|
|
1937
2169
|
/** Reads a repo file as text; undefined when it is gone, not a regular file, too large or binary. */
|
|
1938
2170
|
declare function readCodeFile(root: string, path: string): string | undefined;
|
|
1939
|
-
/** The code layer of the repo at `root`, one entry per readable file of `listCodeFiles`, imports resolved. */
|
|
2171
|
+
/** The code layer of the repo at `root`, one entry per readable file of `listCodeFiles`, imports and calls resolved. */
|
|
1940
2172
|
declare function parseRepo(root: string, opts?: {
|
|
1941
2173
|
ignore?: readonly string[];
|
|
1942
2174
|
}): Promise<ParsedFile[]>;
|
|
1943
2175
|
|
|
1944
|
-
|
|
2176
|
+
interface CodeIndexOptions {
|
|
2177
|
+
/** The config's `ignore` globs, as `parseRepo` takes them. */
|
|
2178
|
+
ignore?: readonly string[];
|
|
2179
|
+
}
|
|
2180
|
+
/** What one update touched; every path is repo-relative with `/`. */
|
|
2181
|
+
interface CodeUpdate {
|
|
2182
|
+
/** Files added, edited or removed by content hash. */
|
|
2183
|
+
changed: string[];
|
|
2184
|
+
/** Changed files parsed again: one file on the live path, more in bulk. */
|
|
2185
|
+
parsed: string[];
|
|
2186
|
+
/** Files outside `parsed` whose imports or calls changed through the ripple. */
|
|
2187
|
+
relinked: string[];
|
|
2188
|
+
/** Files that left the repo or became unreadable. */
|
|
2189
|
+
removed: string[];
|
|
2190
|
+
}
|
|
2191
|
+
interface CodeIndex {
|
|
2192
|
+
readonly root: string;
|
|
2193
|
+
/** Every readable file of the code layer, sorted by path. */
|
|
2194
|
+
readonly files: readonly ParsedFile[];
|
|
2195
|
+
file(path: string): ParsedFile | undefined;
|
|
2196
|
+
/**
|
|
2197
|
+
* Re-reads `paths` (repo-relative or absolute) and the repo's file list, parses only files whose hash changed, and
|
|
2198
|
+
* re-matches only the files the change affects. With no paths, hashes every listed file (bulk mode).
|
|
2199
|
+
*/
|
|
2200
|
+
update(paths?: readonly string[]): Promise<CodeUpdate>;
|
|
2201
|
+
}
|
|
2202
|
+
/** Opens the code layer of `root` and keeps it ready for one-file updates; links as `parseRepo` does, recording probes. */
|
|
2203
|
+
declare function openCodeIndex(root: string, opts?: CodeIndexOptions): Promise<CodeIndex>;
|
|
2204
|
+
|
|
2205
|
+
type RefResolution = Pick<CodeRef, 'status' | 'resolved'>;
|
|
2206
|
+
|
|
2207
|
+
type Resolution = Pick<Import, 'status' | 'resolved' | 'packageFolder'>;
|
|
2208
|
+
/** What a resolution needs beyond the specifier: whether the importing Python file edits `sys.path`. */
|
|
2209
|
+
interface ResolveContext {
|
|
2210
|
+
sysPathEdited?: boolean;
|
|
2211
|
+
}
|
|
1945
2212
|
/** Resolves import specifiers against one snapshot of a repo's files; caches configs, so make a new one when a config changes. */
|
|
1946
2213
|
interface Resolver {
|
|
1947
2214
|
/** Where `spec`, imported by repo file `from`, leads; `kind` picks the package conditions (`require` or the rest). */
|
|
1948
|
-
resolve(from: string, spec: string, kind?: Import['kind']): Resolution;
|
|
2215
|
+
resolve(from: string, spec: string, kind?: Import['kind'], context?: ResolveContext): Resolution;
|
|
2216
|
+
/** Where a reference of a file without imports leads: the listed file it names, the web, or unknown. */
|
|
2217
|
+
ref(ref: CodeRef): RefResolution;
|
|
2218
|
+
}
|
|
2219
|
+
/** Hooks that see what resolution depends on. */
|
|
2220
|
+
interface ResolverProbes {
|
|
2221
|
+
/** Every path one resolution checks for. */
|
|
2222
|
+
path?: (path: string) => void;
|
|
2223
|
+
/**
|
|
2224
|
+
* Every path a config lookup (package.json, tsconfig and its `extends` chain, workspaces) checks for or reads. Those
|
|
2225
|
+
* lookups are cached and shared by every resolution, so a change to one of these paths can change any of them.
|
|
2226
|
+
*/
|
|
2227
|
+
config?: (path: string) => void;
|
|
1949
2228
|
}
|
|
1950
2229
|
/**
|
|
1951
2230
|
* A resolver over `files` (repo paths with `/`, as `listCodeFiles` gives them); `read` returns a repo file's text.
|
|
1952
2231
|
* Only listed files count, so nothing resolves into `node_modules` or ignored build output.
|
|
1953
2232
|
*/
|
|
1954
|
-
declare function createResolver(files: Iterable<string>, read: (path: string) => string | undefined): Resolver;
|
|
2233
|
+
declare function createResolver(files: Iterable<string>, read: (path: string) => string | undefined, probes?: ResolverProbes): Resolver;
|
|
1955
2234
|
|
|
1956
2235
|
/**
|
|
1957
2236
|
* Resolves every file's imports with `resolver`, then follows each imported name through re-exports to the file
|
|
1958
2237
|
* that defines it. Files not passed in count as unparsed: names reaching them get no `definedIn`.
|
|
1959
2238
|
*/
|
|
1960
2239
|
declare function linkImports(files: readonly ParsedFile[], resolver: Resolver): ParsedFile[];
|
|
2240
|
+
/** Imports and calls of every file, linked against the full set. */
|
|
2241
|
+
declare function linkCode(files: readonly ParsedFile[], resolver: Resolver): ParsedFile[];
|
|
1961
2242
|
|
|
1962
|
-
export { AGENTS, BLOCK_MAX, BUILTIN_DEFAULTS, CODE_PATTERNS, DEFAULT_CODE_IGNORE, DEFAULT_RELEASE_BRANCHES, DESCRIPTION_CANVASES, EDGE_KINDS, FLOW_PREFIX, GENERATED_PATHS, GLOBAL_ONLY, HTML_NAME, IMPORT_KINDS, IN_DIFF, KIND_ROW, LABEL_LINE_HEIGHT, LANGS, LINE_HEIGHT, LONG, MAX_FLOWS, MAX_ITEMS, MAX_SPEC_BYTES, NODE_KINDS, OutputTooLarge, PANE_CANVASES, PRIVATE_KEY, REVIEW_NAME, SHORT, STATUSES, STEP_STATUSES, SUMMARY_CHARS_PER_LINE, SUMMARY_MAX_LINES, SYMBOL_KINDS, THEMES, agentsFor, anchorContext, arrowNames, asFlowSpec, blockOf, buildDoc, builtinRules, businessLinkIssues, businessSpecJsonSchema, businessTexts, callRefSchema, carryNotes, changeTitle, checkFlowAnchors, checkFlowDiff, checkMapNodes, checkRef, cleanPath, clip, codeLabelIssue, codeRangeSchema, codeSymbolSchema, configJsonSchema, copyFiles, createResolver, csv, dataSchema, diffOf, diffRange, driftBase, driftIssues, entryPaths, entryProse, entryWords, escapeJsonControls, explainFlowSchema, explainIssues, explainTexts, explains, fileInfoSchema, fileSlug, findChange, findMatch, findRepoRoot, flat, flowIssues, flowJsonSchema, flowShapeIssues, flowTexts, formatIssues, formatPath, git, gitBinary, gitBlob, gitBlobSizes, gitBlobs, gitBranch, gitChangedChanges, gitChangedFiles, gitChanges, gitCommitChanges, gitCommitFiles, gitDiffFiles, gitDirtyHashes, gitEmptyTree, gitFileAt, gitFileDiff, gitFileDiffs, gitFiles, gitFirstParentLog, gitGeneratedAttr, gitHead, gitIsAncestor, gitIsShallow, gitLatestTag, gitListFiles, gitMergeBase, gitParent, gitSinceChanges, gitSinceFiles, gitTagNames, gitUntracked, gitWorktreeChanges, globalConfigPath, grammarOf, hasAny, hasGitSelection, hasHiddenChars, hashToken, headerHeight, htmlOutputPath, ident, importSchema, importedNameSchema, installCopy, installPairs, isAt, isCodechartSkill, isExplain, isExplainSlug, isPlannedLink, isQuestion, isRemovedLink, itemGroups, itemIssues, itemTexts, journeySchema, labelIssues, labelLines, langOf, lastNoteNumber, layoutSpec, legacyAgentsFor, likelyPath, linkImports, linkSchema, listCodeFiles, listReviews, load, loadConfig, loadConfigWithSources, locate, long, looksSecret, loose, marker, matchSchema, mentionsPath, mergeNotes, nodeOfHeading, normalizeEol, normalizePath, oneLine, onlyBuiltinsToJudge, opencodeConfigDir, parseCode, parseConfigFile, parseDoc, parseRepo, parseStamp, pathStr, pickLayout, plainDiffName, plainLabel, plainTextIssues, questionsOf, quotable, readCodeFile, readRegularBytes, readRegularFile, readReview, releaseSpecJsonSchema, removeSkill, repoDiffOverrides, repoFilterOverrides, repoFolder, repoPath, repoPathResolver, resolveCommit, resolveRules, reviewFile, reviewLock, reviewSchema, ruleSchema, sameFile, sameNote, sanitizeText, saveReview, scanFlowAnchors, selectionError, short, shortOpt, shown, shownLines, skillFiles, skillFolders, specJsonSchema, stamp, stepLabel, stepSchema, stripInvisible, symbolId, targetExists, techIdIssue, text, trustedBinary, unionOutputs, unmappedFiles, updateReview, validateAnySpec, validateBusinessSpec, validateFlowSpec, validateReleaseSpec, validateSpec, withStepTypes, withTypes, wrapSummary, wrapText, writeReview };
|
|
1963
|
-
export type { AgentPreset, AnchorCtx, AnchorFailure, Block, BusinessSpec, CallRef, ChangeSpec, ChangeStatus, CheckResult, CheckSummary, CodeRange, CodeSymbol, Config, ConfigFile, ConfigWithSources, ContextMode, Diagram, Diff, DiffLine, DiffRange, Direction, DriftCause, ExplainFlow, ExplainSpec, ExportName, Field, FileChange, FileInfo, Flow, FlowInput, FlowLink, FlowSnippets, FlowSpec, FlowStep, Flows, Found, GitOpts, GitSelection, Grammar, Import, ImportedName, InstallIO, Issue$2 as Issue, ItemBase, ItemGroup, Items, Lang, Layout, LayoutEdge, Lists, Loaded, LogEntry, MapCheck, Mismatch, ModuleExports, NodeKind, Note, NoteKind, Output, Pair, Parsed, ParsedFile, Point, Range, ReleaseSpec, Resolution, Resolver, Review, ReviewNode, ReviewSnapshot, Rule, Snippet, Spec, SpecEdge, SpecNode, Status, SymbolKind, Target, TechBox, Theme, ToJudge, ValidationResult$1 as ValidationResult, Which };
|
|
2243
|
+
export { AGENTS, BLOCK_MAX, BUILTIN_DEFAULTS, CALL_VIAS, CODE_PATTERNS, DEFAULT_CODE_IGNORE, DEFAULT_RELEASE_BRANCHES, DESCRIPTION_CANVASES, EDGE_KINDS, ENTITY_KINDS, FLOW_PREFIX, FOLDER_BOX_PREFIX, GENERATED_PATHS, GLOBAL_ONLY, HTML_NAME, IMPORT_KINDS, IN_DIFF, KIND_ROW, LABEL_LINE_HEIGHT, LANGS, LINE_HEIGHT, LONG, MAP_ENTITY_KINDS, MAX_FLOWS, MAX_ITEMS, MAX_SPEC_BYTES, NODE_KINDS, OutputTooLarge, PANE_CANVASES, PRIVATE_KEY, REF_KINDS, REVIEW_NAME, SHORT, STATUSES, STEP_STATUSES, SUMMARY_CHARS_PER_LINE, SUMMARY_MAX_LINES, SYMBOL_KINDS, THEMES, agentsFor, anchorContext, arrowNames, asFlowSpec, blockOf, buildDoc, builtinRules, businessLinkIssues, businessSpecJsonSchema, businessTexts, callRefSchema, carryNotes, changeTitle, checkFlowAnchors, checkFlowDiff, checkMapNodes, checkRef, cleanPath, clip, codeEntitySchema, codeLabelIssue, codeRangeSchema, codeRefSchema, codeSymbolSchema, configJsonSchema, copyFiles, createResolver, csv, dataSchema, diffOf, diffRange, driftBase, driftIssues, entityGrammarOf, entityId, entryPaths, entryProse, entryWords, escapeJsonControls, explainFlowSchema, explainIssues, explainTexts, explains, fileInfoSchema, fileSlug, findChange, findMatch, findRepoRoot, flat, flowIssues, flowJsonSchema, flowShapeIssues, flowTexts, formatIssues, formatPath, git, gitBinary, gitBlob, gitBlobSizes, gitBlobs, gitBranch, gitChangedChanges, gitChangedFiles, gitChanges, gitCommitChanges, gitCommitFiles, gitDiffFiles, gitDirtyHashes, gitEmptyTree, gitFileAt, gitFileDiff, gitFileDiffs, gitFiles, gitFirstParentLog, gitGeneratedAttr, gitHead, gitIsAncestor, gitIsShallow, gitLatestTag, gitListFiles, gitMergeBase, gitParent, gitSinceChanges, gitSinceFiles, gitTagNames, gitUntracked, gitWorktreeChanges, globalConfigPath, grammarOf, hasAny, hasGitSelection, hasHiddenChars, hashToken, headerHeight, htmlOutputPath, ident, importSchema, importedNameSchema, installCopy, installPairs, isAt, isCodechartSkill, isExplain, isExplainSlug, isPlannedLink, isQuestion, isRemovedLink, itemGroups, itemIssues, itemTexts, journeySchema, labelIssues, labelLines, langOf, lastNoteNumber, layoutSpec, legacyAgentsFor, likelyPath, linkCode, linkImports, linkSchema, listCodeFiles, listReviews, load, loadConfig, loadConfigWithSources, locate, long, looksSecret, loose, marker, matchSchema, mentionsPath, mergeNotes, nodeOfHeading, normalizeEol, normalizePath, oneLine, onlyBuiltinsToJudge, openCodeIndex, opencodeConfigDir, parseCode, parseConfigFile, parseDoc, parsePinned, parseRepo, parseStamp, pathStr, pickLayout, pinnedIdKind, plainDiffName, plainLabel, plainTextIssues, questionsOf, quotable, quotedVisible, readCodeFile, readRegularBytes, readRegularFile, readReview, releaseSpecJsonSchema, removeSkill, repoDiffOverrides, repoFilterOverrides, repoFolder, repoPath, repoPathResolver, resolveCommit, resolveRules, reviewFile, reviewLock, reviewSchema, ruleSchema, sameFile, sameNote, sanitizeText, saveReview, scanFlowAnchors, selectionError, short, shortOpt, shown, shownLines, skillFiles, skillFolders, specJsonSchema, stamp, stepLabel, stepSchema, stripInvisible, symbolId, targetExists, techIdIssue, text, trustedBinary, unionOutputs, unmappedFiles, updateReview, validateAnySpec, validateBusinessSpec, validateFlowSpec, validateReleaseSpec, validateSpec, withStepTypes, withTypes, wrapSummary, wrapText, writePinned, writeReview };
|
|
2244
|
+
export type { AgentPreset, AnchorCtx, AnchorFailure, Block, BusinessSpec, CallRef, CallVia, ChangeSpec, ChangeStatus, CheckResult, CheckSummary, CodeEntity, CodeIndex, CodeIndexOptions, CodeRange, CodeRef, CodeSymbol, CodeUpdate, Config, ConfigFile, ConfigWithSources, ContextMode, Diagram, Diff, DiffLine, DiffRange, Direction, DriftCause, EntityGrammar, EntityKind, ExplainFlow, ExplainSpec, ExportName, Field, FileChange, FileInfo, Flow, FlowInput, FlowLink, FlowSnippets, FlowSpec, FlowStep, Flows, Found, GitOpts, GitSelection, Grammar, Import, ImportedName, InstallIO, Issue$2 as Issue, ItemBase, ItemGroup, Items, Lang, LastGood, Layout, LayoutEdge, Lists, Loaded, LogEntry, MapCheck, MapConfig, MapEntityKind, MapRule, Mismatch, ModuleExports, NodeKind, Note, NoteKind, Output, Pair, Parsed, ParsedFile, Pinned, PinnedEntry, Point, Range, ReleaseSpec, Resolution, Resolver, ResolverProbes, Review, ReviewNode, ReviewSnapshot, Rule, Snippet, Spec, SpecEdge, SpecNode, Status, SymbolKind, Target, TechBox, Theme, ToJudge, ValidationResult$1 as ValidationResult, Which };
|