circle-ir-ai 4.34.0 → 4.35.2
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/CHANGELOG.md +27 -0
- package/dist/agents/mastra/workflow.d.ts +9 -0
- package/dist/agents/mastra/workflow.d.ts.map +1 -1
- package/dist/agents/mastra/workflow.js +12 -3
- package/dist/agents/mastra/workflow.js.map +1 -1
- package/dist/grid/index.d.ts +9 -0
- package/dist/grid/index.d.ts.map +1 -1
- package/dist/grid/index.js +19 -5
- package/dist/grid/index.js.map +1 -1
- package/dist/selectors/detect.d.ts +2 -0
- package/dist/selectors/detect.d.ts.map +1 -1
- package/dist/selectors/detect.js +1 -1
- package/dist/selectors/detect.js.map +1 -1
- package/dist/spec-gap/analyzer.js +30 -4
- package/dist/spec-gap/analyzer.js.map +1 -1
- package/dist/specifica/environment/diff.d.ts.map +1 -1
- package/dist/specifica/environment/diff.js +10 -2
- package/dist/specifica/environment/diff.js.map +1 -1
- package/dist/specifica/environment/index.d.ts +20 -3
- package/dist/specifica/environment/index.d.ts.map +1 -1
- package/dist/specifica/environment/index.js +40 -10
- package/dist/specifica/environment/index.js.map +1 -1
- package/dist/specifica/environment/merge.d.ts +12 -0
- package/dist/specifica/environment/merge.d.ts.map +1 -1
- package/dist/specifica/environment/merge.js +29 -6
- package/dist/specifica/environment/merge.js.map +1 -1
- package/dist/specifica/environment/read-ci.d.ts.map +1 -1
- package/dist/specifica/environment/read-ci.js +3 -2
- package/dist/specifica/environment/read-ci.js.map +1 -1
- package/dist/specifica/environment/read-compose.d.ts +17 -0
- package/dist/specifica/environment/read-compose.d.ts.map +1 -0
- package/dist/specifica/environment/read-compose.js +96 -0
- package/dist/specifica/environment/read-compose.js.map +1 -0
- package/dist/specifica/environment/read-docker.js +2 -2
- package/dist/specifica/environment/read-docker.js.map +1 -1
- package/dist/specifica/environment/read-dotenv.js +3 -3
- package/dist/specifica/environment/read-dotenv.js.map +1 -1
- package/dist/specifica/environment/read-wrangler.js +2 -2
- package/dist/specifica/environment/read-wrangler.js.map +1 -1
- package/dist/specifica/environment/secrets.d.ts +17 -2
- package/dist/specifica/environment/secrets.d.ts.map +1 -1
- package/dist/specifica/environment/secrets.js +67 -12
- package/dist/specifica/environment/secrets.js.map +1 -1
- package/dist/specifica/environment/write.d.ts +24 -1
- package/dist/specifica/environment/write.d.ts.map +1 -1
- package/dist/specifica/environment/write.js +183 -73
- package/dist/specifica/environment/write.js.map +1 -1
- package/dist/specifica/file-routes.d.ts +89 -0
- package/dist/specifica/file-routes.d.ts.map +1 -0
- package/dist/specifica/file-routes.js +374 -0
- package/dist/specifica/file-routes.js.map +1 -0
- package/dist/specifica/generator.d.ts.map +1 -1
- package/dist/specifica/generator.js +124 -2
- package/dist/specifica/generator.js.map +1 -1
- package/dist/specifica/index.d.ts +4 -1
- package/dist/specifica/index.d.ts.map +1 -1
- package/dist/specifica/index.js +4 -1
- package/dist/specifica/index.js.map +1 -1
- package/dist/specifica/layering.d.ts +140 -0
- package/dist/specifica/layering.d.ts.map +1 -0
- package/dist/specifica/layering.js +365 -0
- package/dist/specifica/layering.js.map +1 -0
- package/dist/specifica/learned-diff.d.ts +15 -1
- package/dist/specifica/learned-diff.d.ts.map +1 -1
- package/dist/specifica/learned-diff.js +63 -21
- package/dist/specifica/learned-diff.js.map +1 -1
- package/dist/specifica/learned-tree.d.ts +4 -0
- package/dist/specifica/learned-tree.d.ts.map +1 -1
- package/dist/specifica/learned-tree.js.map +1 -1
- package/dist/specifica/level-design.d.ts +170 -0
- package/dist/specifica/level-design.d.ts.map +1 -0
- package/dist/specifica/level-design.js +1253 -0
- package/dist/specifica/level-design.js.map +1 -0
- package/dist/specifica/library-surface.d.ts +62 -0
- package/dist/specifica/library-surface.d.ts.map +1 -0
- package/dist/specifica/library-surface.js +348 -0
- package/dist/specifica/library-surface.js.map +1 -0
- package/dist/specifica/modules.d.ts +37 -0
- package/dist/specifica/modules.d.ts.map +1 -0
- package/dist/specifica/modules.js +536 -0
- package/dist/specifica/modules.js.map +1 -0
- package/dist/specifica/spec-tree.d.ts +150 -0
- package/dist/specifica/spec-tree.d.ts.map +1 -0
- package/dist/specifica/spec-tree.js +689 -0
- package/dist/specifica/spec-tree.js.map +1 -0
- package/dist/specifica/tree-types.d.ts +228 -0
- package/dist/specifica/tree-types.d.ts.map +1 -0
- package/dist/specifica/tree-types.js +35 -0
- package/dist/specifica/tree-types.js.map +1 -0
- package/dist/specifica/tree-writer.d.ts +133 -0
- package/dist/specifica/tree-writer.d.ts.map +1 -0
- package/dist/specifica/tree-writer.js +402 -0
- package/dist/specifica/tree-writer.js.map +1 -0
- package/dist/specifica/types.d.ts +40 -0
- package/dist/specifica/types.d.ts.map +1 -1
- package/dist/specifica/use-cases.d.ts +80 -0
- package/dist/specifica/use-cases.d.ts.map +1 -0
- package/dist/specifica/use-cases.js +888 -0
- package/dist/specifica/use-cases.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File-based routing as entry points (spec recovery 0.2, SR-E2 follow-up).
|
|
3
|
+
*
|
|
4
|
+
* The file's place in the routes folder is the route:
|
|
5
|
+
*
|
|
6
|
+
* - **Next.js app router** — `app/**/page.tsx` (PAGE) and `app/**/route.ts`
|
|
7
|
+
* (one entry per exported `GET` / `POST` / …); route groups `(x)` and
|
|
8
|
+
* parallel slots `@slot` leave the URL, `[id]` → `:id`, `[...slug]` →
|
|
9
|
+
* `*slug`, `[[...slug]]` → `*slug?`; intercepting routes `(.)x` render a
|
|
10
|
+
* route that exists elsewhere and private folders `_x` are not routed, so
|
|
11
|
+
* both are skipped;
|
|
12
|
+
* - **Next.js pages router** — `pages/**` (PAGE) and `pages/api/**` (ANY),
|
|
13
|
+
* only in a module that imports `next`; `_app`, `_document` and other
|
|
14
|
+
* `_x` files are not pages;
|
|
15
|
+
* - **TanStack Router** — `createFileRoute('/path')` (the literal the router
|
|
16
|
+
* plugin writes), groups and pathless `_x` segments dropped, `$id` → `:id`;
|
|
17
|
+
* a pathless layout is not a page;
|
|
18
|
+
* - **Remix / React Router 7 flat routes** — `app/routes/a.$id.tsx`, only in a
|
|
19
|
+
* module that imports `@remix-run/*` or `@react-router/*`;
|
|
20
|
+
* - **SvelteKit** — `src/routes/**/+page(.server).ts` (PAGE) and `+server.ts`
|
|
21
|
+
* (one entry per exported verb);
|
|
22
|
+
* - **route config** — `createBrowserRouter([{ path, children }])` and the
|
|
23
|
+
* other React Router factories, TanStack `createRoute({ path })`;
|
|
24
|
+
* - **server actions** — every exported function of a `'use server'` file
|
|
25
|
+
* (handler, method `ACTION`).
|
|
26
|
+
*
|
|
27
|
+
* Pure. Facts from circle-ir's IR (imports, calls, declarations); source text
|
|
28
|
+
* is read for the file-level `'use server'` directive and `export default`,
|
|
29
|
+
* which the IR does not carry.
|
|
30
|
+
*/
|
|
31
|
+
const VERB_EXPORTS = new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTIONS']);
|
|
32
|
+
const CODE_EXT = /\.(tsx?|jsx?|mdx|mjs|cjs)$/;
|
|
33
|
+
function importsFrom(ir, test) {
|
|
34
|
+
return (ir.imports ?? []).some(i => !!i.from_package && test(i.from_package));
|
|
35
|
+
}
|
|
36
|
+
export function fileRouteSignals(files) {
|
|
37
|
+
return {
|
|
38
|
+
next: files.some(f => importsFrom(f.ir, p => p === 'next' || p.startsWith('next/'))),
|
|
39
|
+
remix: files.some(f => importsFrom(f.ir, p => p.startsWith('@remix-run/') || p.startsWith('@react-router/'))),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** Collapse slashes, drop a trailing slash; the root is `/`. */
|
|
43
|
+
function cleanPath(segs) {
|
|
44
|
+
const p = '/' + segs.filter(Boolean).join('/');
|
|
45
|
+
return p.length > 1 ? p.replace(/\/+$/, '') : p;
|
|
46
|
+
}
|
|
47
|
+
/** Next.js / SvelteKit dynamic segment → `:id`, `*slug`, `*slug?`, `:opt?`. */
|
|
48
|
+
function bracketSegment(seg) {
|
|
49
|
+
let m = /^\[\[\.\.\.([^\]]+)\]\]$/.exec(seg);
|
|
50
|
+
if (m)
|
|
51
|
+
return `*${m[1]}?`;
|
|
52
|
+
m = /^\[\.\.\.([^\]=]+)(=[^\]]+)?\]$/.exec(seg);
|
|
53
|
+
if (m)
|
|
54
|
+
return `*${m[1]}`;
|
|
55
|
+
m = /^\[\[([^\]=]+)(=[^\]]+)?\]\]$/.exec(seg);
|
|
56
|
+
if (m)
|
|
57
|
+
return `:${m[1]}?`;
|
|
58
|
+
m = /^\[([^\]=]+)(=[^\]]+)?\]$/.exec(seg);
|
|
59
|
+
if (m)
|
|
60
|
+
return `:${m[1]}`;
|
|
61
|
+
return seg;
|
|
62
|
+
}
|
|
63
|
+
/** The module-relative path of a file. */
|
|
64
|
+
function relTo(file, moduleRoot) {
|
|
65
|
+
return moduleRoot && file.startsWith(moduleRoot + '/') ? file.slice(moduleRoot.length + 1) : file;
|
|
66
|
+
}
|
|
67
|
+
function exportedDefault(code, fns) {
|
|
68
|
+
const lines = code.split('\n');
|
|
69
|
+
const at = fns.find(f => /\bexport\s+default\b/.test(lines[f.start - 1] ?? ''));
|
|
70
|
+
if (at)
|
|
71
|
+
return at;
|
|
72
|
+
const name = /^export\s+default\s+(?:async\s+)?(?:function\s+)?([A-Za-z_$][\w$]*)\s*;?\s*$/m.exec(code)?.[1];
|
|
73
|
+
return name ? fns.find(f => f.name === name) : undefined;
|
|
74
|
+
}
|
|
75
|
+
function hasDefaultExport(code) {
|
|
76
|
+
return /^export\s+default\b/m.test(code) || /^export\s*\{[^}]*\bdefault\b[^}]*\}/m.test(code);
|
|
77
|
+
}
|
|
78
|
+
function whole(code) {
|
|
79
|
+
return { start: 1, end: Math.max(1, code.split('\n').length) };
|
|
80
|
+
}
|
|
81
|
+
function pageFound(file, code, fns, p) {
|
|
82
|
+
const fn = exportedDefault(code, fns);
|
|
83
|
+
return fn
|
|
84
|
+
? { kind: 'route', file, method: 'PAGE', path: p, symbol: fn.symbol, span: { start: fn.start, end: fn.end } }
|
|
85
|
+
: { kind: 'route', file, method: 'PAGE', path: p, span: whole(code) };
|
|
86
|
+
}
|
|
87
|
+
/** One entry per exported HTTP-verb function (Next `route.ts`, SvelteKit `+server.ts`). */
|
|
88
|
+
function verbFound(file, fns, p, exported) {
|
|
89
|
+
return fns
|
|
90
|
+
.filter(f => f.symbol === f.name && VERB_EXPORTS.has(f.name) && exported.has(f.name))
|
|
91
|
+
.map(f => ({ kind: 'route', file, method: f.name, path: p, symbol: f.name, span: { start: f.start, end: f.end } }));
|
|
92
|
+
}
|
|
93
|
+
function exportedNames(ir) {
|
|
94
|
+
return new Set((ir.exports ?? []).map(e => e.symbol));
|
|
95
|
+
}
|
|
96
|
+
// ─── Next.js ─────────────────────────────────────────────────────────
|
|
97
|
+
const NEXT_APP = /^(?:(.*)\/)?(?:src\/)?app\/((?:[^/]+\/)*)(page|route)\.(tsx?|jsx?|mdx)$/;
|
|
98
|
+
function nextAppEntry(rel, file, code, ir, fns) {
|
|
99
|
+
const m = NEXT_APP.exec(rel);
|
|
100
|
+
if (!m || (m[1] ?? '').split('/').some(s => s === 'node_modules'))
|
|
101
|
+
return undefined;
|
|
102
|
+
const segs = [];
|
|
103
|
+
for (const raw of (m[2] ?? '').split('/').filter(Boolean)) {
|
|
104
|
+
if (raw.startsWith('_'))
|
|
105
|
+
return []; // private folder: not routed
|
|
106
|
+
if (/^\(\.{1,3}\)/.test(raw) || raw.startsWith('(..)'))
|
|
107
|
+
return []; // intercepting route
|
|
108
|
+
if (/^\(.*\)$/.test(raw) || raw.startsWith('@'))
|
|
109
|
+
continue; // group, parallel slot
|
|
110
|
+
segs.push(bracketSegment(raw));
|
|
111
|
+
}
|
|
112
|
+
const p = cleanPath(segs);
|
|
113
|
+
return m[3] === 'page' ? [pageFound(file, code, fns, p)] : verbFound(file, fns, p, exportedNames(ir));
|
|
114
|
+
}
|
|
115
|
+
const NEXT_PAGES = /^(?:src\/)?pages\/(.+)$/;
|
|
116
|
+
function nextPagesEntry(rel, file, code, fns) {
|
|
117
|
+
const m = NEXT_PAGES.exec(rel);
|
|
118
|
+
if (!m || !CODE_EXT.test(m[1]))
|
|
119
|
+
return undefined;
|
|
120
|
+
const parts = m[1].replace(CODE_EXT, '').split('/');
|
|
121
|
+
if (parts.some(s => s.startsWith('_')))
|
|
122
|
+
return []; // _app, _document, _error, private
|
|
123
|
+
const isApi = parts[0] === 'api';
|
|
124
|
+
if (parts[parts.length - 1] === 'index')
|
|
125
|
+
parts.pop();
|
|
126
|
+
const p = cleanPath(parts.map(bracketSegment));
|
|
127
|
+
if (!isApi)
|
|
128
|
+
return hasDefaultExport(code) ? [pageFound(file, code, fns, p)] : [];
|
|
129
|
+
const fn = exportedDefault(code, fns);
|
|
130
|
+
return [{ kind: 'route', file, method: 'ANY', path: p, ...(fn ? { symbol: fn.symbol, span: { start: fn.start, end: fn.end } } : { span: whole(code) }) }];
|
|
131
|
+
}
|
|
132
|
+
// ─── TanStack Router ─────────────────────────────────────────────────
|
|
133
|
+
/** `/(app)/r/$repoId/runs/` → `/r/:repoId/runs`; undefined for a pathless layout. */
|
|
134
|
+
export function tanstackPath(literal) {
|
|
135
|
+
const raw = literal.split('/').filter(Boolean);
|
|
136
|
+
const last = raw[raw.length - 1];
|
|
137
|
+
if (last && (/^_/.test(last) || /^\(.*\)$/.test(last)))
|
|
138
|
+
return undefined; // pathless layout / group layout
|
|
139
|
+
const segs = [];
|
|
140
|
+
for (const s of raw) {
|
|
141
|
+
if (/^\(.*\)$/.test(s) || s.startsWith('_'))
|
|
142
|
+
continue;
|
|
143
|
+
const seg = s.replace(/_$/, '');
|
|
144
|
+
if (seg === 'index' || seg === 'route')
|
|
145
|
+
continue;
|
|
146
|
+
if (seg === '$')
|
|
147
|
+
segs.push('*');
|
|
148
|
+
else if (/^\{-\$([\w]+)\}$/.test(seg))
|
|
149
|
+
segs.push(`:${/^\{-\$([\w]+)\}$/.exec(seg)[1]}?`);
|
|
150
|
+
else if (seg.startsWith('$'))
|
|
151
|
+
segs.push(`:${seg.slice(1)}`);
|
|
152
|
+
else
|
|
153
|
+
segs.push(seg);
|
|
154
|
+
}
|
|
155
|
+
return cleanPath(segs);
|
|
156
|
+
}
|
|
157
|
+
function tanstackEntries(file, ir, fns) {
|
|
158
|
+
if (!importsFrom(ir, p => /^@tanstack\/[\w-]*router/.test(p)))
|
|
159
|
+
return [];
|
|
160
|
+
const out = [];
|
|
161
|
+
for (const c of ir.calls ?? []) {
|
|
162
|
+
if (c.method_name !== 'createFileRoute' && c.method_name !== 'createLazyFileRoute')
|
|
163
|
+
continue;
|
|
164
|
+
const lit = c.arguments?.[0]?.literal;
|
|
165
|
+
const line = c.location?.line;
|
|
166
|
+
if (typeof lit !== 'string' || !line)
|
|
167
|
+
continue;
|
|
168
|
+
const p = tanstackPath(lit);
|
|
169
|
+
if (p === undefined)
|
|
170
|
+
continue;
|
|
171
|
+
// The options call on the same line (`createFileRoute('/x')({ component: X })`) names the component.
|
|
172
|
+
const opts = (ir.calls ?? []).find(o => o.location?.line === line && o.method_name.startsWith(`${c.method_name}(`));
|
|
173
|
+
const comp = /\bcomponent\s*:\s*([A-Za-z_$][\w$]*)/.exec(opts?.arguments?.[0]?.expression ?? '')?.[1];
|
|
174
|
+
const fn = comp ? fns.find(f => f.name === comp) : undefined;
|
|
175
|
+
out.push(fn
|
|
176
|
+
? { kind: 'route', file, method: 'PAGE', path: p, symbol: fn.symbol, span: { start: fn.start, end: fn.end }, site: line }
|
|
177
|
+
: { kind: 'route', file, method: 'PAGE', path: p, span: { start: line, end: line } });
|
|
178
|
+
}
|
|
179
|
+
return out;
|
|
180
|
+
}
|
|
181
|
+
// ─── Remix / React Router 7 flat routes ──────────────────────────────
|
|
182
|
+
const REMIX = /^(?:(.*)\/)?app\/routes\/(.+)$/;
|
|
183
|
+
/** `a.$id._index.tsx` / `a.$id/route.tsx` → `/a/:id`; undefined when not a route module. */
|
|
184
|
+
export function remixPath(name) {
|
|
185
|
+
const parts = name.split('/');
|
|
186
|
+
let stem;
|
|
187
|
+
if (parts.length === 1)
|
|
188
|
+
stem = parts[0].replace(CODE_EXT, '');
|
|
189
|
+
else if (parts.length === 2 && /^route\.(tsx?|jsx?)$/.test(parts[1]))
|
|
190
|
+
stem = parts[0];
|
|
191
|
+
else
|
|
192
|
+
return undefined;
|
|
193
|
+
const segs = [];
|
|
194
|
+
for (const s of stem.split('.')) {
|
|
195
|
+
if (s === '_index' || s === 'route')
|
|
196
|
+
continue;
|
|
197
|
+
if (s.startsWith('_'))
|
|
198
|
+
continue; // pathless layout
|
|
199
|
+
const seg = s.replace(/_$/, '');
|
|
200
|
+
const opt = /^\((\$?[\w-]+)\)$/.exec(seg);
|
|
201
|
+
if (opt) {
|
|
202
|
+
segs.push(opt[1].startsWith('$') ? `:${opt[1].slice(1)}?` : `${opt[1]}?`);
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
if (seg === '$')
|
|
206
|
+
segs.push('*');
|
|
207
|
+
else if (seg.startsWith('$'))
|
|
208
|
+
segs.push(`:${seg.slice(1)}`);
|
|
209
|
+
else
|
|
210
|
+
segs.push(seg);
|
|
211
|
+
}
|
|
212
|
+
return cleanPath(segs);
|
|
213
|
+
}
|
|
214
|
+
function remixEntry(rel, file, code, fns) {
|
|
215
|
+
const m = REMIX.exec(rel);
|
|
216
|
+
if (!m)
|
|
217
|
+
return undefined;
|
|
218
|
+
const p = remixPath(m[2]);
|
|
219
|
+
if (p === undefined)
|
|
220
|
+
return [];
|
|
221
|
+
if (hasDefaultExport(code))
|
|
222
|
+
return [pageFound(file, code, fns, p)];
|
|
223
|
+
// A resource route: loader → GET, action → POST.
|
|
224
|
+
const out = [];
|
|
225
|
+
for (const [name, verb] of [['loader', 'GET'], ['action', 'POST']]) {
|
|
226
|
+
const fn = fns.find(f => f.symbol === name);
|
|
227
|
+
if (fn)
|
|
228
|
+
out.push({ kind: 'route', file, method: verb, path: p, symbol: name, span: { start: fn.start, end: fn.end } });
|
|
229
|
+
}
|
|
230
|
+
return out;
|
|
231
|
+
}
|
|
232
|
+
// ─── SvelteKit ───────────────────────────────────────────────────────
|
|
233
|
+
const SVELTE = /^(?:(.*)\/)?src\/routes\/((?:[^/]+\/)*)\+(page|server)(\.server)?\.(ts|js)$/;
|
|
234
|
+
function svelteEntry(rel, file, code, ir, fns) {
|
|
235
|
+
const m = SVELTE.exec(rel);
|
|
236
|
+
if (!m)
|
|
237
|
+
return undefined;
|
|
238
|
+
const segs = (m[2] ?? '').split('/').filter(Boolean).filter(s => !/^\(.*\)$/.test(s)).map(bracketSegment);
|
|
239
|
+
const p = cleanPath(segs);
|
|
240
|
+
if (m[3] === 'server')
|
|
241
|
+
return verbFound(file, fns, p, exportedNames(ir));
|
|
242
|
+
const load = fns.find(f => f.symbol === 'load');
|
|
243
|
+
return [load
|
|
244
|
+
? { kind: 'route', file, method: 'PAGE', path: p, symbol: 'load', span: { start: load.start, end: load.end } }
|
|
245
|
+
: { kind: 'route', file, method: 'PAGE', path: p, span: whole(code) }];
|
|
246
|
+
}
|
|
247
|
+
/** File-system routes of one file. */
|
|
248
|
+
export function fileRouteEntries(sf, fns, moduleRoot, signals) {
|
|
249
|
+
const { file, code, ir } = sf;
|
|
250
|
+
const tan = tanstackEntries(file, ir, fns);
|
|
251
|
+
if (tan.length > 0)
|
|
252
|
+
return tan;
|
|
253
|
+
const rel = relTo(file, moduleRoot);
|
|
254
|
+
if (signals.remix) {
|
|
255
|
+
const r = remixEntry(rel, file, code, fns);
|
|
256
|
+
if (r)
|
|
257
|
+
return r;
|
|
258
|
+
}
|
|
259
|
+
const app = nextAppEntry(rel, file, code, ir, fns);
|
|
260
|
+
if (app)
|
|
261
|
+
return app;
|
|
262
|
+
if (signals.next) {
|
|
263
|
+
const pages = nextPagesEntry(rel, file, code, fns);
|
|
264
|
+
if (pages)
|
|
265
|
+
return pages;
|
|
266
|
+
}
|
|
267
|
+
return svelteEntry(rel, file, code, ir, fns) ?? [];
|
|
268
|
+
}
|
|
269
|
+
// ─── Route config (React Router objects, TanStack code-based) ────────
|
|
270
|
+
const ROUTER_FACTORIES = new Set(['createBrowserRouter', 'createHashRouter', 'createMemoryRouter', 'createStaticRouter', 'useRoutes']);
|
|
271
|
+
/** Every `path: '…'` in a route-object tree, joined with its ancestors' paths; with its line offset. */
|
|
272
|
+
export function configPaths(text) {
|
|
273
|
+
const out = [];
|
|
274
|
+
const stack = [];
|
|
275
|
+
let depth = 0;
|
|
276
|
+
let line = 0;
|
|
277
|
+
let quote;
|
|
278
|
+
for (let i = 0; i < text.length; i++) {
|
|
279
|
+
const ch = text[i];
|
|
280
|
+
if (ch === '\n')
|
|
281
|
+
line++;
|
|
282
|
+
if (quote) {
|
|
283
|
+
if (ch === '\\')
|
|
284
|
+
i++;
|
|
285
|
+
else if (ch === quote)
|
|
286
|
+
quote = undefined;
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
if (ch === '/' && text[i + 1] === '/') {
|
|
290
|
+
const nl = text.indexOf('\n', i);
|
|
291
|
+
i = (nl < 0 ? text.length : nl) - 1;
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
if (ch === '{') {
|
|
295
|
+
depth++;
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
if (ch === '}') {
|
|
299
|
+
depth--;
|
|
300
|
+
while (stack.length && stack[stack.length - 1].depth > depth)
|
|
301
|
+
stack.pop();
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (ch === "'" || ch === '"' || ch === '`') {
|
|
305
|
+
quote = ch;
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
const m = /^path\s*:\s*(['"`])([^'"`$]*)\1/.exec(text.slice(i, i + 200));
|
|
309
|
+
if (m && !/[\w$]/.test(text[i - 1] ?? '')) {
|
|
310
|
+
while (stack.length && stack[stack.length - 1].depth >= depth)
|
|
311
|
+
stack.pop();
|
|
312
|
+
const own = m[2];
|
|
313
|
+
const parent = stack.length ? stack[stack.length - 1].path : '';
|
|
314
|
+
const full = own.startsWith('/') ? own : `${parent.replace(/\/$/, '')}/${own}`;
|
|
315
|
+
stack.push({ depth, path: full });
|
|
316
|
+
out.push({ path: full, offset: line });
|
|
317
|
+
i += m[0].length - 1;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return out;
|
|
321
|
+
}
|
|
322
|
+
function configPathClean(p) {
|
|
323
|
+
return cleanPath(p.split('/').filter(Boolean).map(s => (s === '*' ? '*' : s)));
|
|
324
|
+
}
|
|
325
|
+
export function routerConfigEntries(sf) {
|
|
326
|
+
const { file, ir } = sf;
|
|
327
|
+
const out = [];
|
|
328
|
+
for (const c of ir.calls ?? []) {
|
|
329
|
+
const line = c.location?.line;
|
|
330
|
+
if (!line)
|
|
331
|
+
continue;
|
|
332
|
+
const arg = c.arguments?.[0]?.expression ?? '';
|
|
333
|
+
if (ROUTER_FACTORIES.has(c.method_name) && !c.receiver && /^\s*\[/.test(arg)) {
|
|
334
|
+
for (const p of configPaths(arg)) {
|
|
335
|
+
const at = line + p.offset;
|
|
336
|
+
out.push({ kind: 'route', file, method: 'PAGE', path: configPathClean(p.path), span: { start: at, end: at } });
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
else if (c.method_name === 'createRoute' && !c.receiver && /^\s*\{/.test(arg) && importsFrom(ir, p => /^@tanstack\/[\w-]*router/.test(p))) {
|
|
340
|
+
const m = /\bpath\s*:\s*(['"`])([^'"`$]*)\1/.exec(arg);
|
|
341
|
+
if (m) {
|
|
342
|
+
const p = tanstackPath(m[2].startsWith('/') ? m[2] : `/${m[2]}`);
|
|
343
|
+
if (p !== undefined)
|
|
344
|
+
out.push({ kind: 'route', file, method: 'PAGE', path: p, span: { start: line, end: line } });
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return out;
|
|
349
|
+
}
|
|
350
|
+
// ─── Server actions ──────────────────────────────────────────────────
|
|
351
|
+
/** The file's first statement is the `'use server'` directive. */
|
|
352
|
+
export function isUseServerFile(code) {
|
|
353
|
+
const body = code.replace(/^/, '').replace(/^(\s*(\/\/[^\n]*\n|\/\*[\s\S]*?\*\/))*\s*/, '');
|
|
354
|
+
return /^(['"])use server\1\s*;?\s*(\n|$)/.test(body);
|
|
355
|
+
}
|
|
356
|
+
export function serverActionEntries(sf, fns) {
|
|
357
|
+
const { file, code, ir } = sf;
|
|
358
|
+
if (!isUseServerFile(code))
|
|
359
|
+
return [];
|
|
360
|
+
const exported = exportedNames(ir);
|
|
361
|
+
return fns
|
|
362
|
+
.filter(f => f.symbol === f.name && exported.has(f.name))
|
|
363
|
+
.map(f => ({ kind: 'handler', file, method: 'ACTION', symbol: f.name, span: { start: f.start, end: f.end } }));
|
|
364
|
+
}
|
|
365
|
+
/** The route path a Next.js app-router directory serves (for a server action's area), else undefined. */
|
|
366
|
+
export function appDirRoute(file, moduleRoot) {
|
|
367
|
+
const rel = relTo(file, moduleRoot);
|
|
368
|
+
const m = /^(?:(?:.*)\/)?(?:src\/)?app\/((?:[^/]+\/)*)[^/]+$/.exec(rel);
|
|
369
|
+
if (!m)
|
|
370
|
+
return undefined;
|
|
371
|
+
const segs = (m[1] ?? '').split('/').filter(Boolean).filter(s => !/^\(.*\)$/.test(s) && !s.startsWith('@') && !s.startsWith('_')).map(bracketSegment);
|
|
372
|
+
return segs.length ? cleanPath(segs) : undefined;
|
|
373
|
+
}
|
|
374
|
+
//# sourceMappingURL=file-routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-routes.js","sourceRoot":"","sources":["../../src/specifica/file-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAyBH,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAA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,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACtJ,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACnD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/specifica/generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/specifica/generator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAqBH,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAMhB,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,eAAe,CAAC,CAwE1B;AAED;;;GAGG;AACH,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,eAAe,EAAE,CAAC,CA2U5B"}
|
|
@@ -17,6 +17,7 @@ import { generatePrinciples } from './principles-generator.js';
|
|
|
17
17
|
import { generateTasks } from './tasks-generator.js';
|
|
18
18
|
import { calculateFanIn } from './infrastructure-filter.js';
|
|
19
19
|
import { assignRuleKeys, attachStableIds, relativizeProvenance, summarizeProvenance } from './provenance.js';
|
|
20
|
+
import { levelFilePaths } from './tree-writer.js';
|
|
20
21
|
import { moduleSpecLocation, projectFilePath, resolveSubjectCommit, writeModuleSpec } from './learned-tree.js';
|
|
21
22
|
/**
|
|
22
23
|
* Generate Specifica specification from a single file
|
|
@@ -101,6 +102,10 @@ export async function generateSpecificaForDirectory(dirPath, options = {}) {
|
|
|
101
102
|
throw new Error(`No source files found in ${dirPath}`);
|
|
102
103
|
}
|
|
103
104
|
const mixedLanguage = mixedLanguageOn(options);
|
|
105
|
+
// Spec recovery 0.2: the learned tree, unless the 0.1 layout is asked for.
|
|
106
|
+
const treeLayout = treeLayoutOn(options);
|
|
107
|
+
// The tree's public-API use cases need declaration detail (a library's exports).
|
|
108
|
+
const detail = treeLayout && options.declarationDetail !== false ? { declarationDetail: true } : analyzerDetail(options);
|
|
104
109
|
if (!options.quiet) {
|
|
105
110
|
console.error(`Found ${files.length} source files`);
|
|
106
111
|
}
|
|
@@ -108,6 +113,8 @@ export async function generateSpecificaForDirectory(dirPath, options = {}) {
|
|
|
108
113
|
const evidenceList = [];
|
|
109
114
|
const extendedEvidenceList = [];
|
|
110
115
|
const irResults = [];
|
|
116
|
+
/** Tree layout: each analysed file with its code (same order as evidenceList). */
|
|
117
|
+
const analysed = [];
|
|
111
118
|
// Pre-calculate fan-in for extended evidence if design generation is enabled
|
|
112
119
|
let fanInMap;
|
|
113
120
|
for (let i = 0; i < files.length; i++) {
|
|
@@ -127,10 +134,11 @@ export async function generateSpecificaForDirectory(dirPath, options = {}) {
|
|
|
127
134
|
}
|
|
128
135
|
const code = flight.content;
|
|
129
136
|
const language = detectLanguage(file, mixedLanguage);
|
|
130
|
-
const analysis = await analyze(code, file, language,
|
|
137
|
+
const analysis = await analyze(code, file, language, detail);
|
|
131
138
|
const evidence = extractEvidence(file, code, analysis, { ownPackage: mixedLanguage });
|
|
132
139
|
evidenceList.push(evidence);
|
|
133
140
|
irResults.push(analysis);
|
|
141
|
+
analysed.push({ file, code });
|
|
134
142
|
}
|
|
135
143
|
catch (error) {
|
|
136
144
|
console.error(`Failed to analyze ${file}:`, error instanceof Error ? error.message : String(error));
|
|
@@ -139,6 +147,9 @@ export async function generateSpecificaForDirectory(dirPath, options = {}) {
|
|
|
139
147
|
if (evidenceList.length === 0) {
|
|
140
148
|
throw new Error('Failed to analyze any files');
|
|
141
149
|
}
|
|
150
|
+
if (treeLayout) {
|
|
151
|
+
return generateTreeOutputs(dirPath, options, analysed, evidenceList, irResults);
|
|
152
|
+
}
|
|
142
153
|
// Calculate fan-in if design generation is enabled
|
|
143
154
|
if (options.generateDesign && irResults.length > 0) {
|
|
144
155
|
fanInMap = calculateFanIn(irResults);
|
|
@@ -275,7 +286,7 @@ export async function generateSpecificaForDirectory(dirPath, options = {}) {
|
|
|
275
286
|
const { writeLearnedEnvironment } = await import('./environment/index.js');
|
|
276
287
|
const root = options.outputDir || findProjectRoot(dirPath);
|
|
277
288
|
const head = resolveSubjectCommit(root, options.subjectCommit);
|
|
278
|
-
const { path: envPath } = await writeLearnedEnvironment(root, { learnedDir: options.learnedDir, commit: head.commit });
|
|
289
|
+
const { path: envPath } = await writeLearnedEnvironment(root, { learnedDir: options.learnedDir, commit: head.commit, explicitOutputDir: Boolean(options.outputDir) });
|
|
279
290
|
if (!options.quiet) {
|
|
280
291
|
console.error(` ✓ Generated: ${envPath}`);
|
|
281
292
|
}
|
|
@@ -366,6 +377,117 @@ export async function generateSpecificaForDirectory(dirPath, options = {}) {
|
|
|
366
377
|
}
|
|
367
378
|
return outputs;
|
|
368
379
|
}
|
|
380
|
+
/** Spec recovery 0.2: the tree layout is the default; `legacyOutput` and `specLayout: 'features'` keep 0.1. */
|
|
381
|
+
function treeLayoutOn(options) {
|
|
382
|
+
return !options.legacyOutput && options.specLayout !== 'features';
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Spec recovery 0.2: build and write the learned tree (`spec-tree.ts`), and
|
|
386
|
+
* report one output per level (repository first) so callers that read
|
|
387
|
+
* `specPath` / `rulesPath` keep working.
|
|
388
|
+
*/
|
|
389
|
+
async function generateTreeOutputs(dirPath, options, analysed, evidenceList, irResults) {
|
|
390
|
+
const { generateSpecTree, llmTreePhraser, treeLineCounts } = await import('./spec-tree.js');
|
|
391
|
+
const projectRoot = options.outputDir || findProjectRoot(dirPath);
|
|
392
|
+
const subject = resolveSubjectCommit(projectRoot, options.subjectCommit);
|
|
393
|
+
// Learned conventions (principles-generator) read extended evidence.
|
|
394
|
+
const fanIn = calculateFanIn(irResults);
|
|
395
|
+
const files = [];
|
|
396
|
+
for (let i = 0; i < analysed.length; i++) {
|
|
397
|
+
const { file, code } = analysed[i];
|
|
398
|
+
let extended;
|
|
399
|
+
try {
|
|
400
|
+
extended = await extractExtendedEvidence(file, code, irResults[i], { fanInData: fanIn });
|
|
401
|
+
}
|
|
402
|
+
catch {
|
|
403
|
+
extended = undefined;
|
|
404
|
+
}
|
|
405
|
+
const rel = path.relative(projectRoot, file).split(path.sep).join('/');
|
|
406
|
+
if (rel.startsWith('../'))
|
|
407
|
+
continue; // outside the project
|
|
408
|
+
files.push({ abs: file, rel, code, ir: irResults[i], evidence: evidenceList[i], ...(extended ? { extended } : {}) });
|
|
409
|
+
}
|
|
410
|
+
let environment;
|
|
411
|
+
let environmentFolder;
|
|
412
|
+
if (options.environment !== false) {
|
|
413
|
+
try {
|
|
414
|
+
const { learnEnvironment } = await import('./environment/index.js');
|
|
415
|
+
const learnedEnv = await learnEnvironment(projectRoot, { commit: subject.commit });
|
|
416
|
+
// Over ~100 lines as one file → environment/{environments,build,config,secrets}.md.
|
|
417
|
+
if (learnedEnv.form === 'folder' && learnedEnv.parts)
|
|
418
|
+
environmentFolder = learnedEnv.parts;
|
|
419
|
+
else
|
|
420
|
+
environment = learnedEnv.markdown;
|
|
421
|
+
}
|
|
422
|
+
catch (error) {
|
|
423
|
+
console.error('Failed to generate environment.md:', error instanceof Error ? error.message : String(error));
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
// Model arm: phrases only, from the deterministic facts (spend is opt-in: skipLLM false).
|
|
427
|
+
// Only with a model route or a named specModel, and never under skipLLM.
|
|
428
|
+
const { activeModelLabel, isInLLMRoute } = await import('../llm/model-route.js');
|
|
429
|
+
const phraser = options.skipLLM || !(isInLLMRoute() || options.specModel)
|
|
430
|
+
? undefined
|
|
431
|
+
: llmTreePhraser(activeModelLabel(options.specModel || process.env.LLM_ENRICHMENT_MODEL || 'cognium/gpt-oss-120b'), options.specModel);
|
|
432
|
+
const built = await generateSpecTree({
|
|
433
|
+
projectRoot,
|
|
434
|
+
scanRoot: dirPath,
|
|
435
|
+
files,
|
|
436
|
+
engineVersion: getVersion(),
|
|
437
|
+
subject,
|
|
438
|
+
...(environment !== undefined ? { environment } : {}),
|
|
439
|
+
...(environmentFolder ? { environmentFolder } : {}),
|
|
440
|
+
attachStableIds: attachStableIdsFromTree,
|
|
441
|
+
...(phraser ? { phraser } : {}),
|
|
442
|
+
learnedDir: options.learnedDir,
|
|
443
|
+
explicitOutputDir: Boolean(options.outputDir),
|
|
444
|
+
});
|
|
445
|
+
const counts = treeLineCounts(built.tree);
|
|
446
|
+
const outputs = [];
|
|
447
|
+
for (const b of built.levels) {
|
|
448
|
+
const l = b.level;
|
|
449
|
+
const rel = levelFilePaths(l);
|
|
450
|
+
const at = (p) => path.join(built.write.treeDir, ...p.split('/'));
|
|
451
|
+
const lines = counts.find(c => c.level === (l.level === 'repo' ? '(repository)' : l.path));
|
|
452
|
+
const phrased = b.phrased.useCases + b.phrased.layers > 0;
|
|
453
|
+
const metadata = {
|
|
454
|
+
generatedAt: new Date().toISOString(),
|
|
455
|
+
generator: 'circle-ir-ai/specifica',
|
|
456
|
+
version: getVersion(),
|
|
457
|
+
model: phrased && phraser ? phraser.model : 'static-generation',
|
|
458
|
+
filesAnalyzed: b.files.length,
|
|
459
|
+
reviewRequired: true,
|
|
460
|
+
provenance: l.rules.metadata.provenance,
|
|
461
|
+
};
|
|
462
|
+
outputs.push({
|
|
463
|
+
featureName: l.name,
|
|
464
|
+
outputPath: path.join(built.write.treeDir, ...(l.path ? l.path.split('/') : [])),
|
|
465
|
+
specPath: at(rel.spec),
|
|
466
|
+
layout: 'learned',
|
|
467
|
+
...(rel.rules ? { rulesPath: at(rel.rules) } : {}),
|
|
468
|
+
subject,
|
|
469
|
+
spec: { title: l.name, summary: '', requirements: b.domainRules, edgeCases: [], errorScenarios: [] },
|
|
470
|
+
metadata,
|
|
471
|
+
generationMethod: phrased ? 'llm' : 'static',
|
|
472
|
+
...(!phrased ? { fallbackReason: phraser ? 'unusable_answer' : 'model_off' } : {}),
|
|
473
|
+
treeLevel: {
|
|
474
|
+
level: l.level,
|
|
475
|
+
path: l.path,
|
|
476
|
+
sourceRoot: l.sourceRoot,
|
|
477
|
+
useCases: b.useCases.length,
|
|
478
|
+
domainRules: b.domainRules.length,
|
|
479
|
+
lines: { principles: lines.principles, ...(lines.environment !== undefined ? { environment: lines.environment } : {}), ...(lines.environmentFolder ? { environmentFolder: lines.environmentFolder } : {}), spec: lines.spec, design: lines.design, tasks: lines.tasks },
|
|
480
|
+
specMode: b.specMode,
|
|
481
|
+
},
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
if (!options.quiet) {
|
|
485
|
+
for (const w of built.write.warnings)
|
|
486
|
+
console.error(` ⚠ ${w.message}`);
|
|
487
|
+
console.error(`\n✓ Learned spec tree: ${built.levels.length} level(s) (${built.modules.length} module(s)) in ${built.write.treeDir}`);
|
|
488
|
+
}
|
|
489
|
+
return outputs;
|
|
490
|
+
}
|
|
369
491
|
/** E07: circle-ir's `declarationDetail` (4.18.0 and later) when asked for. */
|
|
370
492
|
function analyzerDetail(options) {
|
|
371
493
|
return options.declarationDetail ? { declarationDetail: true } : {};
|