@akanjs/cli 3.2.0-rc.18 → 3.2.0-rc.19
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/.build-stamp +2 -2
- package/{CodeAgent-w96z7fm7.js → CodeAgent-q0xkt4at.js} +2 -2
- package/{CodeTui-496f55hh.js → CodeTui-n56kpaca.js} +819 -663
- package/TunnelShare-844s9te4.js +18 -0
- package/{agent.command-81h65wcv.js → agent.command-k07raqft.js} +20 -20
- package/akanCode.js +8 -8
- package/{appExecutor-g4wq24v1.js → appExecutor-xav1zemr.js} +3 -3
- package/{application.command-rcw4h1gh.js → application.command-dv8y8r12.js} +52 -25
- package/{applicationBuildRunner-emhp6rh0.js → applicationBuildRunner-vhx7zq97.js} +9 -10
- package/buildBatch.proc.js +20 -11
- package/{cloud.command-k47h3kma.js → cloud.command-0vjy3x96.js} +22 -22
- package/cloud.script-jp48r0kw.js +35 -0
- package/{code.command-dam01a2f.js → code.command-xc5exq4b.js} +10 -10
- package/{context.command-44carkt5.js → context.command-etsat8yk.js} +22 -22
- package/context.runner-e52ak0cx.js +34 -0
- package/{guideline.command-ccxs69br.js → guideline.command-zqkntk7b.js} +6 -6
- package/guidelines/agentRule/agentRule.instruction.md +5 -4
- package/guidelines/conventions/core.md +18 -0
- package/guidelines/errorCodes/errorCodes.instruction.md +6 -0
- package/guidelines/mcpRule/mcpRule.instruction.md +4 -2
- package/guidelines/transportRule/transportRule.instruction.md +3 -1
- package/incrementalBuilder.proc.js +559 -409
- package/{index-aw7at6j6.js → index-12js5pj4.js} +1 -1
- package/{index-tpr9nqkj.js → index-12vv4g80.js} +1 -1
- package/index-4zqebbqb.js +80 -0
- package/{index-rxxjkbj2.js → index-6bryy19d.js} +499 -421
- package/{index-2hwjhe8r.js → index-6pzncry1.js} +4 -4
- package/{index-jeqq717b.js → index-6rrh0ffr.js} +44 -32
- package/{index-a42cf737.js → index-7jr9mfp2.js} +235 -105
- package/{index-pcqr0r0m.js → index-81qt1jyj.js} +1 -1
- package/{index-2mrn1mrg.js → index-9f3reh2y.js} +1 -1
- package/{index-h9356zmz.js → index-a05ewnnp.js} +1 -1
- package/{index-ptpdd9hw.js → index-bxevbjw7.js} +8 -8
- package/{index-g95rbz83.js → index-c1vym3gx.js} +2 -2
- package/{index-vh8q7mrq.js → index-c9hd79py.js} +4 -4
- package/{index-wy7qcqsd.js → index-c9mnfy9r.js} +38 -23
- package/{index-a85n83t6.js → index-cc9pevta.js} +1 -1
- package/{index-4279crca.js → index-cet2s7xk.js} +2 -2
- package/{index-k1p29hdp.js → index-dasa0kbj.js} +2 -2
- package/{index-y27cxjd6.js → index-ddc2zjj5.js} +1 -1
- package/{index-r790hx48.js → index-dz7z9n9t.js} +25 -25
- package/{index-mgvvtjp1.js → index-e4vna9dn.js} +4 -4
- package/{index-ggmwp14t.js → index-ean2tff1.js} +723 -691
- package/{index-s21zxj7p.js → index-fgp04fh7.js} +6 -6
- package/{index-cef0fxf2.js → index-g541mhzw.js} +3 -3
- package/{index-rj406y9n.js → index-gh741qft.js} +8 -8
- package/{index-sa8g94se.js → index-k51718xz.js} +2138 -2138
- package/{index-286djj0d.js → index-m6r3pvf5.js} +2 -2
- package/{index-kqf2s304.js → index-my17308p.js} +7 -7
- package/{index-pqf6d5ff.js → index-nd8bq17n.js} +6 -6
- package/{index-her656ng.js → index-nxcmgqk3.js} +3 -3
- package/{index-gd9tkq2k.js → index-pkgha3rt.js} +5 -5
- package/{index-tkrg58qv.js → index-q2t2w996.js} +1 -1
- package/{index-b061e6fn.js → index-qtqhsb33.js} +204 -160
- package/{index-nwbdpnna.js → index-rj2n5kfk.js} +67 -67
- package/{index-ktvyva62.js → index-s5gvwvkb.js} +103 -138
- package/{index-bbd1727m.js → index-sh3yzse2.js} +8 -7
- package/{index-y71v7grx.js → index-syn4vm3y.js} +1 -1
- package/{index-gkfpqdm8.js → index-t00xrkey.js} +1 -1
- package/{index-hw2eammf.js → index-v72mh89f.js} +5 -6
- package/{index-qrh7kdb1.js → index-wq8pnev4.js} +3 -3
- package/{index-1j1jmmac.js → index-wxr3941g.js} +8 -8
- package/{index-e4w015qt.js → index-y8mqkhcf.js} +1 -1
- package/{index-ctrx7asj.js → index-zk1gjk46.js} +4 -4
- package/index.js +27 -27
- package/{libExecutor-mmrzd606.js → libExecutor-mr3vxtnr.js} +2 -2
- package/{library.command-brkcat13.js → library.command-ps9q5t37.js} +7 -7
- package/{localRegistry.command-qwzy3t7w.js → localRegistry.command-rszxmvd0.js} +21 -21
- package/{module.command-t5emqxkr.js → module.command-fcybnn1a.js} +10 -10
- package/{package.command-xv04dbxf.js → package.command-zen3rhye.js} +10 -10
- package/package.json +2 -2
- package/{page.command-yhgq9tj8.js → page.command-gwrxymms.js} +7 -7
- package/{pipeline.command-x3nkf9kc.js → pipeline.command-m1brkqqw.js} +6 -6
- package/{pkgExecutor-4cbe3sgr.js → pkgExecutor-x51agavp.js} +2 -2
- package/{primitive.command-jv60b759.js → primitive.command-5vkxvvmk.js} +11 -11
- package/{projectTypecheck-fbfq9rm9.js → projectTypecheck-9dzfah37.js} +1 -1
- package/{quality.command-mdjardf1.js → quality.command-gqry7eas.js} +9 -9
- package/{repair.command-s22j5xbe.js → repair.command-qs4ejcrg.js} +10 -10
- package/{scalar.command-a6qs7012.js → scalar.command-ny0vchqq.js} +9 -9
- package/skills/akan-scaffold/SKILL.md +1 -1
- package/{subspace.command-26hkjqf9.js → subspace.command-5pxqjgmw.js} +12 -12
- package/templates/workspaceRoot/AGENTS.md.template +2 -1
- package/{tunnel.command-83sfgz5z.js → tunnel.command-ndajt0xk.js} +11 -11
- package/{verify.command-krm1rrf1.js → verify.command-m59ashc7.js} +17 -17
- package/{workflow.command-z05y7amj.js → workflow.command-jchqey88.js} +15 -15
- package/{workspace.command-qga6cn1n.js → workspace.command-g0gzxkpd.js} +36 -36
- package/TunnelShare-tyj8nb0z.js +0 -19
- package/cloud.script-b4smdpa5.js +0 -35
- package/context.runner-xtr9ngpa.js +0 -34
- package/index-k2kr1wd4.js +0 -18
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
script
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-sh3yzse2.js";
|
|
5
5
|
import {
|
|
6
6
|
jsonText
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-ean2tff1.js";
|
|
8
8
|
import {
|
|
9
9
|
akanMcpInstallTargets
|
|
10
|
-
} from "./index-
|
|
10
|
+
} from "./index-6bryy19d.js";
|
|
11
11
|
import {
|
|
12
12
|
ContextRunner2
|
|
13
|
-
} from "./index-
|
|
13
|
+
} from "./index-qtqhsb33.js";
|
|
14
14
|
|
|
15
15
|
// pkgs/@akanjs/cli/context/context.script.ts
|
|
16
16
|
import { Logger } from "akanjs/common";
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
ApplicationBuildReporter
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-s5gvwvkb.js";
|
|
5
5
|
import {
|
|
6
6
|
script,
|
|
7
7
|
markCliErrorPrinted,
|
|
8
8
|
assertPromptable
|
|
9
|
-
} from "./index-
|
|
9
|
+
} from "./index-sh3yzse2.js";
|
|
10
10
|
import {
|
|
11
11
|
CliError
|
|
12
12
|
} from "./index-j4yvgfhr.js";
|
|
13
13
|
import {
|
|
14
14
|
SysExecutor
|
|
15
|
-
} from "./index-
|
|
15
|
+
} from "./index-v72mh89f.js";
|
|
16
16
|
import {
|
|
17
17
|
AppExecutor2
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-cet2s7xk.js";
|
|
19
19
|
import {
|
|
20
20
|
LibExecutor2
|
|
21
|
-
} from "./index-
|
|
21
|
+
} from "./index-t00xrkey.js";
|
|
22
22
|
import {
|
|
23
23
|
PkgExecutor2
|
|
24
|
-
} from "./index-
|
|
24
|
+
} from "./index-cc9pevta.js";
|
|
25
25
|
import {
|
|
26
26
|
DesktopServerStage
|
|
27
|
-
} from "./index-
|
|
27
|
+
} from "./index-12vv4g80.js";
|
|
28
28
|
import {
|
|
29
29
|
LibraryScript
|
|
30
|
-
} from "./index-
|
|
30
|
+
} from "./index-nxcmgqk3.js";
|
|
31
31
|
import {
|
|
32
32
|
ApplicationRunner,
|
|
33
33
|
VerifyScope
|
|
34
|
-
} from "./index-
|
|
34
|
+
} from "./index-c9mnfy9r.js";
|
|
35
35
|
import {
|
|
36
36
|
PreviewChrome2,
|
|
37
37
|
PreviewView2,
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
} from "./index-rwgqba9p.js";
|
|
40
40
|
import {
|
|
41
41
|
formatSlicePlan
|
|
42
|
-
} from "./index-
|
|
42
|
+
} from "./index-12js5pj4.js";
|
|
43
43
|
import {
|
|
44
44
|
assertPlainName
|
|
45
45
|
} from "./index-va90m8nd.js";
|
|
@@ -633,6 +633,7 @@ class AppPreview {
|
|
|
633
633
|
static mobileViewport = { width: 390, height: 844 };
|
|
634
634
|
static desktopViewport = { width: 1280, height: 800 };
|
|
635
635
|
static csrTarget = "preview";
|
|
636
|
+
static #fullUrl = /^https?:\/\//i;
|
|
636
637
|
static settleMs = 1000;
|
|
637
638
|
static logGraceMs = 300;
|
|
638
639
|
static stopGraceMs = 15000;
|
|
@@ -700,33 +701,31 @@ class AppPreview {
|
|
|
700
701
|
if (options.changed && !changed.paths.length && !typed.length)
|
|
701
702
|
throw new Error(`No page to open: ${changed.skipped.join("; ")}. Pass a concrete path, e.g. \`akan preview ${app.name} /memo/1\`.`);
|
|
702
703
|
const { i18n, api } = await app.getConfig();
|
|
703
|
-
const { paths, asWritten } = AppPreview.#plan(typed, i18n, {
|
|
704
|
+
const { paths, asWritten, folded } = AppPreview.#plan(typed, i18n, {
|
|
704
705
|
csr: !!options.csr,
|
|
705
706
|
apiPrefix: api.prefix,
|
|
706
707
|
publicDir: path2.join(app.cwdPath, "public"),
|
|
707
708
|
pages: changed.paths
|
|
708
709
|
});
|
|
709
710
|
const dev = new URL(origin);
|
|
710
|
-
const isDevServer = (url) => url.protocol === dev.protocol && url.port === dev.port &&
|
|
711
|
-
const elsewhere = [...new Set(typed)].filter((raw) =>
|
|
712
|
-
const skipsBoot =
|
|
711
|
+
const isDevServer = (url) => url.protocol === dev.protocol && url.port === dev.port && AppPreview.#isDevHost(url.hostname);
|
|
712
|
+
const elsewhere = [...new Set(typed)].filter((raw) => AppPreview.#fullUrl.test(raw) && !isDevServer(new URL(raw)));
|
|
713
|
+
const skipsBoot = asWritten;
|
|
713
714
|
const notes = [
|
|
714
715
|
...elsewhere.length ? [
|
|
715
716
|
`${elsewhere.join(", ")} ${elsewhere.length === 1 ? "names another server: its path opens" : "name other servers: their paths open"} on ${origin}.`
|
|
716
717
|
] : [],
|
|
717
718
|
...options.csr && skipsBoot.length ? [
|
|
718
719
|
`--csr does not apply to ${skipsBoot.join(", ")}: ${skipsBoot.length === 1 ? "it opens" : "they open"} without the CSR boot.`
|
|
719
|
-
] : []
|
|
720
|
+
] : [],
|
|
721
|
+
...folded.map(({ raw, kept }) => `${raw} opens as ${kept}, which writes the same screenshot.`)
|
|
720
722
|
];
|
|
721
723
|
return { paths, notes };
|
|
722
724
|
}
|
|
723
|
-
static pagePaths(paths, i18n, options) {
|
|
724
|
-
return AppPreview.#plan(paths, i18n, options).paths;
|
|
725
|
-
}
|
|
726
725
|
static #plan(paths, i18n, { csr, apiPrefix = "/api", publicDir = null, pages = [] }) {
|
|
727
726
|
const keepsUnprefixed = i18n.localePrefix === "as-needed" && !csr;
|
|
728
727
|
const urlOf = (raw) => {
|
|
729
|
-
const url =
|
|
728
|
+
const url = AppPreview.#fullUrl.test(raw) ? new URL(raw) : AppPreview.probeUrlOf("http://localhost", raw);
|
|
730
729
|
url.pathname = url.pathname.replace(/^\/{2,}/, "/");
|
|
731
730
|
return url;
|
|
732
731
|
};
|
|
@@ -740,21 +739,32 @@ class AppPreview {
|
|
|
740
739
|
}
|
|
741
740
|
return `${url.pathname}${url.search}`;
|
|
742
741
|
};
|
|
743
|
-
const
|
|
744
|
-
const typed = (paths.length || pages.length ? paths : ["/"]).map((raw) => {
|
|
742
|
+
const rows = (paths.length || pages.length ? paths : ["/"]).map((raw) => {
|
|
745
743
|
const url = urlOf(raw);
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
asWritten.push(raw);
|
|
749
|
-
return `${url.pathname}${url.search}`;
|
|
744
|
+
const isPage = !AppPreview.#fullUrl.test(raw) && AppPreview.#isPagePath(url.pathname, i18n, { apiPrefix, publicDir });
|
|
745
|
+
return { raw, path: isPage ? asPage(url) : `${url.pathname}${url.search}`, asWritten: !isPage };
|
|
750
746
|
});
|
|
751
|
-
const
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
747
|
+
for (const page of pages)
|
|
748
|
+
rows.push({ raw: null, path: asPage(urlOf(page)), asWritten: false });
|
|
749
|
+
const byScreenshot = new Map;
|
|
750
|
+
const folded = [];
|
|
751
|
+
for (const row of rows) {
|
|
752
|
+
const name = AppPreview.screenshotName(row.path);
|
|
753
|
+
const kept = byScreenshot.get(name);
|
|
754
|
+
if (!kept)
|
|
755
|
+
byScreenshot.set(name, row);
|
|
756
|
+
else if (row.raw !== null && kept.path !== row.path)
|
|
757
|
+
folded.push({ raw: row.raw, kept: kept.path });
|
|
756
758
|
}
|
|
757
|
-
|
|
759
|
+
const planned = [...byScreenshot.values()];
|
|
760
|
+
return {
|
|
761
|
+
paths: planned.map((row) => row.path),
|
|
762
|
+
asWritten: planned.flatMap((row) => row.asWritten && row.raw !== null ? [row.raw] : []),
|
|
763
|
+
folded
|
|
764
|
+
};
|
|
765
|
+
}
|
|
766
|
+
static #isDevHost(hostname) {
|
|
767
|
+
return ["localhost", "127.0.0.1", "0.0.0.0"].includes(hostname.replace(/\.$/, ""));
|
|
758
768
|
}
|
|
759
769
|
static probeUrlOf(origin, pagePath) {
|
|
760
770
|
return new URL(`${origin}${pagePath.startsWith("/") ? "" : "/"}${pagePath}`);
|
|
@@ -775,6 +785,8 @@ class AppPreview {
|
|
|
775
785
|
const prefixes = ["/_akan", "/__csr", "/__rsc", "/.well-known", apiPrefix.replace(/\/+$/, "")].filter(Boolean);
|
|
776
786
|
if (prefixes.some((prefix) => pathname === prefix || pathname.startsWith(`${prefix}/`)))
|
|
777
787
|
return false;
|
|
788
|
+
if (pathname.endsWith("/"))
|
|
789
|
+
return true;
|
|
778
790
|
if (AppPreview.#serverFiles.has(pathname))
|
|
779
791
|
return false;
|
|
780
792
|
if (segments.length === 2 && segments[1] === "manifest.webmanifest")
|
|
@@ -1723,7 +1735,7 @@ class ApplicationScript extends script("application", [ApplicationRunner, Librar
|
|
|
1723
1735
|
await Promise.all(shares.map(async (share) => await share.close()));
|
|
1724
1736
|
}, "Abandoning the tunnel release; the shares expire on their own.");
|
|
1725
1737
|
await Promise.all(apps.map(async (app) => {
|
|
1726
|
-
const { TunnelShare } = await import("./TunnelShare-
|
|
1738
|
+
const { TunnelShare } = await import("./TunnelShare-844s9te4.js");
|
|
1727
1739
|
const share = await TunnelShare.open(app, { workspace: app.workspace });
|
|
1728
1740
|
shares.push(share);
|
|
1729
1741
|
urls.set(app.name, share.url);
|
|
@@ -394,7 +394,7 @@ var ownerOf = (relativePath) => {
|
|
|
394
394
|
const [root, name] = relativePath.split("/");
|
|
395
395
|
return (root === "apps" || root === "libs") && name ? `${root}/${name}` : null;
|
|
396
396
|
};
|
|
397
|
-
var
|
|
397
|
+
var syntaxReaderOf = (ts, ast) => {
|
|
398
398
|
const spanOf = (source, node) => {
|
|
399
399
|
const start = node.getStart(source);
|
|
400
400
|
const end = node.getEnd();
|
|
@@ -452,6 +452,74 @@ var createFactReader = (ts, ast) => {
|
|
|
452
452
|
const node = keyName(property);
|
|
453
453
|
return name && node ? [{ name, span: spanOf(source, node), extent: extentOf(source, property) }] : [];
|
|
454
454
|
});
|
|
455
|
+
const verbReaderOf = (parameter) => {
|
|
456
|
+
const verbs = new Map;
|
|
457
|
+
if (parameter && ts.isObjectBindingPattern(parameter.name))
|
|
458
|
+
for (const element of parameter.name.elements) {
|
|
459
|
+
const verb = element.propertyName ?? element.name;
|
|
460
|
+
if (ts.isIdentifier(verb) && ts.isIdentifier(element.name))
|
|
461
|
+
verbs.set(element.name.text, verb.text);
|
|
462
|
+
}
|
|
463
|
+
const holder = parameter && ts.isIdentifier(parameter.name) ? parameter.name.text : null;
|
|
464
|
+
return (callee) => {
|
|
465
|
+
if (callee && ts.isIdentifier(callee))
|
|
466
|
+
return verbs.get(callee.text) ?? null;
|
|
467
|
+
if (callee && ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression) && callee.expression.text === holder)
|
|
468
|
+
return callee.name.text;
|
|
469
|
+
return null;
|
|
470
|
+
};
|
|
471
|
+
};
|
|
472
|
+
return {
|
|
473
|
+
spanOf,
|
|
474
|
+
extentOf,
|
|
475
|
+
unwrap,
|
|
476
|
+
moduleRefOf,
|
|
477
|
+
returnedObject,
|
|
478
|
+
builderOf,
|
|
479
|
+
guardNameOf,
|
|
480
|
+
optionObjectOf,
|
|
481
|
+
chainOf,
|
|
482
|
+
keyName,
|
|
483
|
+
objectKeys,
|
|
484
|
+
verbReaderOf
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
var sourceReaderOf = (ts) => {
|
|
488
|
+
const importsOf = (statement) => {
|
|
489
|
+
const { importClause, moduleSpecifier } = statement;
|
|
490
|
+
if (!importClause || !ts.isStringLiteral(moduleSpecifier))
|
|
491
|
+
return [];
|
|
492
|
+
const from = moduleSpecifier.text;
|
|
493
|
+
const bindings = importClause.namedBindings;
|
|
494
|
+
return [
|
|
495
|
+
...importClause.name ? [{ name: importClause.name.text, imported: "default", from }] : [],
|
|
496
|
+
...bindings && ts.isNamespaceImport(bindings) ? [{ name: bindings.name.text, imported: "*", from }] : [],
|
|
497
|
+
...bindings && ts.isNamedImports(bindings) ? bindings.elements.map((element) => ({
|
|
498
|
+
name: element.name.text,
|
|
499
|
+
imported: (element.propertyName ?? element.name).text,
|
|
500
|
+
from
|
|
501
|
+
})) : []
|
|
502
|
+
];
|
|
503
|
+
};
|
|
504
|
+
const docOf = (source, node) => {
|
|
505
|
+
const { text } = source;
|
|
506
|
+
const ranges = ts.getLeadingCommentRanges(text, node.getFullStart()) ?? [];
|
|
507
|
+
const comments = [];
|
|
508
|
+
let end = node.getStart(source);
|
|
509
|
+
for (const range of [...ranges].reverse()) {
|
|
510
|
+
if ((text.slice(range.end, end).match(/\n/g)?.length ?? 0) > 1)
|
|
511
|
+
break;
|
|
512
|
+
comments.unshift(text.slice(range.pos, range.end));
|
|
513
|
+
end = range.pos;
|
|
514
|
+
}
|
|
515
|
+
const lines = comments.flatMap((comment) => comment.split(`
|
|
516
|
+
`)).map((line) => line.trim().replace(/^\/\*\*?|\*\/$/g, "").replace(/^(?:\/\/[?*!]?|\*)/, "").replace(/\{@link\s+([^}\s|]+)[^}]*\}/g, "$1").trim()).filter((line) => line && !/^(?:biome-ignore|eslint-|@ts-)/.test(line));
|
|
517
|
+
return lines.length ? lines.join(" ") : null;
|
|
518
|
+
};
|
|
519
|
+
const importsIn = (source) => source.statements.filter(ts.isImportDeclaration).flatMap(importsOf);
|
|
520
|
+
return { docOf, importsIn };
|
|
521
|
+
};
|
|
522
|
+
var signalKeyReaderOf = (ts, ast, { spanOf, extentOf, returnedObject, optionObjectOf, chainOf, verbReaderOf }, guardsIn) => {
|
|
455
523
|
const sliceKeysOf = (source, builder, made, model) => (returnedObject(builder)?.properties ?? []).flatMap((property) => {
|
|
456
524
|
if (!ts.isPropertyAssignment(property))
|
|
457
525
|
return [];
|
|
@@ -470,23 +538,30 @@ var createFactReader = (ts, ast) => {
|
|
|
470
538
|
}
|
|
471
539
|
];
|
|
472
540
|
});
|
|
473
|
-
const
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
541
|
+
const endpointKeysOf = (source, builder, made, model) => {
|
|
542
|
+
const verbOf = verbReaderOf(builder?.parameters[0]);
|
|
543
|
+
return (returnedObject(builder)?.properties ?? []).flatMap((property) => {
|
|
544
|
+
if (!ts.isPropertyAssignment(property))
|
|
545
|
+
return [];
|
|
546
|
+
const name = ast.nodeName(property.name);
|
|
547
|
+
if (!name)
|
|
548
|
+
return [];
|
|
549
|
+
const { root, methods } = chainOf(property.initializer);
|
|
550
|
+
return [
|
|
551
|
+
{
|
|
552
|
+
name,
|
|
553
|
+
span: spanOf(source, property.name),
|
|
554
|
+
extent: extentOf(source, property),
|
|
555
|
+
verb: root ? verbOf(root.expression) : null,
|
|
556
|
+
guards: root ? guardsIn(source, optionObjectOf(root), made, `${model}.${name}`) : [],
|
|
557
|
+
argCount: methods.filter((method) => argMethods.has(method)).length
|
|
558
|
+
}
|
|
559
|
+
];
|
|
560
|
+
});
|
|
489
561
|
};
|
|
562
|
+
return { sliceKeysOf, endpointKeysOf };
|
|
563
|
+
};
|
|
564
|
+
var jobKeyReaderOf = (ts, ast, { spanOf, extentOf, unwrap, returnedObject, chainOf, verbReaderOf }) => {
|
|
490
565
|
const numberOf = (expression) => {
|
|
491
566
|
const value = unwrap(expression);
|
|
492
567
|
if (ts.isNumericLiteral(value))
|
|
@@ -559,6 +634,9 @@ var createFactReader = (ts, ast) => {
|
|
|
559
634
|
];
|
|
560
635
|
});
|
|
561
636
|
};
|
|
637
|
+
return { internalKeysOf };
|
|
638
|
+
};
|
|
639
|
+
var serviceReaderOf = (ts, ast, { spanOf, extentOf, returnedObject, guardNameOf, chainOf, verbReaderOf }) => {
|
|
562
640
|
const plugsOf = (source, builder) => {
|
|
563
641
|
const verbOf = verbReaderOf(builder?.parameters[0]);
|
|
564
642
|
return (returnedObject(builder)?.properties ?? []).flatMap((property) => {
|
|
@@ -584,27 +662,17 @@ var createFactReader = (ts, ast) => {
|
|
|
584
662
|
visit(source);
|
|
585
663
|
return bindings;
|
|
586
664
|
};
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
name,
|
|
599
|
-
span: spanOf(source, property.name),
|
|
600
|
-
extent: extentOf(source, property),
|
|
601
|
-
verb: root ? verbOf(root.expression) : null,
|
|
602
|
-
guards: root ? guardsIn(source, optionObjectOf(root), made, `${model}.${name}`) : [],
|
|
603
|
-
argCount: methods.filter((method) => argMethods.has(method)).length
|
|
604
|
-
}
|
|
605
|
-
];
|
|
606
|
-
});
|
|
607
|
-
};
|
|
665
|
+
const methodsOf = (source, statement) => statement.members.flatMap((member) => {
|
|
666
|
+
if (!ts.isMethodDeclaration(member) || !member.body)
|
|
667
|
+
return [];
|
|
668
|
+
const name = ast.nodeName(member.name);
|
|
669
|
+
if (!name || ts.getModifiers(member)?.some(({ kind }) => kind === ts.SyntaxKind.StaticKeyword))
|
|
670
|
+
return [];
|
|
671
|
+
return [{ name, span: spanOf(source, member.name), extent: extentOf(source, member) }];
|
|
672
|
+
});
|
|
673
|
+
return { plugsOf, adaptorBindingsIn, methodsOf };
|
|
674
|
+
};
|
|
675
|
+
var constantReaderOf = (ts, ast, { spanOf, extentOf, unwrap, returnedObject, chainOf, keyName, objectKeys }) => {
|
|
608
676
|
const filterQueriesOf = (source, builder) => {
|
|
609
677
|
const query = returnedObject(builder)?.properties.find((property) => ts.isPropertyAssignment(property) && ast.nodeName(property.name) === "query")?.initializer;
|
|
610
678
|
return query && ts.isObjectLiteralExpression(query) ? objectKeys(source, query) : [];
|
|
@@ -642,48 +710,18 @@ var createFactReader = (ts, ast) => {
|
|
|
642
710
|
return [];
|
|
643
711
|
return list.elements.flatMap((element) => ts.isStringLiteralLike(element) ? [element.text] : []);
|
|
644
712
|
};
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
return [{ name, span: spanOf(source, member.name), extent: extentOf(source, member) }];
|
|
652
|
-
});
|
|
653
|
-
const importsOf = (statement) => {
|
|
654
|
-
const { importClause, moduleSpecifier } = statement;
|
|
655
|
-
if (!importClause || !ts.isStringLiteral(moduleSpecifier))
|
|
656
|
-
return [];
|
|
657
|
-
const from = moduleSpecifier.text;
|
|
658
|
-
const bindings = importClause.namedBindings;
|
|
659
|
-
return [
|
|
660
|
-
...importClause.name ? [{ name: importClause.name.text, imported: "default", from }] : [],
|
|
661
|
-
...bindings && ts.isNamespaceImport(bindings) ? [{ name: bindings.name.text, imported: "*", from }] : [],
|
|
662
|
-
...bindings && ts.isNamedImports(bindings) ? bindings.elements.map((element) => ({
|
|
663
|
-
name: element.name.text,
|
|
664
|
-
imported: (element.propertyName ?? element.name).text,
|
|
665
|
-
from
|
|
666
|
-
})) : []
|
|
667
|
-
];
|
|
668
|
-
};
|
|
669
|
-
const docOf = (source, node) => {
|
|
670
|
-
const { text } = source;
|
|
671
|
-
const ranges = ts.getLeadingCommentRanges(text, node.getFullStart()) ?? [];
|
|
672
|
-
const comments = [];
|
|
673
|
-
let end = node.getStart(source);
|
|
674
|
-
for (const range of [...ranges].reverse()) {
|
|
675
|
-
if ((text.slice(range.end, end).match(/\n/g)?.length ?? 0) > 1)
|
|
676
|
-
break;
|
|
677
|
-
comments.unshift(text.slice(range.pos, range.end));
|
|
678
|
-
end = range.pos;
|
|
679
|
-
}
|
|
680
|
-
const lines = comments.flatMap((comment) => comment.split(`
|
|
681
|
-
`)).map((line) => line.trim().replace(/^\/\*\*?|\*\/$/g, "").replace(/^(?:\/\/[?*!]?|\*)/, "").replace(/\{@link\s+([^}\s|]+)[^}]*\}/g, "$1").trim()).filter((line) => line && !/^(?:biome-ignore|eslint-|@ts-)/.test(line));
|
|
682
|
-
return lines.length ? lines.join(" ") : null;
|
|
683
|
-
};
|
|
713
|
+
return { constantOf, enumValuesOf, filterQueriesOf };
|
|
714
|
+
};
|
|
715
|
+
var createFactReader = (ts, ast) => {
|
|
716
|
+
const syntax = syntaxReaderOf(ts, ast);
|
|
717
|
+
const { spanOf, extentOf, unwrap, moduleRefOf, returnedObject, builderOf, chainOf, objectKeys } = syntax;
|
|
718
|
+
const { docOf, importsIn } = sourceReaderOf(ts);
|
|
684
719
|
const { guardsIn, guardsOf } = createGuardFactReader(ts, ast, { spanOf, extentOf, unwrap, docOf });
|
|
720
|
+
const { sliceKeysOf, endpointKeysOf } = signalKeyReaderOf(ts, ast, syntax, guardsIn);
|
|
721
|
+
const { internalKeysOf } = jobKeyReaderOf(ts, ast, syntax);
|
|
722
|
+
const { plugsOf, adaptorBindingsIn, methodsOf } = serviceReaderOf(ts, ast, syntax);
|
|
723
|
+
const { constantOf, enumValuesOf, filterQueriesOf } = constantReaderOf(ts, ast, syntax);
|
|
685
724
|
const lowerFirst = (text) => text.charAt(0).toLowerCase() + text.slice(1);
|
|
686
|
-
const importsIn = (source) => source.statements.filter(ts.isImportDeclaration).flatMap(importsOf);
|
|
687
725
|
const read = (source, owner) => {
|
|
688
726
|
const imports = importsIn(source);
|
|
689
727
|
const madeInPlace = [];
|
|
@@ -785,6 +823,7 @@ var identifierPattern = /^[\p{ID_Start}$_][\p{ID_Continue}$\u200c\u200d]*$/u;
|
|
|
785
823
|
var starExportPattern = /export\s*\*\s*from\s*["']([^"']+)["']/g;
|
|
786
824
|
var facetEntryPattern = new RegExp(`^((?:apps|libs)/[^/]+/(${barrelFacetDirs.map(escapeRegExp).join("|")}))/([^/]+)(/)?`);
|
|
787
825
|
var exportingPatternOf = (name) => new RegExp(`export\\s*\\{(?:[^}]*?[\\s,])?${escapeRegExp(name)}(?![\\w$])`);
|
|
826
|
+
var exportMentioningPatternOf = (name) => new RegExp(`export\\s[^;]*?(?<![\\w$])${escapeRegExp(name)}(?![\\w$])`);
|
|
788
827
|
var declaringPatternOf = (name, isAnyBinding) => {
|
|
789
828
|
const escaped = escapeRegExp(name);
|
|
790
829
|
const braced = "\\{(?:[^}]*?[\\s,])?";
|
|
@@ -807,6 +846,8 @@ class GuardResolver {
|
|
|
807
846
|
#declarations = new Map;
|
|
808
847
|
#starExports = new Map;
|
|
809
848
|
#moduleExports = new Map;
|
|
849
|
+
#fileStars = new Map;
|
|
850
|
+
#starReach = new Map;
|
|
810
851
|
#ownerFiles = null;
|
|
811
852
|
#modules = null;
|
|
812
853
|
#barrels = null;
|
|
@@ -1164,27 +1205,78 @@ ${name}`;
|
|
|
1164
1205
|
const cached = this.#moduleExports.get(key);
|
|
1165
1206
|
if (cached)
|
|
1166
1207
|
return cached;
|
|
1167
|
-
const found = { named: null, stars:
|
|
1168
|
-
const
|
|
1208
|
+
const found = { named: null, stars: [], isLocal: false };
|
|
1209
|
+
const stars = new Set(this.#barrelAt(path));
|
|
1169
1210
|
for (const fileName of this.#modulesAt(path)) {
|
|
1170
1211
|
const text = this.#source.readText(fileName);
|
|
1171
1212
|
if (text === undefined)
|
|
1172
1213
|
continue;
|
|
1173
|
-
const named = identifierPattern.test(name) &&
|
|
1214
|
+
const named = text.includes(name) && identifierPattern.test(name) && exportingPatternOf(name).test(text) ? this.#reexportIn(this.#source.parse(fileName, text), name) : null;
|
|
1174
1215
|
if (named) {
|
|
1175
1216
|
found.named = { ...named, fileName };
|
|
1176
|
-
found.stars = [];
|
|
1177
1217
|
break;
|
|
1178
1218
|
}
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
found.stars.push(target);
|
|
1219
|
+
if (text.includes(name) && exportMentioningPatternOf(name).test(text) && this.#exportsLocally(this.#source.parse(fileName, text), name)) {
|
|
1220
|
+
found.isLocal = true;
|
|
1221
|
+
break;
|
|
1183
1222
|
}
|
|
1223
|
+
for (const target of this.#starsIn(fileName, text))
|
|
1224
|
+
stars.add(target);
|
|
1184
1225
|
}
|
|
1226
|
+
if (!found.named && !found.isLocal)
|
|
1227
|
+
found.stars = [...stars];
|
|
1185
1228
|
this.#moduleExports.set(key, found);
|
|
1186
1229
|
return found;
|
|
1187
1230
|
}
|
|
1231
|
+
#exportsLocally(source, name) {
|
|
1232
|
+
const { ts } = this.#source;
|
|
1233
|
+
const binds = (node) => ts.isIdentifier(node) ? node.text === name : node.elements.some((element) => !ts.isOmittedExpression(element) && binds(element.name));
|
|
1234
|
+
return source.statements.some((statement) => {
|
|
1235
|
+
if (ts.isExportDeclaration(statement))
|
|
1236
|
+
return !statement.moduleSpecifier && !statement.isTypeOnly && !!statement.exportClause && ts.isNamedExports(statement.exportClause) && statement.exportClause.elements.some((element) => !element.isTypeOnly && element.name.text === name);
|
|
1237
|
+
const modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) ?? [] : [];
|
|
1238
|
+
if (!modifiers.some(({ kind }) => kind === ts.SyntaxKind.ExportKeyword) || modifiers.some(({ kind }) => kind === ts.SyntaxKind.DefaultKeyword))
|
|
1239
|
+
return false;
|
|
1240
|
+
if (ts.isVariableStatement(statement))
|
|
1241
|
+
return statement.declarationList.declarations.some((declaration) => binds(declaration.name));
|
|
1242
|
+
return (ts.isClassDeclaration(statement) || ts.isFunctionDeclaration(statement) || ts.isEnumDeclaration(statement) || ts.isModuleDeclaration(statement) || ts.isImportEqualsDeclaration(statement)) && !!statement.name && ts.isIdentifier(statement.name) && statement.name.text === name;
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
mentionsAlong(path, name) {
|
|
1246
|
+
return this.#starReachOf(path).some((text) => text.includes(name));
|
|
1247
|
+
}
|
|
1248
|
+
#starReachOf(path) {
|
|
1249
|
+
const cached = this.#starReach.get(path);
|
|
1250
|
+
if (cached)
|
|
1251
|
+
return cached;
|
|
1252
|
+
const paths = new Set([path]);
|
|
1253
|
+
const texts = [];
|
|
1254
|
+
for (const at of paths) {
|
|
1255
|
+
for (const next of this.#barrelAt(at) ?? [])
|
|
1256
|
+
paths.add(next);
|
|
1257
|
+
for (const fileName of this.#modulesAt(at)) {
|
|
1258
|
+
const text = this.#source.readText(fileName) ?? "";
|
|
1259
|
+
texts.push(text);
|
|
1260
|
+
for (const next of this.#starsIn(fileName, text))
|
|
1261
|
+
paths.add(next);
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
this.#starReach.set(path, texts);
|
|
1265
|
+
return texts;
|
|
1266
|
+
}
|
|
1267
|
+
#starsIn(fileName, text) {
|
|
1268
|
+
const cached = this.#fileStars.get(fileName);
|
|
1269
|
+
if (cached)
|
|
1270
|
+
return cached;
|
|
1271
|
+
const found = [];
|
|
1272
|
+
for (const [, specifier = ""] of text.matchAll(starExportPattern)) {
|
|
1273
|
+
const target = this.pathOfSpecifier(fileName, specifier);
|
|
1274
|
+
if (target !== null)
|
|
1275
|
+
found.push(target);
|
|
1276
|
+
}
|
|
1277
|
+
this.#fileStars.set(fileName, found);
|
|
1278
|
+
return found;
|
|
1279
|
+
}
|
|
1188
1280
|
#modulesAt(path) {
|
|
1189
1281
|
if (!this.#modules) {
|
|
1190
1282
|
this.#modules = new Map;
|
|
@@ -1276,6 +1368,9 @@ ${name}`;
|
|
|
1276
1368
|
var packageOf = (specifier) => specifier.split("/").slice(0, specifier.startsWith("@") ? 2 : 1).join("/");
|
|
1277
1369
|
var packageKeyOf = ({ name, from }) => `${packageOf(from)}
|
|
1278
1370
|
${name}`;
|
|
1371
|
+
var exportedKeyOf = (item) => ("fact" in item) ? item.id : ("local" in item) ? `${item.local}
|
|
1372
|
+
` : packageKeyOf(item);
|
|
1373
|
+
var isPackageExport = (item) => ("from" in item);
|
|
1279
1374
|
|
|
1280
1375
|
class AdaptorResolver {
|
|
1281
1376
|
#source;
|
|
@@ -1284,6 +1379,7 @@ class AdaptorResolver {
|
|
|
1284
1379
|
#adaptors = new Map;
|
|
1285
1380
|
#plugs = new Map;
|
|
1286
1381
|
#serviceFields = new Set;
|
|
1382
|
+
#exported = new Map;
|
|
1287
1383
|
constructor(source, resolver, sink) {
|
|
1288
1384
|
this.#source = source;
|
|
1289
1385
|
this.#resolver = resolver;
|
|
@@ -1366,33 +1462,66 @@ ${field}`))
|
|
|
1366
1462
|
return own.find((adaptor) => adaptor.fileName === fileName) ?? first;
|
|
1367
1463
|
if (own.length === 1)
|
|
1368
1464
|
return first;
|
|
1369
|
-
const exported = this.#exportedAt(name, path
|
|
1465
|
+
const exported = this.#exportedAt(name, path).filter((item) => first || !isPackageExport(item));
|
|
1370
1466
|
const [only] = exported;
|
|
1371
1467
|
if (only)
|
|
1372
|
-
return exported.length === 1 ? only : null;
|
|
1468
|
+
return exported.length === 1 && !("local" in only) ? only : null;
|
|
1373
1469
|
return first ? null : undefined;
|
|
1374
1470
|
}
|
|
1375
|
-
#exportedAt(name, path
|
|
1471
|
+
#exportedAt(name, path) {
|
|
1376
1472
|
const key = `${path}
|
|
1377
1473
|
${name}`;
|
|
1378
|
-
|
|
1474
|
+
const cached = this.#exported.get(key);
|
|
1475
|
+
if (cached)
|
|
1476
|
+
return cached;
|
|
1477
|
+
if (!this.#resolver.mentionsAlong(path, name)) {
|
|
1478
|
+
this.#exported.set(key, []);
|
|
1379
1479
|
return [];
|
|
1380
|
-
|
|
1381
|
-
const
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1480
|
+
}
|
|
1481
|
+
const reached = new Map;
|
|
1482
|
+
const seen = new Set;
|
|
1483
|
+
const pending = [[name, path]];
|
|
1484
|
+
for (let next = pending.pop();next; next = pending.pop()) {
|
|
1485
|
+
const [wanted, at] = next;
|
|
1486
|
+
if (seen.has(`${at}
|
|
1487
|
+
${wanted}`))
|
|
1488
|
+
continue;
|
|
1489
|
+
seen.add(`${at}
|
|
1490
|
+
${wanted}`);
|
|
1491
|
+
for (const item of this.#bindingAt(wanted, at, pending))
|
|
1492
|
+
reached.set(exportedKeyOf(item), item);
|
|
1493
|
+
}
|
|
1494
|
+
const found = [...reached.values()];
|
|
1495
|
+
this.#exported.set(key, found);
|
|
1496
|
+
return found;
|
|
1497
|
+
}
|
|
1498
|
+
#bindingAt(name, path, pending) {
|
|
1499
|
+
const here = this.#declaredAt(name, path);
|
|
1385
1500
|
if (here.length)
|
|
1386
1501
|
return here;
|
|
1387
|
-
const { named, stars } = this.#resolver.exportsAt(path, name);
|
|
1388
|
-
if (
|
|
1389
|
-
return [{
|
|
1502
|
+
const { named, stars, isLocal } = this.#resolver.exportsAt(path, name);
|
|
1503
|
+
if (isLocal)
|
|
1504
|
+
return [{ local: path }];
|
|
1505
|
+
if (named?.from === null) {
|
|
1506
|
+
const local = this.#declaredAt(named.name, path);
|
|
1507
|
+
return local.length ? local : [{ local: path }];
|
|
1508
|
+
}
|
|
1390
1509
|
if (named) {
|
|
1391
|
-
const target =
|
|
1392
|
-
|
|
1510
|
+
const target = this.#resolver.pathOfSpecifier(named.fileName, named.from);
|
|
1511
|
+
if (target === null)
|
|
1512
|
+
return [{ name: named.name === "default" ? name : named.name, from: named.from }];
|
|
1513
|
+
pending.push([named.name, target]);
|
|
1514
|
+
return [];
|
|
1393
1515
|
}
|
|
1394
|
-
const
|
|
1395
|
-
|
|
1516
|
+
for (const star of stars)
|
|
1517
|
+
pending.push([name, star]);
|
|
1518
|
+
return [];
|
|
1519
|
+
}
|
|
1520
|
+
#declaredAt(name, path) {
|
|
1521
|
+
return (this.#adaptors.get(name) ?? []).filter((adaptor) => {
|
|
1522
|
+
const module = this.#source.relative(adaptor.fileName).replace(/\.tsx?$/, "");
|
|
1523
|
+
return module === path || module === `${path}/index`;
|
|
1524
|
+
});
|
|
1396
1525
|
}
|
|
1397
1526
|
#packageAdaptorOf(name, specifier) {
|
|
1398
1527
|
if (frameworkPattern.test(specifier))
|
|
@@ -1403,14 +1532,15 @@ ${name}`;
|
|
|
1403
1532
|
#packageShimOf(owner, name, near) {
|
|
1404
1533
|
if (!near)
|
|
1405
1534
|
return null;
|
|
1406
|
-
const shims = this.#exportedAt(name, near
|
|
1535
|
+
const shims = this.#exportedAt(name, near).filter(isPackageExport);
|
|
1407
1536
|
const [shim] = shims;
|
|
1408
1537
|
if (shim)
|
|
1409
1538
|
return shims.length === 1 ? shim : null;
|
|
1410
1539
|
const { packages, paths } = this.#resolver.starExportsOf(owner, near);
|
|
1411
1540
|
const [only] = packages;
|
|
1412
|
-
|
|
1413
|
-
|
|
1541
|
+
if (!only || new Set(packages.map(packageOf)).size !== 1)
|
|
1542
|
+
return null;
|
|
1543
|
+
return paths.some((path) => this.#resolver.declaresAt(path, name)) ? null : { name, from: only };
|
|
1414
1544
|
}
|
|
1415
1545
|
#nodeOf({ fact, owner, fileName, id }) {
|
|
1416
1546
|
const detail = fact.refName ? [fact.refName] : [];
|
|
@@ -758,4 +758,4 @@ class CodeTuiParts2 {
|
|
|
758
758
|
}
|
|
759
759
|
}
|
|
760
760
|
|
|
761
|
-
export {
|
|
761
|
+
export { CodeTuiCommands2, CodeTuiLines2, CodeTuiEditor2, CodeTuiAgents2, CodeTuiMarkdown2, CodeTuiParts2, CodeTuiClipboard2, CodeTuiFiles2 };
|