@isaacriehm/cairn-state 0.22.5
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/LICENSE +21 -0
- package/README.md +11 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/alignment-pending.d.ts +28 -0
- package/dist/alignment-pending.js +83 -0
- package/dist/alignment-pending.js.map +1 -0
- package/dist/anchor-map.d.ts +14 -0
- package/dist/anchor-map.js +56 -0
- package/dist/anchor-map.js.map +1 -0
- package/dist/archive.d.ts +48 -0
- package/dist/archive.js +96 -0
- package/dist/archive.js.map +1 -0
- package/dist/cache.d.ts +48 -0
- package/dist/cache.js +241 -0
- package/dist/cache.js.map +1 -0
- package/dist/component-registry.d.ts +93 -0
- package/dist/component-registry.js +0 -0
- package/dist/component-registry.js.map +1 -0
- package/dist/components.d.ts +192 -0
- package/dist/components.js +603 -0
- package/dist/components.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.js +26 -0
- package/dist/config.js.map +1 -0
- package/dist/drift.d.ts +8 -0
- package/dist/drift.js +23 -0
- package/dist/drift.js.map +1 -0
- package/dist/file-candidates-map.d.ts +23 -0
- package/dist/file-candidates-map.js +76 -0
- package/dist/file-candidates-map.js.map +1 -0
- package/dist/frontmatter.d.ts +32 -0
- package/dist/frontmatter.js +77 -0
- package/dist/frontmatter.js.map +1 -0
- package/dist/fs.d.ts +36 -0
- package/dist/fs.js +47 -0
- package/dist/fs.js.map +1 -0
- package/dist/glob.d.ts +10 -0
- package/dist/glob.js +46 -0
- package/dist/glob.js.map +1 -0
- package/dist/home.d.ts +69 -0
- package/dist/home.js +168 -0
- package/dist/home.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/languages.d.ts +113 -0
- package/dist/languages.js +512 -0
- package/dist/languages.js.map +1 -0
- package/dist/ledgers.d.ts +14 -0
- package/dist/ledgers.js +105 -0
- package/dist/ledgers.js.map +1 -0
- package/dist/logger.d.ts +13 -0
- package/dist/logger.js +17 -0
- package/dist/logger.js.map +1 -0
- package/dist/manifest.d.ts +10 -0
- package/dist/manifest.js +84 -0
- package/dist/manifest.js.map +1 -0
- package/dist/missions.d.ts +119 -0
- package/dist/missions.js +414 -0
- package/dist/missions.js.map +1 -0
- package/dist/paths.d.ts +117 -0
- package/dist/paths.js +241 -0
- package/dist/paths.js.map +1 -0
- package/dist/quality-grades.d.ts +11 -0
- package/dist/quality-grades.js +100 -0
- package/dist/quality-grades.js.map +1 -0
- package/dist/rejected.d.ts +42 -0
- package/dist/rejected.js +100 -0
- package/dist/rejected.js.map +1 -0
- package/dist/schemas.d.ts +789 -0
- package/dist/schemas.js +506 -0
- package/dist/schemas.js.map +1 -0
- package/dist/scope-index.d.ts +96 -0
- package/dist/scope-index.js +299 -0
- package/dist/scope-index.js.map +1 -0
- package/dist/slug.d.ts +81 -0
- package/dist/slug.js +138 -0
- package/dist/slug.js.map +1 -0
- package/dist/sot-bindings.d.ts +14 -0
- package/dist/sot-bindings.js +79 -0
- package/dist/sot-bindings.js.map +1 -0
- package/dist/sot-cache.d.ts +18 -0
- package/dist/sot-cache.js +62 -0
- package/dist/sot-cache.js.map +1 -0
- package/dist/text.d.ts +27 -0
- package/dist/text.js +63 -0
- package/dist/text.js.map +1 -0
- package/dist/topic-index.d.ts +27 -0
- package/dist/topic-index.js +82 -0
- package/dist/topic-index.js.map +1 -0
- package/dist/walk.d.ts +7 -0
- package/dist/walk.js +34 -0
- package/dist/walk.js.map +1 -0
- package/package.json +35 -0
package/dist/home.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cairn state-home resolver — the single source of truth for *where* a repo's
|
|
3
|
+
* Cairn state lives. Committed mode (the default) returns `<repoRoot>/.cairn`,
|
|
4
|
+
* byte-for-byte today's behavior. Ghost mode returns an out-of-repo directory
|
|
5
|
+
* under `~/.cairn/state/<repo-id>/`, so nothing Cairn-shaped ever lands in the
|
|
6
|
+
* client tree.
|
|
7
|
+
*
|
|
8
|
+
* This is pure indirection: every `paths.ts` helper (and every other call site
|
|
9
|
+
* that used to hardcode `join(repoRoot, ".cairn", …)`) builds on `cairnHome`
|
|
10
|
+
* here. Centralizing the state location is a standalone win independent of
|
|
11
|
+
* ghost — it makes the location relocatable, testable, and a single seam.
|
|
12
|
+
*
|
|
13
|
+
* The resolver chicken-and-egg (the ghost flag normally lives in the config
|
|
14
|
+
* file, but in ghost that file is *inside* the out-of-repo home) is broken by a
|
|
15
|
+
* global registry outside any client repo: `~/.cairn/registry.yaml`.
|
|
16
|
+
*/
|
|
17
|
+
import { execFileSync } from "node:child_process";
|
|
18
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
19
|
+
import { homedir } from "node:os";
|
|
20
|
+
import { dirname, join } from "node:path";
|
|
21
|
+
import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
|
|
22
|
+
/** Expand a leading `~` to the operator's home directory. */
|
|
23
|
+
function expandTilde(p) {
|
|
24
|
+
if (p === "~")
|
|
25
|
+
return homedir();
|
|
26
|
+
if (p.startsWith("~/"))
|
|
27
|
+
return join(homedir(), p.slice(2));
|
|
28
|
+
return p;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Global Cairn state home — `~/.cairn/state/`. Hardcoded (the operator hates
|
|
32
|
+
* env vars). Per-repo ghost state lives at `<stateHome>/<repo-id>/`, mirroring
|
|
33
|
+
* the in-repo `.cairn/` layout (`ground/`, `config.yaml`, `git-hooks/`, …) but
|
|
34
|
+
* physically outside every client repo tree.
|
|
35
|
+
*/
|
|
36
|
+
export function stateHome() {
|
|
37
|
+
return join(homedir(), ".cairn", "state");
|
|
38
|
+
}
|
|
39
|
+
/** `~/.cairn/state/<repoId>` — the out-of-repo home for one ghost repo. */
|
|
40
|
+
export function ghostStateDir(repoId) {
|
|
41
|
+
return join(stateHome(), repoId);
|
|
42
|
+
}
|
|
43
|
+
/** `~/.cairn/registry.yaml` — the global repo→mode map, outside any repo. */
|
|
44
|
+
export function registryPath() {
|
|
45
|
+
return join(homedir(), ".cairn", "registry.yaml");
|
|
46
|
+
}
|
|
47
|
+
/* -------------------------------------------------------------------------- */
|
|
48
|
+
/* Resolution — memoized per process; registry-absent is the fast committed */
|
|
49
|
+
/* path (one existsSync, no git shell). */
|
|
50
|
+
/* -------------------------------------------------------------------------- */
|
|
51
|
+
const homeCache = new Map();
|
|
52
|
+
const ghostCache = new Map();
|
|
53
|
+
/**
|
|
54
|
+
* Drop the memoized resolution for a repo (or all repos). Call after mutating
|
|
55
|
+
* the registry — e.g. `cairn init --ghost` registers a repo, then seed must
|
|
56
|
+
* resolve to the *new* out-of-repo home rather than a stale committed cache.
|
|
57
|
+
*/
|
|
58
|
+
export function invalidateCairnHomeCache(repoRoot) {
|
|
59
|
+
if (repoRoot) {
|
|
60
|
+
homeCache.delete(repoRoot);
|
|
61
|
+
ghostCache.delete(repoRoot);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
homeCache.clear();
|
|
65
|
+
ghostCache.clear();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/** Read `~/.cairn/registry.yaml`; null when absent/broken (→ committed). */
|
|
69
|
+
export function readRegistry() {
|
|
70
|
+
const p = registryPath();
|
|
71
|
+
if (!existsSync(p))
|
|
72
|
+
return null;
|
|
73
|
+
try {
|
|
74
|
+
const doc = parseYaml(readFileSync(p, "utf8"));
|
|
75
|
+
return typeof doc === "object" && doc !== null ? doc : null;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** The repo's root-commit SHA, or null (no git / no commits yet). */
|
|
82
|
+
function rootCommit(repoRoot) {
|
|
83
|
+
try {
|
|
84
|
+
const out = execFileSync("git", ["-C", repoRoot, "rev-list", "--max-parents=0", "HEAD"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
85
|
+
return out.trim().split(/\s+/)[0] || null;
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The ghost registry entry for this repo, or null when committed. Prefers the
|
|
93
|
+
* move-stable root-commit identity (so moving/renaming the checkout doesn't
|
|
94
|
+
* orphan state), falling back to an absolute-path match for pre-first-commit
|
|
95
|
+
* repos.
|
|
96
|
+
*/
|
|
97
|
+
function ghostEntry(repoRoot) {
|
|
98
|
+
const reg = readRegistry();
|
|
99
|
+
if (!reg?.repos)
|
|
100
|
+
return null;
|
|
101
|
+
const ghosts = Object.values(reg.repos).filter((e) => e?.mode === "ghost");
|
|
102
|
+
if (ghosts.length === 0)
|
|
103
|
+
return null;
|
|
104
|
+
const rc = rootCommit(repoRoot);
|
|
105
|
+
if (rc) {
|
|
106
|
+
const byCommit = ghosts.find((e) => e.root_commit === rc);
|
|
107
|
+
if (byCommit)
|
|
108
|
+
return byCommit;
|
|
109
|
+
}
|
|
110
|
+
return ghosts.find((e) => e.last_path === repoRoot) ?? null;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Resolve the Cairn state home for a repo — the base every path helper builds
|
|
114
|
+
* on. Committed: `<repoRoot>/.cairn`. Ghost: the out-of-repo `state_dir`.
|
|
115
|
+
*/
|
|
116
|
+
export function cairnHome(repoRoot) {
|
|
117
|
+
const cached = homeCache.get(repoRoot);
|
|
118
|
+
if (cached !== undefined)
|
|
119
|
+
return cached;
|
|
120
|
+
const entry = ghostEntry(repoRoot);
|
|
121
|
+
const home = entry ? expandTilde(entry.state_dir) : join(repoRoot, ".cairn");
|
|
122
|
+
homeCache.set(repoRoot, home);
|
|
123
|
+
ghostCache.set(repoRoot, entry !== null);
|
|
124
|
+
return home;
|
|
125
|
+
}
|
|
126
|
+
/** True when this repo is registered ghost. Registry lookup, memoized. */
|
|
127
|
+
export function isGhost(repoRoot) {
|
|
128
|
+
const cached = ghostCache.get(repoRoot);
|
|
129
|
+
if (cached !== undefined)
|
|
130
|
+
return cached;
|
|
131
|
+
cairnHome(repoRoot); // populates both caches
|
|
132
|
+
return ghostCache.get(repoRoot) ?? false;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* `join(cairnHome(repoRoot), ...segments)` — the workhorse builder that
|
|
136
|
+
* replaces every `join(repoRoot, ".cairn", …)` outside `paths.ts`.
|
|
137
|
+
*/
|
|
138
|
+
export function cairnDir(repoRoot, ...segments) {
|
|
139
|
+
return join(cairnHome(repoRoot), ...segments);
|
|
140
|
+
}
|
|
141
|
+
/* -------------------------------------------------------------------------- */
|
|
142
|
+
/* Registration — written once at adoption (cairn init --ghost / cairn-adopt) */
|
|
143
|
+
/* -------------------------------------------------------------------------- */
|
|
144
|
+
/**
|
|
145
|
+
* Register a repo as ghost in the global registry, keyed on its root-commit
|
|
146
|
+
* SHA (abs-path key fallback for pre-first-commit repos), and return the
|
|
147
|
+
* resolved out-of-repo state dir. Invalidates the resolver cache so subsequent
|
|
148
|
+
* `cairnHome` calls relocate immediately.
|
|
149
|
+
*/
|
|
150
|
+
export function registerGhostRepo(repoRoot) {
|
|
151
|
+
const rc = rootCommit(repoRoot);
|
|
152
|
+
const repoId = rc ?? repoRoot.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
153
|
+
const entry = {
|
|
154
|
+
mode: "ghost",
|
|
155
|
+
state_dir: ghostStateDir(repoId),
|
|
156
|
+
last_path: repoRoot,
|
|
157
|
+
...(rc ? { root_commit: rc } : {}),
|
|
158
|
+
};
|
|
159
|
+
const reg = readRegistry() ?? {};
|
|
160
|
+
reg.repos = reg.repos ?? {};
|
|
161
|
+
reg.repos[repoId] = entry;
|
|
162
|
+
const p = registryPath();
|
|
163
|
+
mkdirSync(dirname(p), { recursive: true });
|
|
164
|
+
writeFileSync(p, stringifyYaml(reg), "utf8");
|
|
165
|
+
invalidateCairnHomeCache(repoRoot);
|
|
166
|
+
return entry;
|
|
167
|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CAAC;IAC5B,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;IAC1B,MAAM,CAAC,GAAG,YAAY,EAAE,CAAC;IACzB,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,aAAa,CAAC,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC;IAC7C,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IACnC,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export * from "./schemas.js";
|
|
2
|
+
export * from "./home.js";
|
|
3
|
+
export * from "./paths.js";
|
|
4
|
+
export * from "./ledgers.js";
|
|
5
|
+
export * from "./archive.js";
|
|
6
|
+
export * from "./anchor-map.js";
|
|
7
|
+
export * from "./sot-bindings.js";
|
|
8
|
+
export * from "./scope-index.js";
|
|
9
|
+
export * from "./frontmatter.js";
|
|
10
|
+
export * from "./text.js";
|
|
11
|
+
export * from "./slug.js";
|
|
12
|
+
export * from "./cache.js";
|
|
13
|
+
export * from "./fs.js";
|
|
14
|
+
export * from "./logger.js";
|
|
15
|
+
export * from "./glob.js";
|
|
16
|
+
export * from "./walk.js";
|
|
17
|
+
export * from "./topic-index.js";
|
|
18
|
+
export * from "./rejected.js";
|
|
19
|
+
export * from "./quality-grades.js";
|
|
20
|
+
export * from "./languages.js";
|
|
21
|
+
export * from "./components.js";
|
|
22
|
+
export * from "./component-registry.js";
|
|
23
|
+
export * from "./config.js";
|
|
24
|
+
export * from "./manifest.js";
|
|
25
|
+
export * from "./file-candidates-map.js";
|
|
26
|
+
export * from "./drift.js";
|
|
27
|
+
export * from "./alignment-pending.js";
|
|
28
|
+
export * from "./sot-cache.js";
|
|
29
|
+
export * from "./missions.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export * from "./schemas.js";
|
|
2
|
+
export * from "./home.js";
|
|
3
|
+
export * from "./paths.js";
|
|
4
|
+
export * from "./ledgers.js";
|
|
5
|
+
export * from "./archive.js";
|
|
6
|
+
export * from "./anchor-map.js";
|
|
7
|
+
export * from "./sot-bindings.js";
|
|
8
|
+
export * from "./scope-index.js";
|
|
9
|
+
export * from "./frontmatter.js";
|
|
10
|
+
export * from "./text.js";
|
|
11
|
+
export * from "./slug.js";
|
|
12
|
+
export * from "./cache.js";
|
|
13
|
+
export * from "./fs.js";
|
|
14
|
+
export * from "./logger.js";
|
|
15
|
+
export * from "./glob.js";
|
|
16
|
+
export * from "./walk.js";
|
|
17
|
+
export * from "./topic-index.js";
|
|
18
|
+
export * from "./rejected.js";
|
|
19
|
+
export * from "./quality-grades.js";
|
|
20
|
+
export * from "./languages.js";
|
|
21
|
+
export * from "./components.js";
|
|
22
|
+
export * from "./component-registry.js";
|
|
23
|
+
export * from "./config.js";
|
|
24
|
+
export * from "./manifest.js";
|
|
25
|
+
export * from "./file-candidates-map.js";
|
|
26
|
+
export * from "./drift.js";
|
|
27
|
+
export * from "./alignment-pending.js";
|
|
28
|
+
export * from "./sot-cache.js";
|
|
29
|
+
export * from "./missions.js";
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Language profile table — the single source of truth for every per-language
|
|
3
|
+
* mechanical fact Cairn needs: which extensions belong to a language, what
|
|
4
|
+
* comment forms a `@cairn` registry header may live in, how to pull the
|
|
5
|
+
* top-level exported/public symbols out of a source file, whether a file
|
|
6
|
+
* "looks like a reusable UI unit", and which style/class attributes its
|
|
7
|
+
* markup uses.
|
|
8
|
+
*
|
|
9
|
+
* Why a data table and not branching code: Cairn runs INSIDE an LLM coding
|
|
10
|
+
* agent, so semantic classification ("is this a component?", "what category?")
|
|
11
|
+
* is the model's job (see `detect-components.ts`). The *mechanical* facts —
|
|
12
|
+
* comment syntax, extension→language, export grammar — are pure lookup data
|
|
13
|
+
* that should be easy to extend by adding a row, never a crash or a silent
|
|
14
|
+
* JS/React default when a language is missing.
|
|
15
|
+
*
|
|
16
|
+
* This table is consumed by:
|
|
17
|
+
* - the component store (collection + audit) — export extraction, header
|
|
18
|
+
* comment-form parsing, unit-shape + style-attr detection;
|
|
19
|
+
* - the source-comment SoT walker — extension→`CommentLang` bucket;
|
|
20
|
+
* - the Layer-A stub-pattern sensor — extension→sensor language tag.
|
|
21
|
+
*
|
|
22
|
+
* A miss (extension not in the table) means "unknown": the file is skipped by
|
|
23
|
+
* language-scoped features, never coerced into TypeScript.
|
|
24
|
+
*/
|
|
25
|
+
import type { CommentLang } from "./schemas.js";
|
|
26
|
+
/** The comment syntaxes a registry header / essay comment can appear in. */
|
|
27
|
+
export type CommentForm = "block" | "line" | "hash" | "html" | "dash" | "docstring";
|
|
28
|
+
/**
|
|
29
|
+
* Sensor/stub-pattern language tag — an OPEN string equal to a language
|
|
30
|
+
* profile `id`. The registry IS the single source: any profile id (plus the
|
|
31
|
+
* stub-pattern catalog's special `"all"`) is a valid tag, so a new language
|
|
32
|
+
* becomes filterable just by living in the table. Common ids: typescript,
|
|
33
|
+
* javascript, python, ruby, go, rust, sql.
|
|
34
|
+
*/
|
|
35
|
+
export type SensorLang = string;
|
|
36
|
+
export interface LanguageProfile {
|
|
37
|
+
/** Canonical language id — "typescript", "vue", "swift", "kotlin", … */
|
|
38
|
+
id: string;
|
|
39
|
+
/** Extensions owned by this profile (lowercase, dot-prefixed). */
|
|
40
|
+
extensions: readonly string[];
|
|
41
|
+
/** Coarser bucket the source-comment walker groups by. */
|
|
42
|
+
commentLang: CommentLang;
|
|
43
|
+
/** Comment forms a `@cairn` header may be written in. */
|
|
44
|
+
commentForms: readonly CommentForm[];
|
|
45
|
+
/**
|
|
46
|
+
* Every top-level exported / public symbol name (order-preserving,
|
|
47
|
+
* de-duplicated). `basename` lets single-file-unit languages (Vue, Svelte,
|
|
48
|
+
* Astro, Razor) report the file stem as their export.
|
|
49
|
+
*/
|
|
50
|
+
exportSymbols(source: string, basename: string): string[];
|
|
51
|
+
/**
|
|
52
|
+
* Whether the file looks like a reusable UI unit (component / widget /
|
|
53
|
+
* view) for THIS language — PascalCase React component, Vue/Svelte SFC,
|
|
54
|
+
* SwiftUI `View` struct, Flutter `Widget`, Compose `@Composable`, etc.
|
|
55
|
+
* Backend / non-UI languages return false.
|
|
56
|
+
*/
|
|
57
|
+
isUnitShaped(source: string, basename: string): boolean;
|
|
58
|
+
/** Class/style attribute regexes for the inline-rebuild audit. */
|
|
59
|
+
styleAttrs: readonly RegExp[];
|
|
60
|
+
}
|
|
61
|
+
export declare const LANGUAGE_PROFILES: readonly LanguageProfile[];
|
|
62
|
+
/** Profile for a bare extension (`.tsx`), case-insensitive. Null when unknown. */
|
|
63
|
+
export declare function profileForExtension(ext: string): LanguageProfile | null;
|
|
64
|
+
/** Profile for a file path. Null when the extension isn't in the table. */
|
|
65
|
+
export declare function profileForFile(path: string): LanguageProfile | null;
|
|
66
|
+
/** Profile by canonical language id (`"vue"`). Null when unknown. */
|
|
67
|
+
export declare function profileForId(id: string): LanguageProfile | null;
|
|
68
|
+
/**
|
|
69
|
+
* Type-declaration keywords for a file's language (`struct`/`class`/`type`/…),
|
|
70
|
+
* or `[]` when the language has no nominal types or the extension is unknown.
|
|
71
|
+
* Single source for the audit's name-collision scan.
|
|
72
|
+
*/
|
|
73
|
+
export declare function typeDeclKeywordsForFile(path: string): readonly string[];
|
|
74
|
+
/**
|
|
75
|
+
* Extensions where reusable UI units live, across web + native frameworks.
|
|
76
|
+
* Used as the component-store default when a config omits `extensions`, so an
|
|
77
|
+
* absent signal scans every UI file type rather than silently assuming React
|
|
78
|
+
* `.tsx`/`.jsx`. (Excludes `.ts`/`.js` — those hold logic, not components.)
|
|
79
|
+
*/
|
|
80
|
+
export declare const UI_EXTENSIONS: readonly string[];
|
|
81
|
+
/**
|
|
82
|
+
* Whether `s` names a known language — a profile id. The open sensor-language
|
|
83
|
+
* registry: the stub-pattern catalog validates yaml `languages:` tags against
|
|
84
|
+
* this (plus its own `"all"`), so a typo is still rejected but any table
|
|
85
|
+
* language is accepted.
|
|
86
|
+
*/
|
|
87
|
+
export declare function isSensorLang(s: unknown): boolean;
|
|
88
|
+
/** Every extension the table knows about. */
|
|
89
|
+
export declare function knownExtensions(): string[];
|
|
90
|
+
/**
|
|
91
|
+
* The source-comment `CommentLang` bucket for a file, or `"unknown"` when the
|
|
92
|
+
* extension isn't in the table. Single source for the source-comment walker.
|
|
93
|
+
*/
|
|
94
|
+
export declare function commentLangForFile(path: string): CommentLang;
|
|
95
|
+
/**
|
|
96
|
+
* The sensor language tag for a file — the profile `id`, or `undefined` when
|
|
97
|
+
* the extension isn't in the table. Single source for the Layer-A
|
|
98
|
+
* stub-pattern catalog (a tag with no patterns simply matches nothing).
|
|
99
|
+
*/
|
|
100
|
+
export declare function sensorLangForFile(path: string): SensorLang | undefined;
|
|
101
|
+
/**
|
|
102
|
+
* Every top-level exported / public name in a source file, using the
|
|
103
|
+
* language profile for `basename`'s extension. Order-preserving, de-duplicated.
|
|
104
|
+
* Unknown extension → empty (caller treats as "no detectable exports").
|
|
105
|
+
*/
|
|
106
|
+
export declare function extractExportNames(source: string, basename: string): string[];
|
|
107
|
+
/**
|
|
108
|
+
* Best-effort single exported name — the likely `@cairn` value, used as the
|
|
109
|
+
* annotator's hint and for display. Prefers a PascalCase declaration (the
|
|
110
|
+
* unit convention) over hooks / SCREAMING_CASE constants. Null when nothing
|
|
111
|
+
* is exported.
|
|
112
|
+
*/
|
|
113
|
+
export declare function extractExportName(source: string, basename: string): string | null;
|