@ferrule-io/ok-fine 0.0.0-stage → 0.3.7

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.
Files changed (87) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +93 -2
  3. package/dist/auth/discovery.js +67 -0
  4. package/dist/auth/http-auth.js +50 -0
  5. package/dist/auth/verifier.js +176 -0
  6. package/dist/cli-options.js +99 -0
  7. package/dist/cli.js +115 -0
  8. package/dist/config.js +320 -0
  9. package/dist/data-dir-lock.js +60 -0
  10. package/dist/errors.js +13 -0
  11. package/dist/http/mcp-route.js +32 -0
  12. package/dist/http/rest.js +243 -0
  13. package/dist/http/ui.js +118 -0
  14. package/dist/main.js +32 -0
  15. package/dist/mcp/server.js +203 -0
  16. package/dist/okf/concept.js +99 -0
  17. package/dist/okf/frontmatter.js +180 -0
  18. package/dist/okf/index-file.js +74 -0
  19. package/dist/okf/lint.js +480 -0
  20. package/dist/okf/log-file.js +74 -0
  21. package/dist/okf/markdown.js +106 -0
  22. package/dist/okf/paths.js +99 -0
  23. package/dist/okf/repository.js +53 -0
  24. package/dist/okf/semantics.js +121 -0
  25. package/dist/server.js +343 -0
  26. package/dist/service/feedback.js +40 -0
  27. package/dist/service/knowledge-service.js +819 -0
  28. package/dist/service/principal.js +22 -0
  29. package/dist/store/archive.js +108 -0
  30. package/dist/store/backend.js +4 -0
  31. package/dist/store/bundle.js +250 -0
  32. package/dist/store/catalog.js +295 -0
  33. package/dist/store/fs-util.js +120 -0
  34. package/dist/store/git-backend.js +713 -0
  35. package/dist/store/git.js +274 -0
  36. package/dist/store/mutex.js +19 -0
  37. package/dist/store/path-index.js +54 -0
  38. package/dist/ui/assets/bash-BiGZg9Om.js +1 -0
  39. package/dist/ui/assets/css-BGIxQoYs.js +1 -0
  40. package/dist/ui/assets/css-DUjzNfgv.js +1 -0
  41. package/dist/ui/assets/diff-woXpYk--.js +1 -0
  42. package/dist/ui/assets/dockerfile-IyjqRm3v.js +1 -0
  43. package/dist/ui/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  44. package/dist/ui/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  45. package/dist/ui/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  46. package/dist/ui/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  47. package/dist/ui/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
  48. package/dist/ui/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
  49. package/dist/ui/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
  50. package/dist/ui/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
  51. package/dist/ui/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
  52. package/dist/ui/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
  53. package/dist/ui/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  54. package/dist/ui/assets/github-dark-default-DXG-b-1a.js +1 -0
  55. package/dist/ui/assets/github-light-default-BXViO-2h.js +1 -0
  56. package/dist/ui/assets/go-rLFTqkRN.js +1 -0
  57. package/dist/ui/assets/highlight-CW19vWvw.js +153 -0
  58. package/dist/ui/assets/html-BMn1ogTm.js +1 -0
  59. package/dist/ui/assets/html-BlpXnbzK.js +1 -0
  60. package/dist/ui/assets/index-0b2NNRC5.js +127 -0
  61. package/dist/ui/assets/index-CFuTAZQM.css +1 -0
  62. package/dist/ui/assets/java-BtIQNnN0.js +1 -0
  63. package/dist/ui/assets/java-DxlWrXwe.js +1 -0
  64. package/dist/ui/assets/javascript-BzbQS41l.js +1 -0
  65. package/dist/ui/assets/javascript-Yelw-5ZN.js +1 -0
  66. package/dist/ui/assets/json-qhed-kSA.js +1 -0
  67. package/dist/ui/assets/jsx-D3KKoC5L.js +1 -0
  68. package/dist/ui/assets/jsx-hEbJ82HF.js +1 -0
  69. package/dist/ui/assets/markdown-BYOwaDjH.js +1 -0
  70. package/dist/ui/assets/python-gzcpVVnB.js +1 -0
  71. package/dist/ui/assets/ruby-Di5fYh6S.js +1 -0
  72. package/dist/ui/assets/rust-DpiIf5JO.js +1 -0
  73. package/dist/ui/assets/shellscript-CqHdAlCp.js +1 -0
  74. package/dist/ui/assets/sql-BOsskAmu.js +1 -0
  75. package/dist/ui/assets/sql-CNu3Or2W.js +1 -0
  76. package/dist/ui/assets/toml-CcmNWLt0.js +1 -0
  77. package/dist/ui/assets/tsx-5f3ulCja.js +1 -0
  78. package/dist/ui/assets/tsx-BOvsFOI6.js +1 -0
  79. package/dist/ui/assets/typescript-Utq2Cl8c.js +1 -0
  80. package/dist/ui/assets/typescript-j_1H8WHN.js +1 -0
  81. package/dist/ui/assets/yaml-CxbubiML.js +1 -0
  82. package/dist/ui/assets/yaml-DijMHRDA.js +1 -0
  83. package/dist/ui/favicon.svg +11 -0
  84. package/dist/ui/index.html +16 -0
  85. package/dist/ui/theme-init.js +10 -0
  86. package/dist/version.js +2 -0
  87. package/package.json +77 -4
@@ -0,0 +1,120 @@
1
+ import { randomBytes } from "node:crypto";
2
+ import { access, lstat, mkdir, readdir, readFile, rename, writeFile } from "node:fs/promises";
3
+ import { basename, dirname, join, posix } from "node:path";
4
+ import { OkfError } from "../errors.js";
5
+ export async function atomicWrite(absPath, data) {
6
+ const dir = dirname(absPath);
7
+ await mkdir(dir, { recursive: true });
8
+ const tmpName = join(dir, `.${basename(absPath)}.${randomBytes(4).toString("hex")}.tmp`);
9
+ await writeFile(tmpName, data);
10
+ await rename(tmpName, absPath);
11
+ }
12
+ export async function pathExists(absPath) {
13
+ try {
14
+ await access(absPath);
15
+ return true;
16
+ }
17
+ catch {
18
+ return false;
19
+ }
20
+ }
21
+ export async function isDirectory(absPath) {
22
+ try {
23
+ const s = await lstat(absPath);
24
+ return s.isDirectory() && !s.isSymbolicLink();
25
+ }
26
+ catch {
27
+ return false;
28
+ }
29
+ }
30
+ /**
31
+ * Lists regular files below `rootDir` as sorted POSIX relative paths. Skips dot-entries; symlinks and other
32
+ * non-regular entries are excluded and never followed. A missing root yields [].
33
+ */
34
+ export async function listTreeFiles(rootDir) {
35
+ try {
36
+ const s = await lstat(rootDir);
37
+ if (s.isSymbolicLink() || !s.isDirectory()) {
38
+ return [];
39
+ }
40
+ }
41
+ catch {
42
+ return [];
43
+ }
44
+ const files = [];
45
+ async function walk(rel) {
46
+ let entries;
47
+ try {
48
+ entries = await readdir(rel === "" ? rootDir : join(rootDir, rel), { withFileTypes: true });
49
+ }
50
+ catch {
51
+ return;
52
+ }
53
+ for (const entry of entries) {
54
+ if (entry.name.startsWith(".")) {
55
+ continue;
56
+ }
57
+ const childRel = rel === "" ? entry.name : `${rel}/${entry.name}`;
58
+ if (entry.isDirectory()) {
59
+ await walk(childRel);
60
+ }
61
+ else if (entry.isFile()) {
62
+ files.push(childRel);
63
+ }
64
+ }
65
+ }
66
+ await walk("");
67
+ return files.sort();
68
+ }
69
+ export async function fsBundleSource(rootDir) {
70
+ return {
71
+ paths: await listTreeFiles(rootDir),
72
+ read: (path) => readFile(join(rootDir, path)).catch(() => null),
73
+ };
74
+ }
75
+ export async function assertContainedPath(repoDir, project, relPath) {
76
+ const projectDir = join(repoDir, project);
77
+ try {
78
+ const s = await lstat(projectDir);
79
+ if (s.isSymbolicLink()) {
80
+ throw new OkfError("invalid_path", 400, `project directory "${project}" is a symbolic link`);
81
+ }
82
+ if (!s.isDirectory()) {
83
+ throw new OkfError("invalid_path", 400, `project directory "${project}" is not a directory`);
84
+ }
85
+ }
86
+ catch (err) {
87
+ if (err.code === "ENOENT") {
88
+ return;
89
+ }
90
+ throw err;
91
+ }
92
+ if (!relPath) {
93
+ return;
94
+ }
95
+ const parentDir = posix.dirname(relPath);
96
+ if (parentDir === "." || parentDir === "") {
97
+ return;
98
+ }
99
+ const segments = parentDir.split("/").filter((s) => s.length > 0);
100
+ let current = projectDir;
101
+ for (const segment of segments) {
102
+ current = join(current, segment);
103
+ try {
104
+ const s = await lstat(current);
105
+ if (s.isSymbolicLink()) {
106
+ throw new OkfError("invalid_path", 400, `path component "${segment}" is a symbolic link`);
107
+ }
108
+ if (!s.isDirectory()) {
109
+ throw new OkfError("invalid_path", 400, `path component "${segment}" is not a directory`);
110
+ }
111
+ }
112
+ catch (err) {
113
+ if (err.code === "ENOENT") {
114
+ break;
115
+ }
116
+ throw err;
117
+ }
118
+ }
119
+ }
120
+ //# sourceMappingURL=fs-util.js.map