@fml-inc/fml 0.8.13-rc.1 → 0.8.13-rc.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.
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runObserverSyncCycle
4
- } from "./chunk-HVD2GMN3.js";
5
- import "./chunk-U7SITLCL.js";
6
- import "./chunk-CSOFP7MT.js";
4
+ } from "./chunk-56ABBKUE.js";
5
+ import "./chunk-LYKMU7QR.js";
6
+ import "./chunk-F57IFY3K.js";
7
+ import "./chunk-74KOMQZO.js";
7
8
  import "./chunk-HDAFEHUY.js";
8
9
  import "./chunk-MLKGABMK.js";
9
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fml-inc/fml",
3
- "version": "0.8.13-rc.1",
3
+ "version": "0.8.13-rc.2",
4
4
  "description": "FML CLI and agent tools",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -1,67 +0,0 @@
1
- // ../../packages/shared/src/github-repository.ts
2
- var MAX_REPOSITORY_BYTES = 201;
3
- var UTF8_ENCODER = new TextEncoder();
4
- function utf8Bytes(value) {
5
- return UTF8_ENCODER.encode(value).byteLength;
6
- }
7
- function githubRepositoryPath(pathname) {
8
- const parts = pathname.replace(/^\/+|\/+$/g, "").split("/");
9
- if (parts.length !== 2) return null;
10
- const owner = parts[0];
11
- const repository = parts[1]?.replace(/\.git$/i, "");
12
- if (!owner || !repository) return null;
13
- const segmentPattern = /^[A-Za-z0-9_.-]+$/;
14
- if (!segmentPattern.test(owner) || !segmentPattern.test(repository)) {
15
- return null;
16
- }
17
- const canonical = `${owner.toLowerCase()}/${repository.toLowerCase()}`;
18
- if (canonical.startsWith("./") || canonical.startsWith("../") || repository === "." || repository === ".." || repository.toLowerCase().endsWith(".git")) {
19
- return null;
20
- }
21
- return utf8Bytes(canonical) <= MAX_REPOSITORY_BYTES ? canonical : null;
22
- }
23
- function canonicalGitHubRepository(remote) {
24
- const trimmed = remote.trim();
25
- if (!trimmed || trimmed.includes("\0")) return null;
26
- const scp = trimmed.match(/^git@github\.com:([^?#]+)$/i);
27
- if (scp?.[1]) return githubRepositoryPath(scp[1]);
28
- let url;
29
- try {
30
- url = new URL(trimmed);
31
- } catch {
32
- return null;
33
- }
34
- if (url.hostname.toLowerCase() !== "github.com") return null;
35
- if (url.search || url.hash || url.password || url.port) return null;
36
- if (url.protocol === "https:" || url.protocol === "http:") {
37
- if (url.username) return null;
38
- } else if (url.protocol === "ssh:") {
39
- if (url.username && url.username !== "git") return null;
40
- } else {
41
- return null;
42
- }
43
- return githubRepositoryPath(url.pathname);
44
- }
45
-
46
- // src/package-root.ts
47
- import fs from "fs";
48
- import path from "path";
49
- import { fileURLToPath } from "url";
50
- function resolvePackageRoot(startDir = path.dirname(fileURLToPath(import.meta.url))) {
51
- let directory = startDir;
52
- while (true) {
53
- if (fs.existsSync(path.join(directory, "package.json")) && fs.existsSync(path.join(directory, "bin"))) {
54
- return directory;
55
- }
56
- const parent = path.dirname(directory);
57
- if (parent === directory) {
58
- throw new Error(`Could not resolve FML package root from ${startDir}`);
59
- }
60
- directory = parent;
61
- }
62
- }
63
-
64
- export {
65
- canonicalGitHubRepository,
66
- resolvePackageRoot
67
- };
@@ -1,142 +0,0 @@
1
- // src/repo.ts
2
- import { execFile, execFileSync } from "child_process";
3
- var REPO_CACHE = /* @__PURE__ */ new Map();
4
- var ASYNC_REPO_CACHE = /* @__PURE__ */ new Map();
5
- var GIT_TIMEOUT_MS = 5e3;
6
- var POSITIVE_REPO_CACHE_TTL_MS = 3e4;
7
- var NEGATIVE_REPO_CACHE_TTL_MS = 1e3;
8
- var MAX_REPO_CACHE_ENTRIES = 256;
9
- function cachedRepo(cwd) {
10
- const entry = REPO_CACHE.get(cwd);
11
- if (!entry) return { hit: false };
12
- if (entry.expiresAtMs <= Date.now()) {
13
- REPO_CACHE.delete(cwd);
14
- return { hit: false };
15
- }
16
- REPO_CACHE.delete(cwd);
17
- REPO_CACHE.set(cwd, entry);
18
- return { hit: true, value: entry.value };
19
- }
20
- function cacheRepo(cwd, value) {
21
- REPO_CACHE.delete(cwd);
22
- while (REPO_CACHE.size >= MAX_REPO_CACHE_ENTRIES) {
23
- const oldest = REPO_CACHE.keys().next().value;
24
- if (oldest === void 0) break;
25
- REPO_CACHE.delete(oldest);
26
- }
27
- REPO_CACHE.set(cwd, {
28
- value,
29
- expiresAtMs: Date.now() + (value === null ? NEGATIVE_REPO_CACHE_TTL_MS : POSITIVE_REPO_CACHE_TTL_MS)
30
- });
31
- }
32
- function git(cwd, args, timeoutMs) {
33
- try {
34
- return execFileSync("git", ["-C", cwd, ...args], {
35
- encoding: "utf8",
36
- timeout: timeoutMs,
37
- stdio: ["ignore", "pipe", "ignore"],
38
- windowsHide: true
39
- }).trim() || null;
40
- } catch {
41
- return null;
42
- }
43
- }
44
- function gitAsync(cwd, args, signal) {
45
- return new Promise((resolve, reject) => {
46
- try {
47
- execFile(
48
- "git",
49
- ["-C", cwd, ...args],
50
- {
51
- encoding: "utf8",
52
- timeout: GIT_TIMEOUT_MS,
53
- windowsHide: true,
54
- ...signal ? { signal } : {}
55
- },
56
- (error, stdout) => {
57
- if (signal?.aborted) {
58
- reject(signal.reason ?? new Error("Repository lookup aborted"));
59
- return;
60
- }
61
- resolve(error ? null : stdout.trim() || null);
62
- }
63
- );
64
- } catch (error) {
65
- if (signal?.aborted) {
66
- reject(signal.reason ?? error);
67
- return;
68
- }
69
- resolve(null);
70
- }
71
- });
72
- }
73
- function repositorySlug(remote) {
74
- const ssh = remote.match(/^[^@]+@[^:]+:([^/]+\/[^/]+?)(?:\.git)?$/);
75
- if (ssh?.[1]) return ssh[1].toLowerCase();
76
- try {
77
- const url = new URL(remote);
78
- const slug = url.pathname.replace(/^\/+|\/+$/g, "").replace(/\.git$/, "");
79
- return /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(slug) ? slug.toLowerCase() : null;
80
- } catch {
81
- return null;
82
- }
83
- }
84
- function resolveRepoFromCwd(cwd, timeoutMs = GIT_TIMEOUT_MS) {
85
- const cached = cachedRepo(cwd);
86
- if (cached.hit) return cached.value;
87
- const remote = git(cwd, ["remote", "get-url", "origin"], timeoutMs);
88
- const repo = remote ? repositorySlug(remote) : null;
89
- const result = repo ? {
90
- repo,
91
- branch: git(cwd, ["rev-parse", "--abbrev-ref", "HEAD"], timeoutMs)
92
- } : null;
93
- cacheRepo(cwd, result);
94
- return result;
95
- }
96
- function resolveRepositorySlugFromCwd(cwd, timeoutMs = GIT_TIMEOUT_MS) {
97
- const cached = cachedRepo(cwd);
98
- if (cached.hit) return cached.value?.repo ?? null;
99
- const remote = git(cwd, ["remote", "get-url", "origin"], timeoutMs);
100
- return remote ? repositorySlug(remote) : null;
101
- }
102
- function resolveRepositoryRootFromCwd(cwd, timeoutMs = GIT_TIMEOUT_MS) {
103
- return git(cwd, ["rev-parse", "--show-toplevel"], timeoutMs);
104
- }
105
- async function resolveRepoFromCwdAsync(cwd, signal) {
106
- if (signal?.aborted) {
107
- throw signal.reason ?? new Error("Repository lookup aborted");
108
- }
109
- const cached = cachedRepo(cwd);
110
- if (cached.hit) return cached.value;
111
- const cachedResolution = ASYNC_REPO_CACHE.get(cwd);
112
- if (cachedResolution) return await cachedResolution;
113
- const resolution = (async () => {
114
- const remote = await gitAsync(cwd, ["remote", "get-url", "origin"], signal);
115
- const repo = remote ? repositorySlug(remote) : null;
116
- const result = repo ? {
117
- repo,
118
- branch: await gitAsync(
119
- cwd,
120
- ["rev-parse", "--abbrev-ref", "HEAD"],
121
- signal
122
- )
123
- } : null;
124
- cacheRepo(cwd, result);
125
- return result;
126
- })();
127
- ASYNC_REPO_CACHE.set(cwd, resolution);
128
- try {
129
- return await resolution;
130
- } finally {
131
- if (ASYNC_REPO_CACHE.get(cwd) === resolution) {
132
- ASYNC_REPO_CACHE.delete(cwd);
133
- }
134
- }
135
- }
136
-
137
- export {
138
- resolveRepoFromCwd,
139
- resolveRepositorySlugFromCwd,
140
- resolveRepositoryRootFromCwd,
141
- resolveRepoFromCwdAsync
142
- };