barndog 0.1.1 → 0.2.0

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 (173) hide show
  1. package/README.md +8 -7
  2. package/dist/cli.js +11 -7
  3. package/dist/commands/add.js +33 -21
  4. package/dist/commands/arguments.js +12 -0
  5. package/dist/commands/asset-install.js +160 -0
  6. package/dist/commands/asset-list.js +121 -0
  7. package/dist/commands/asset-share.js +94 -0
  8. package/dist/commands/auth.js +4 -0
  9. package/dist/commands/availability.js +54 -26
  10. package/dist/commands/capabilities.js +71 -415
  11. package/dist/commands/collaboration.js +194 -110
  12. package/dist/commands/environment.js +18 -411
  13. package/dist/commands/github.js +200 -0
  14. package/dist/commands/helpers.js +39 -0
  15. package/dist/commands/hooks.js +87 -0
  16. package/dist/commands/init.js +4 -2
  17. package/dist/commands/knowledge.js +73 -0
  18. package/dist/commands/mcp.js +62 -0
  19. package/dist/commands/origin.js +21 -23
  20. package/dist/commands/people.js +51 -0
  21. package/dist/commands/sets.js +141 -0
  22. package/dist/commands/status.js +34 -24
  23. package/dist/commands/sync.js +11 -4
  24. package/dist/commands/workspace.js +33 -19
  25. package/dist/config/environment.js +13 -27
  26. package/dist/config/paths.js +62 -0
  27. package/dist/config/selection.js +30 -0
  28. package/dist/config/settings.js +97 -108
  29. package/dist/config/state.js +57 -57
  30. package/dist/entry/knowledge-startup.js +32 -0
  31. package/dist/entry/mcp-launch.js +71 -0
  32. package/dist/entry/opencode-plugin.js +62 -0
  33. package/dist/{features/git-workspace/startup.js → entry/workspace-startup.js} +7 -2
  34. package/dist/errors.js +198 -55
  35. package/dist/features/asset-kinds/index.js +120 -0
  36. package/dist/features/asset-selection/index.js +51 -19
  37. package/dist/features/auth/credentials.js +80 -47
  38. package/dist/features/auth/session.js +80 -45
  39. package/dist/features/auth/transport.js +66 -15
  40. package/dist/features/catalog/index.js +32 -61
  41. package/dist/features/collaboration/api.js +160 -0
  42. package/dist/features/collaboration/index.js +321 -233
  43. package/dist/features/collaboration/remote.js +35 -115
  44. package/dist/features/collaboration/results.js +2 -0
  45. package/dist/features/collaboration/workspace-git.js +233 -149
  46. package/dist/features/collaboration/workspace-github.js +117 -54
  47. package/dist/features/collaboration/workspace-store.js +140 -100
  48. package/dist/features/collaboration/workspace.js +257 -172
  49. package/dist/features/discovery/index.js +68 -57
  50. package/dist/features/doctor/index.js +32 -24
  51. package/dist/features/environment/auto-sync.js +28 -27
  52. package/dist/features/environment/names.js +67 -47
  53. package/dist/features/environment/operations.js +321 -228
  54. package/dist/features/environment/own-entries.js +89 -0
  55. package/dist/features/environment/settle-names.js +91 -0
  56. package/dist/features/environment/stage.js +178 -0
  57. package/dist/features/environment/sync.js +113 -484
  58. package/dist/features/environment/transaction.js +179 -147
  59. package/dist/features/environment/writes.js +196 -0
  60. package/dist/features/github/account.js +25 -0
  61. package/dist/features/github/connections.js +119 -0
  62. package/dist/features/github/pulls.js +118 -0
  63. package/dist/features/hooks/adapt.js +32 -25
  64. package/dist/features/hooks/catalog.js +28 -0
  65. package/dist/features/hooks/compatibility.js +49 -0
  66. package/dist/features/hooks/divergence.js +9 -6
  67. package/dist/features/hooks/test.js +74 -49
  68. package/dist/features/hooks/types.js +1 -0
  69. package/dist/features/imports/discover.js +134 -61
  70. package/dist/features/imports/folder.js +48 -14
  71. package/dist/features/imports/local.js +113 -134
  72. package/dist/features/imports/remote.js +44 -25
  73. package/dist/features/inspection/index.js +17 -17
  74. package/dist/features/inventory/index.js +99 -110
  75. package/dist/features/knowledge/index.js +69 -49
  76. package/dist/features/mcps/catalog.js +31 -0
  77. package/dist/features/mcps/import.js +316 -0
  78. package/dist/features/mcps/index.js +98 -49
  79. package/dist/features/migration/migrate.js +263 -0
  80. package/dist/features/{git-workspace → migration}/move.js +165 -109
  81. package/dist/features/migration/promote.js +24 -0
  82. package/dist/features/native/adapters.js +53 -94
  83. package/dist/features/native/configuration.js +128 -82
  84. package/dist/features/native/hook-shell.js +55 -0
  85. package/dist/features/native/plugin-module.js +56 -0
  86. package/dist/features/onboarding/environment.js +67 -34
  87. package/dist/features/onboarding/setup.js +43 -40
  88. package/dist/features/repositories/context.js +30 -13
  89. package/dist/features/server/catalog.js +58 -0
  90. package/dist/features/server/client.js +13 -0
  91. package/dist/features/server/connection.js +37 -0
  92. package/dist/features/server/origin.js +74 -0
  93. package/dist/features/server/pages.js +24 -0
  94. package/dist/features/skills/catalog.js +42 -0
  95. package/dist/features/workspace/assets.js +57 -0
  96. package/dist/features/workspace/cloud-source.js +34 -0
  97. package/dist/features/workspace/directory.js +38 -0
  98. package/dist/features/{git-workspace → workspace}/format.js +114 -51
  99. package/dist/features/workspace/git.js +214 -0
  100. package/dist/features/workspace/installed.js +92 -0
  101. package/dist/features/{git-workspace → workspace}/overlay.js +43 -23
  102. package/dist/features/workspace/packages.js +160 -0
  103. package/dist/features/{git-workspace → workspace}/publish.js +120 -64
  104. package/dist/features/workspace/repo-source.js +192 -0
  105. package/dist/features/{git-workspace → workspace}/setup.js +60 -42
  106. package/dist/features/{git-workspace → workspace}/snapshot.js +53 -18
  107. package/dist/features/workspace/source.js +1 -0
  108. package/dist/features/workspace/tree.js +52 -0
  109. package/dist/features/workspace/workspace-source.js +27 -0
  110. package/dist/harnesses/claude.js +23 -1
  111. package/dist/harnesses/codex.js +57 -1
  112. package/dist/harnesses/cursor.js +22 -1
  113. package/dist/harnesses/detect.js +6 -50
  114. package/dist/harnesses/formats.js +45 -0
  115. package/dist/harnesses/opencode.js +111 -0
  116. package/dist/harnesses/registry.js +35 -2
  117. package/dist/platform.js +375 -0
  118. package/dist/program.js +225 -54
  119. package/dist/runtime.js +1 -0
  120. package/dist/shared/cli-error.js +22 -0
  121. package/dist/shared/constants.js +32 -0
  122. package/dist/shared/files.js +72 -0
  123. package/dist/shared/lock.js +49 -0
  124. package/dist/shared/lookup.js +11 -0
  125. package/dist/shared/patterns.js +94 -0
  126. package/dist/shared/shell.js +22 -0
  127. package/dist/shared/values.js +26 -0
  128. package/dist/ui/add-asset.js +41 -400
  129. package/dist/ui/add-hook.js +213 -0
  130. package/dist/ui/add-mcp.js +107 -0
  131. package/dist/ui/add-prompts.js +47 -0
  132. package/dist/ui/add-skills.js +115 -0
  133. package/dist/ui/asset-list.js +31 -13
  134. package/dist/ui/assets.js +33 -44
  135. package/dist/ui/auth.js +43 -33
  136. package/dist/ui/clash.js +11 -6
  137. package/dist/ui/collaboration.js +116 -44
  138. package/dist/ui/connection.js +10 -4
  139. package/dist/ui/decision-error.js +24 -0
  140. package/dist/ui/environment-onboarding.js +35 -13
  141. package/dist/ui/format.js +66 -18
  142. package/dist/ui/hook-compatibility.js +14 -6
  143. package/dist/ui/mcp.js +28 -3
  144. package/dist/ui/move.js +10 -5
  145. package/dist/ui/onboarding.js +113 -73
  146. package/dist/ui/options.js +9 -0
  147. package/dist/ui/output.js +106 -43
  148. package/dist/ui/pick.js +45 -33
  149. package/dist/ui/scope-install.js +15 -7
  150. package/dist/ui/selection.js +15 -11
  151. package/dist/ui/theme.js +37 -14
  152. package/dist/version.js +6 -3
  153. package/package.json +13 -3
  154. package/dist/features/capabilities/index.js +0 -106
  155. package/dist/features/collaboration/domain.js +0 -90
  156. package/dist/features/environment/cloud-source.js +0 -27
  157. package/dist/features/environment/installed.js +0 -124
  158. package/dist/features/environment/packages.js +0 -120
  159. package/dist/features/environment/remote.js +0 -71
  160. package/dist/features/environment/workspace-source.js +0 -19
  161. package/dist/features/git-hosts/index.js +0 -148
  162. package/dist/features/git-workspace/assets.js +0 -71
  163. package/dist/features/git-workspace/git.js +0 -135
  164. package/dist/features/git-workspace/migrate.js +0 -188
  165. package/dist/features/git-workspace/source.js +0 -159
  166. package/dist/features/imports/mcp.js +0 -219
  167. package/dist/features/knowledge/startup.js +0 -25
  168. package/dist/features/native/mcp-launch.js +0 -57
  169. package/dist/features/skills/install.js +0 -25
  170. package/dist/features/skills/remote.js +0 -177
  171. package/dist/features/skills/sync.js +0 -121
  172. package/dist/features/skills/validation.js +0 -34
  173. /package/dist/features/environment/{source.js → events.js} +0 -0
@@ -1,121 +0,0 @@
1
- import { lstat, mkdir, readlink, realpath, symlink, unlink, rmdir, } from "node:fs/promises";
2
- import { homedir } from "node:os";
3
- import { dirname, isAbsolute, relative, resolve, sep } from "node:path";
4
- import { skillDirectory } from "../../harnesses/registry.js";
5
- import { readState, saveState } from "../../config/state.js";
6
- import { validateSelection, validateSkillSource, isRecord, } from "./validation.js";
7
- import { readSettings, settingsPath, SetupRequiredError, } from "../../config/settings.js";
8
- import { prepareSources } from "./remote.js";
9
- function missing(error) {
10
- return isRecord(error) && error.code === "ENOENT";
11
- }
12
- async function stat(path) {
13
- try {
14
- return await lstat(path);
15
- }
16
- catch (error) {
17
- if (missing(error))
18
- return null;
19
- throw error;
20
- }
21
- }
22
- function inside(parent, child) {
23
- const path = relative(parent, child);
24
- return (path === "" ||
25
- (!path.startsWith(`..${sep}`) && path !== ".." && !isAbsolute(path)));
26
- }
27
- async function pointsTo(link) {
28
- const info = await stat(link.target);
29
- return (!!info?.isSymbolicLink() &&
30
- resolve(dirname(link.target), await readlink(link.target)) === link.source);
31
- }
32
- /** home is injectable for isolated filesystem tests; the CLI always uses the real user home. */
33
- export async function sync(configPath, home = homedir(), override) {
34
- home = resolve(home);
35
- configPath = resolve(configPath ?? settingsPath(home));
36
- const settings = override ?? (await readSettings(home, configPath));
37
- if (!settings)
38
- throw new SetupRequiredError();
39
- const desired = [];
40
- const ids = new Set();
41
- const names = new Set();
42
- const events = [];
43
- for (const item of await prepareSources(settings, home)) {
44
- validateSelection(item);
45
- if (ids.has(item.id))
46
- throw new Error(`Duplicate skill ID: ${item.id}`);
47
- ids.add(item.id);
48
- // Disabled selections remain valid even if their original source is temporarily unavailable.
49
- if (!item.enabled) {
50
- events.push({ type: "disabled", id: item.id });
51
- continue;
52
- }
53
- const source = await realpath(resolve(dirname(configPath), item.source));
54
- const metadata = await validateSkillSource(source);
55
- if (names.has(metadata.name))
56
- throw new Error(`Conflicting enabled skill name: ${metadata.name}`);
57
- names.add(metadata.name);
58
- for (const harness of settings.harnesses) {
59
- const target = resolve(skillDirectory(harness, home), metadata.name);
60
- if (inside(source, target) || inside(target, source))
61
- throw new Error(`Source overlaps installation: ${source}`);
62
- desired.push({ id: item.id, harness, source, target });
63
- }
64
- }
65
- const stateDir = dirname(settingsPath(home));
66
- await mkdir(stateDir, { recursive: true });
67
- const lock = resolve(stateDir, "sync.lock");
68
- try {
69
- await mkdir(lock);
70
- }
71
- catch (error) {
72
- if (isRecord(error) && error.code === "EEXIST")
73
- throw new Error(`Another sync is running. If it crashed, remove ${lock}`, {
74
- cause: error,
75
- });
76
- throw error;
77
- }
78
- try {
79
- const statePath = resolve(stateDir, "state.json");
80
- const state = await readState(statePath, home);
81
- // Preflight all destinations before altering any installation.
82
- for (const old of state.links) {
83
- if ((await stat(old.target)) && !(await pointsTo(old)))
84
- throw new Error(`Managed link was changed externally: ${old.target}`);
85
- }
86
- for (const next of desired) {
87
- if ((await stat(next.target)) &&
88
- !state.links.some((old) => old.target === next.target)) {
89
- throw new Error(`Existing unmanaged skill; refusing to overwrite: ${next.target}`);
90
- }
91
- }
92
- for (const old of [...state.links]) {
93
- if (desired.some((next) => next.target === old.target &&
94
- next.source === old.source &&
95
- next.id === old.id))
96
- continue;
97
- if (await pointsTo(old))
98
- await unlink(old.target);
99
- state.links = state.links.filter((link) => link.target !== old.target);
100
- await saveState(statePath, state);
101
- events.push({ type: "removed", link: old });
102
- }
103
- for (const next of desired) {
104
- if (await pointsTo(next)) {
105
- events.push({ type: "unchanged", link: next });
106
- continue;
107
- }
108
- await mkdir(dirname(next.target), { recursive: true });
109
- // Save ownership first so a crash after symlink creation can be recovered on the next sync.
110
- state.links = state.links.filter((link) => link.target !== next.target);
111
- state.links.push(next);
112
- await saveState(statePath, state);
113
- await symlink(next.source, next.target, "dir");
114
- events.push({ type: "installed", link: next });
115
- }
116
- return events;
117
- }
118
- finally {
119
- await rmdir(lock);
120
- }
121
- }
@@ -1,34 +0,0 @@
1
- import { readFile } from "node:fs/promises";
2
- import { basename, resolve } from "node:path";
3
- import { parse } from "yaml";
4
- export const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
5
- export const skillName = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
6
- export function isRecord(value) {
7
- return typeof value === "object" && value !== null && !Array.isArray(value);
8
- }
9
- export function validateSelection(value) {
10
- if (!isRecord(value) ||
11
- typeof value.id !== "string" ||
12
- !uuid.test(value.id) ||
13
- typeof value.source !== "string" ||
14
- !value.source.trim() ||
15
- typeof value.enabled !== "boolean") {
16
- throw new Error("Each skill requires a UUIDv4 id, source path, and boolean enabled");
17
- }
18
- }
19
- export async function validateSkillSource(source) {
20
- const text = await readFile(resolve(source, "SKILL.md"), "utf8");
21
- const frontmatter = /^\uFEFF?---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(text);
22
- const metadata = frontmatter ? parse(frontmatter[1]) : null;
23
- if (!isRecord(metadata) ||
24
- typeof metadata.name !== "string" ||
25
- !skillName.test(metadata.name) ||
26
- metadata.name.length > 64 ||
27
- typeof metadata.description !== "string" ||
28
- !metadata.description.trim()) {
29
- throw new Error(`Invalid SKILL.md name/description: ${source}`);
30
- }
31
- if (basename(source) !== metadata.name)
32
- throw new Error(`Skill directory must match name: ${metadata.name}`);
33
- return { name: metadata.name, description: metadata.description };
34
- }