harborloop 0.3.0 → 0.4.1

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 (120) hide show
  1. package/bin/checksums.json +12 -0
  2. package/bin/harbor.mjs +188 -0
  3. package/package.json +14 -30
  4. package/dist/api.d.ts +0 -109
  5. package/dist/api.js +0 -409
  6. package/dist/auth/login.d.ts +0 -14
  7. package/dist/auth/login.js +0 -158
  8. package/dist/auth/loopback.d.ts +0 -11
  9. package/dist/auth/loopback.js +0 -87
  10. package/dist/auth/pkce.d.ts +0 -7
  11. package/dist/auth/pkce.js +0 -14
  12. package/dist/auth/store.d.ts +0 -26
  13. package/dist/auth/store.js +0 -107
  14. package/dist/cli-release.d.ts +0 -31
  15. package/dist/cli-release.js +0 -102
  16. package/dist/commands/bind.d.ts +0 -23
  17. package/dist/commands/bind.js +0 -86
  18. package/dist/commands/context.d.ts +0 -12
  19. package/dist/commands/context.js +0 -80
  20. package/dist/commands/daemon.d.ts +0 -39
  21. package/dist/commands/daemon.js +0 -140
  22. package/dist/commands/doctor.d.ts +0 -16
  23. package/dist/commands/doctor.js +0 -937
  24. package/dist/commands/init.d.ts +0 -36
  25. package/dist/commands/init.js +0 -192
  26. package/dist/commands/status.d.ts +0 -5
  27. package/dist/commands/status.js +0 -164
  28. package/dist/commands/sync.d.ts +0 -40
  29. package/dist/commands/sync.js +0 -242
  30. package/dist/commands/toggle.d.ts +0 -16
  31. package/dist/commands/toggle.js +0 -69
  32. package/dist/commands/unbind.d.ts +0 -14
  33. package/dist/commands/unbind.js +0 -60
  34. package/dist/commands/workspaces.d.ts +0 -18
  35. package/dist/commands/workspaces.js +0 -41
  36. package/dist/context-budget.d.ts +0 -40
  37. package/dist/context-budget.js +0 -259
  38. package/dist/daemon/install.d.ts +0 -50
  39. package/dist/daemon/install.js +0 -192
  40. package/dist/daemon/loop.d.ts +0 -15
  41. package/dist/daemon/loop.js +0 -84
  42. package/dist/daemon/state.d.ts +0 -79
  43. package/dist/daemon/state.js +0 -213
  44. package/dist/daemon/tick.d.ts +0 -37
  45. package/dist/daemon/tick.js +0 -231
  46. package/dist/documents/apply.d.ts +0 -21
  47. package/dist/documents/apply.js +0 -58
  48. package/dist/documents/bundle.d.ts +0 -41
  49. package/dist/documents/bundle.js +0 -43
  50. package/dist/documents/inspect.d.ts +0 -12
  51. package/dist/documents/inspect.js +0 -33
  52. package/dist/documents/manifest.d.ts +0 -14
  53. package/dist/documents/manifest.js +0 -52
  54. package/dist/documents/pointer.d.ts +0 -32
  55. package/dist/documents/pointer.js +0 -135
  56. package/dist/documents/write.d.ts +0 -57
  57. package/dist/documents/write.js +0 -211
  58. package/dist/endpoints.d.ts +0 -7
  59. package/dist/endpoints.js +0 -15
  60. package/dist/env-bundle.d.ts +0 -25
  61. package/dist/env-bundle.js +0 -33
  62. package/dist/env-scan.d.ts +0 -27
  63. package/dist/env-scan.js +0 -41
  64. package/dist/env-sync.d.ts +0 -31
  65. package/dist/env-sync.js +0 -37
  66. package/dist/index.d.ts +0 -11
  67. package/dist/index.js +0 -282
  68. package/dist/install-hooks.d.ts +0 -11
  69. package/dist/install-hooks.js +0 -64
  70. package/dist/lock.d.ts +0 -31
  71. package/dist/lock.js +0 -192
  72. package/dist/machine.d.ts +0 -13
  73. package/dist/machine.js +0 -53
  74. package/dist/memories.d.ts +0 -31
  75. package/dist/memories.js +0 -74
  76. package/dist/origin.d.ts +0 -4
  77. package/dist/origin.js +0 -59
  78. package/dist/paths.d.ts +0 -12
  79. package/dist/paths.js +0 -45
  80. package/dist/providers/claude.d.ts +0 -65
  81. package/dist/providers/claude.js +0 -412
  82. package/dist/providers/codex-trust.d.ts +0 -36
  83. package/dist/providers/codex-trust.js +0 -141
  84. package/dist/providers/codex.d.ts +0 -46
  85. package/dist/providers/codex.js +0 -520
  86. package/dist/providers/cursor.d.ts +0 -45
  87. package/dist/providers/cursor.js +0 -344
  88. package/dist/providers/detect.d.ts +0 -16
  89. package/dist/providers/detect.js +0 -70
  90. package/dist/providers/hook-coverage.d.ts +0 -5
  91. package/dist/providers/hook-coverage.js +0 -47
  92. package/dist/providers/hook-entry.d.ts +0 -1
  93. package/dist/providers/hook-entry.js +0 -8
  94. package/dist/providers/surfaces.d.ts +0 -19
  95. package/dist/providers/surfaces.js +0 -91
  96. package/dist/reclaim.d.ts +0 -17
  97. package/dist/reclaim.js +0 -33
  98. package/dist/render.d.ts +0 -17
  99. package/dist/render.js +0 -61
  100. package/dist/repo-sync.d.ts +0 -27
  101. package/dist/repo-sync.js +0 -34
  102. package/dist/repos.d.ts +0 -11
  103. package/dist/repos.js +0 -82
  104. package/dist/skills.d.ts +0 -84
  105. package/dist/skills.js +0 -383
  106. package/dist/slugify.d.ts +0 -1
  107. package/dist/slugify.js +0 -8
  108. package/dist/state.d.ts +0 -23
  109. package/dist/state.js +0 -161
  110. package/dist/sync-report.d.ts +0 -59
  111. package/dist/sync-report.js +0 -87
  112. package/hooks/_recall.mjs +0 -288
  113. package/hooks/_receipt.mjs +0 -47
  114. package/hooks/_shared.mjs +0 -1610
  115. package/hooks/_upgrade.mjs +0 -51
  116. package/hooks/session-capture.mjs +0 -60
  117. package/hooks/session-compact.mjs +0 -19
  118. package/hooks/session-context.mjs +0 -258
  119. package/hooks/session-report.mjs +0 -42
  120. package/hooks/session-toolcontext.mjs +0 -183
@@ -1,57 +0,0 @@
1
- import type { AgentId, AgentPresence } from '../providers/detect.js';
2
- export interface DocumentPayload {
3
- readonly id: string;
4
- readonly name: string;
5
- readonly path: string;
6
- readonly content: string;
7
- }
8
- export type DocumentResult = {
9
- readonly id: string;
10
- readonly file: string;
11
- readonly status: 'synced';
12
- } | {
13
- readonly id: string;
14
- readonly file: string;
15
- readonly status: 'skipped_theirs';
16
- } | {
17
- readonly id: string;
18
- readonly file: string;
19
- readonly status: 'forked';
20
- } | {
21
- readonly file: string;
22
- readonly status: 'forked';
23
- } | {
24
- readonly file: string;
25
- readonly status: 'removed';
26
- };
27
- export interface DocumentRootSummary {
28
- readonly agent: AgentId;
29
- readonly dir: string;
30
- readonly results: readonly DocumentResult[];
31
- readonly reclaimed: boolean;
32
- }
33
- export interface DocumentSyncSummary {
34
- readonly dir: string;
35
- readonly results: readonly DocumentResult[];
36
- readonly reclaimed: boolean;
37
- }
38
- export interface EnvDocumentSyncSummary extends DocumentSyncSummary {
39
- readonly roots: readonly DocumentRootSummary[];
40
- }
41
- export interface DocumentSyncOptions {
42
- readonly workspaceId?: string;
43
- }
44
- export declare function syncDocumentFilesToRepo(repoPath: string, documents: readonly DocumentPayload[], options?: DocumentSyncOptions): Promise<DocumentSyncSummary>;
45
- export declare function syncDocumentFilesToEnv(documents: readonly DocumentPayload[], options?: DocumentSyncOptions & {
46
- readonly home?: string;
47
- readonly agents?: AgentPresence;
48
- }): Promise<EnvDocumentSyncSummary>;
49
- export declare function removeRepoDocumentFiles(repoPath: string): Promise<DocumentSyncSummary & {
50
- readonly status: 'cleaned' | 'no_dir';
51
- }>;
52
- export declare function removeEnvDocumentFiles(options?: {
53
- readonly home?: string;
54
- readonly agents?: AgentPresence;
55
- }): Promise<DocumentSyncSummary & {
56
- readonly status: 'cleaned' | 'no_dir';
57
- }>;
@@ -1,211 +0,0 @@
1
- import { existsSync, promises as fsp } from 'node:fs';
2
- import { homedir } from 'node:os';
3
- import { dirname, join } from 'node:path';
4
- import { writeFileAtomic } from '../lock.js';
5
- import { resolveDocRoots } from '../providers/surfaces.js';
6
- import { slugify } from '../slugify.js';
7
- import { DOCS_DIR, MANIFEST_FILE, hashDocument, parseManifest, renderManifest, } from './manifest.js';
8
- async function readManifest(docsDir) {
9
- try {
10
- const raw = await fsp.readFile(join(docsDir, MANIFEST_FILE), 'utf8');
11
- const parsed = parseManifest(raw);
12
- return {
13
- files: new Set(parsed.files),
14
- hashes: parsed.hashes,
15
- workspaceId: parsed.workspaceId,
16
- };
17
- }
18
- catch {
19
- return { files: new Set(), hashes: new Map(), workspaceId: null };
20
- }
21
- }
22
- async function writeManifest(docsDir, entries, workspaceId) {
23
- const body = renderManifest(entries, workspaceId ?? null);
24
- const path = join(docsDir, MANIFEST_FILE);
25
- const current = await fsp.readFile(path, 'utf8').catch(() => null);
26
- if (current === body)
27
- return;
28
- await writeFileAtomic(path, body);
29
- }
30
- async function ownershipOf(docsDir, file, manifest) {
31
- const recorded = manifest.hashes.get(file);
32
- if (recorded === undefined)
33
- return 'unknown';
34
- const current = await fsp.readFile(join(docsDir, file), 'utf8').catch(() => null);
35
- if (current === null)
36
- return 'unknown';
37
- return hashDocument(current) === recorded ? 'ours' : 'forked';
38
- }
39
- async function ensureDir(path) {
40
- await fsp.mkdir(path, { recursive: true, mode: 0o700 });
41
- if (process.platform !== 'win32') {
42
- try {
43
- await fsp.chmod(path, 0o700);
44
- }
45
- catch {
46
- }
47
- }
48
- }
49
- function relativePathFor(document) {
50
- const slug = slugify(document.name);
51
- const fallback = slug.length > 0 ? `${slug}.md` : `document-${slugify(document.id) || 'unnamed'}.md`;
52
- const raw = document.path.trim();
53
- if (raw.includes('\\') || raw.startsWith('/'))
54
- return fallback;
55
- const isOurs = raw.startsWith(`${DOCS_DIR}/`);
56
- const segments = (isOurs ? raw.slice(DOCS_DIR.length + 1) : (raw.split('/').pop() ?? ''))
57
- .split('/')
58
- .filter((segment) => segment.length > 0);
59
- if (segments.length === 0 || segments.length > 2)
60
- return fallback;
61
- if (segments.some((segment) => segment.includes('..')))
62
- return fallback;
63
- if (!segments[segments.length - 1].endsWith('.md'))
64
- return fallback;
65
- return segments.join('/');
66
- }
67
- async function pruneEmptiedDirs(docsDir, files) {
68
- const dirs = new Set();
69
- for (const file of files) {
70
- const dir = dirname(file);
71
- if (dir !== '.' && dir !== '')
72
- dirs.add(dir);
73
- }
74
- for (const dir of dirs) {
75
- await fsp.rmdir(join(docsDir, dir)).catch(() => {
76
- });
77
- }
78
- }
79
- async function syncDocumentFilesInDir(docsDir, documents, options = {}) {
80
- const previous = await readManifest(docsDir);
81
- if (documents.length === 0 && previous.files.size === 0) {
82
- return { dir: docsDir, results: [], reclaimed: false };
83
- }
84
- if (documents.length === 0) {
85
- const ours = options.workspaceId !== undefined &&
86
- previous.workspaceId !== null &&
87
- previous.workspaceId === options.workspaceId;
88
- if (!ours) {
89
- return { dir: docsDir, results: [], reclaimed: false };
90
- }
91
- const cleaned = await removeDocumentFilesInDir(docsDir);
92
- return { dir: cleaned.dir, results: cleaned.results, reclaimed: true };
93
- }
94
- await ensureDir(docsDir);
95
- const entries = [];
96
- const results = [];
97
- for (const document of documents) {
98
- const fileName = relativePathFor(document);
99
- const filePath = join(docsDir, fileName);
100
- const current = await fsp.readFile(filePath, 'utf8').catch(() => null);
101
- if (current === document.content) {
102
- entries.push({ file: fileName, sha256: hashDocument(document.content) });
103
- results.push({ id: document.id, file: fileName, status: 'synced' });
104
- continue;
105
- }
106
- if (current !== null && !previous.files.has(fileName)) {
107
- results.push({ id: document.id, file: fileName, status: 'skipped_theirs' });
108
- continue;
109
- }
110
- if (current !== null && (await ownershipOf(docsDir, fileName, previous)) === 'forked') {
111
- entries.push({
112
- file: fileName,
113
- sha256: previous.hashes.get(fileName) ?? null,
114
- });
115
- results.push({ id: document.id, file: fileName, status: 'forked' });
116
- continue;
117
- }
118
- if (fileName.includes('/'))
119
- await ensureDir(dirname(filePath));
120
- await writeFileAtomic(filePath, document.content);
121
- entries.push({ file: fileName, sha256: hashDocument(document.content) });
122
- results.push({ id: document.id, file: fileName, status: 'synced' });
123
- }
124
- const keep = new Set(entries.map((entry) => entry.file));
125
- const removed = [];
126
- for (const stale of previous.files) {
127
- if (keep.has(stale))
128
- continue;
129
- if ((await ownershipOf(docsDir, stale, previous)) === 'forked') {
130
- results.push({ file: stale, status: 'forked' });
131
- continue;
132
- }
133
- await fsp.rm(join(docsDir, stale), { force: true });
134
- removed.push(stale);
135
- results.push({ file: stale, status: 'removed' });
136
- }
137
- await pruneEmptiedDirs(docsDir, removed);
138
- await writeManifest(docsDir, entries, options.workspaceId);
139
- return { dir: docsDir, results, reclaimed: false };
140
- }
141
- async function removeDocumentFilesInDir(docsDir) {
142
- if (!existsSync(docsDir)) {
143
- return { dir: docsDir, results: [], reclaimed: false, status: 'no_dir' };
144
- }
145
- const manifest = await readManifest(docsDir);
146
- const results = [];
147
- const removed = [];
148
- for (const file of manifest.files) {
149
- if ((await ownershipOf(docsDir, file, manifest)) === 'forked') {
150
- results.push({ file, status: 'forked' });
151
- continue;
152
- }
153
- await fsp.rm(join(docsDir, file), { force: true });
154
- removed.push(file);
155
- results.push({ file, status: 'removed' });
156
- }
157
- await fsp.rm(join(docsDir, MANIFEST_FILE), { force: true });
158
- await pruneEmptiedDirs(docsDir, removed);
159
- const left = await fsp.readdir(docsDir).catch(() => ['keep']);
160
- if (left.length === 0) {
161
- await fsp.rm(docsDir, { recursive: true, force: true });
162
- }
163
- return { dir: docsDir, results, reclaimed: true, status: 'cleaned' };
164
- }
165
- export async function syncDocumentFilesToRepo(repoPath, documents, options = {}) {
166
- if (!existsSync(repoPath)) {
167
- throw new Error(`Path does not exist: ${repoPath}`);
168
- }
169
- return syncDocumentFilesInDir(join(repoPath, DOCS_DIR), documents, options);
170
- }
171
- export async function syncDocumentFilesToEnv(documents, options = {}) {
172
- const { home, agents, ...rest } = options;
173
- const resolvedHome = home ?? homedir();
174
- const roots = await resolveDocRoots(resolvedHome, agents);
175
- const summaries = [];
176
- for (const root of roots) {
177
- summaries.push({
178
- agent: root.agent,
179
- ...(await syncDocumentFilesInDir(root.dir, documents, rest)),
180
- });
181
- }
182
- const primary = summaries.find((summary) => summary.agent === 'claude') ??
183
- summaries[0] ??
184
- null;
185
- return {
186
- dir: primary?.dir ?? join(resolvedHome, DOCS_DIR),
187
- results: summaries.flatMap((summary) => summary.results),
188
- reclaimed: summaries.some((summary) => summary.reclaimed),
189
- roots: summaries,
190
- };
191
- }
192
- export async function removeRepoDocumentFiles(repoPath) {
193
- return removeDocumentFilesInDir(join(repoPath, DOCS_DIR));
194
- }
195
- export async function removeEnvDocumentFiles(options = {}) {
196
- const home = options.home ?? homedir();
197
- const roots = await resolveDocRoots(home, options.agents);
198
- const cleaned = [];
199
- for (const root of roots) {
200
- cleaned.push(await removeDocumentFilesInDir(root.dir));
201
- }
202
- const primary = cleaned[0];
203
- return {
204
- dir: primary?.dir ?? join(home, DOCS_DIR),
205
- results: cleaned.flatMap((one) => one.results),
206
- reclaimed: cleaned.some((one) => one.reclaimed),
207
- status: cleaned.some((one) => one.status === 'cleaned')
208
- ? 'cleaned'
209
- : 'no_dir',
210
- };
211
- }
@@ -1,7 +0,0 @@
1
- export interface Endpoints {
2
- readonly apiUrl: string;
3
- readonly mcpUrl: string;
4
- readonly webUrl: string;
5
- }
6
- export declare function resolveEndpoints(env?: NodeJS.ProcessEnv): Endpoints;
7
- export declare function isLocalEndpoint(endpoints: Endpoints): boolean;
package/dist/endpoints.js DELETED
@@ -1,15 +0,0 @@
1
- const PROD_API_URL = 'https://app.gethrbr.com/v1';
2
- const PROD_MCP_URL = 'https://mcp.gethrbr.com/mcp';
3
- const PROD_WEB_URL = 'https://app.gethrbr.com';
4
- const strip = (url) => url.replace(/\/+$/, '');
5
- export function resolveEndpoints(env = process.env) {
6
- const read = (suffix) => env[`HARBOR_${suffix}`]?.trim() || env[`ALEF0_${suffix}`]?.trim();
7
- return {
8
- apiUrl: strip(read('API_URL') || PROD_API_URL),
9
- mcpUrl: strip(read('MCP_URL') || PROD_MCP_URL),
10
- webUrl: strip(read('WEB_URL') || PROD_WEB_URL),
11
- };
12
- }
13
- export function isLocalEndpoint(endpoints) {
14
- return /^https?:\/\/(localhost|127\.0\.0\.1|\[::1\])(:|\/|$)/i.test(endpoints.apiUrl);
15
- }
@@ -1,25 +0,0 @@
1
- import type { ContextBundleDocument, ContextBundleSkill } from './documents/bundle.js';
2
- export interface EnvBundle {
3
- readonly contentHash: string;
4
- readonly skills: ReadonlyArray<ContextBundleSkill>;
5
- readonly documents?: ReadonlyArray<ContextBundleDocument>;
6
- readonly lastUpdated: string;
7
- }
8
- export type FetchEnvBundleResult = {
9
- readonly kind: 'ok';
10
- readonly bundle: EnvBundle;
11
- } | {
12
- readonly kind: 'unsupported';
13
- } | {
14
- readonly kind: 'error';
15
- readonly status: number | 'network';
16
- readonly message: string;
17
- };
18
- export interface FetchEnvBundleInput {
19
- readonly apiBase: string;
20
- readonly workspaceId: string;
21
- readonly bearerToken: string;
22
- readonly fetchImpl?: typeof fetch;
23
- }
24
- export declare function envBundleUrl(apiBase: string, workspaceId: string): string;
25
- export declare function fetchEnvBundle(input: FetchEnvBundleInput): Promise<FetchEnvBundleResult>;
@@ -1,33 +0,0 @@
1
- import { ApiError, apiRequest } from './api.js';
2
- function stripTrailingSlash(s) {
3
- return s.endsWith('/') ? s.slice(0, -1) : s;
4
- }
5
- export function envBundleUrl(apiBase, workspaceId) {
6
- return (`${stripTrailingSlash(apiBase)}/workspaces/${encodeURIComponent(workspaceId)}` +
7
- `/context/env-bundle`);
8
- }
9
- export async function fetchEnvBundle(input) {
10
- const url = envBundleUrl(input.apiBase, input.workspaceId);
11
- try {
12
- const body = await apiRequest(url, {
13
- bearer: input.bearerToken,
14
- fetchImpl: input.fetchImpl,
15
- });
16
- const data = body?.data;
17
- if (!data)
18
- return { kind: 'error', status: 200, message: 'missing data field' };
19
- return { kind: 'ok', bundle: data };
20
- }
21
- catch (err) {
22
- if (!(err instanceof ApiError)) {
23
- return {
24
- kind: 'error',
25
- status: 'network',
26
- message: err instanceof Error ? err.message : String(err),
27
- };
28
- }
29
- if (err.status === 404)
30
- return { kind: 'unsupported' };
31
- return { kind: 'error', status: err.status ?? 'network', message: err.message };
32
- }
33
- }
@@ -1,27 +0,0 @@
1
- import type { AgentId, AgentPresence } from './providers/detect.js';
2
- export type ScannedKind = 'SKILL' | 'DOCUMENT';
3
- export type ScannedState = 'ours' | 'forked' | 'missing' | 'unverifiable';
4
- export interface ScannedFile {
5
- readonly kind: ScannedKind;
6
- readonly file: string;
7
- readonly sha256: string | null;
8
- readonly state: ScannedState;
9
- }
10
- export interface ScannedRoot {
11
- readonly agent: AgentId;
12
- readonly dir: string;
13
- readonly managed: boolean;
14
- readonly files: readonly ScannedFile[];
15
- }
16
- export interface EnvScan {
17
- readonly roots: readonly ScannedRoot[];
18
- }
19
- export interface EnvScanOptions {
20
- readonly home?: string;
21
- readonly agents?: AgentPresence;
22
- }
23
- export declare function scanEnv(options?: EnvScanOptions): Promise<EnvScan>;
24
- export declare function scannedFiles(scan: EnvScan): ReadonlyArray<ScannedFile & {
25
- readonly agent: AgentId;
26
- readonly dir: string;
27
- }>;
package/dist/env-scan.js DELETED
@@ -1,41 +0,0 @@
1
- import { promises as fsp } from 'node:fs';
2
- import { homedir } from 'node:os';
3
- import { join } from 'node:path';
4
- import { MANIFEST_FILE, hashDocument, parseManifest, } from './documents/manifest.js';
5
- import { resolveDocRoots, resolveSkillRoots } from './providers/surfaces.js';
6
- async function classify(dir, file, recorded) {
7
- const content = await fsp.readFile(join(dir, file), 'utf8').catch(() => null);
8
- if (content === null)
9
- return { sha256: null, state: 'missing' };
10
- const onDisk = hashDocument(content);
11
- if (recorded === undefined)
12
- return { sha256: onDisk, state: 'unverifiable' };
13
- return { sha256: onDisk, state: onDisk === recorded ? 'ours' : 'forked' };
14
- }
15
- async function scanManifestDir(dir, kind) {
16
- const raw = await fsp.readFile(join(dir, MANIFEST_FILE), 'utf8').catch(() => null);
17
- if (raw === null)
18
- return { managed: false, files: [] };
19
- const { files, hashes } = parseManifest(raw);
20
- const out = [];
21
- for (const file of files) {
22
- out.push({ kind, file, ...(await classify(dir, file, hashes.get(file))) });
23
- }
24
- return { managed: true, files: out };
25
- }
26
- export async function scanEnv(options = {}) {
27
- const home = options.home ?? homedir();
28
- const roots = [];
29
- for (const root of await resolveSkillRoots(home, options.agents)) {
30
- const scanned = await scanManifestDir(root.dir, 'SKILL');
31
- roots.push({ agent: root.agent, dir: root.dir, ...scanned });
32
- }
33
- for (const root of await resolveDocRoots(home, options.agents)) {
34
- const scanned = await scanManifestDir(root.dir, 'DOCUMENT');
35
- roots.push({ agent: root.agent, dir: root.dir, ...scanned });
36
- }
37
- return { roots };
38
- }
39
- export function scannedFiles(scan) {
40
- return scan.roots.flatMap((root) => root.files.map((file) => ({ ...file, agent: root.agent, dir: root.dir })));
41
- }
@@ -1,31 +0,0 @@
1
- import { type ApplyDocumentsOutcome } from './documents/apply.js';
2
- import { type EnvSkillSyncSummary } from './skills.js';
3
- export type EnvSkillOutcome = {
4
- readonly kind: 'synced';
5
- readonly summary: EnvSkillSyncSummary;
6
- } | {
7
- readonly kind: 'unsupported';
8
- } | {
9
- readonly kind: 'error';
10
- };
11
- export type EnvDocumentOutcome = {
12
- readonly kind: 'synced';
13
- readonly outcome: ApplyDocumentsOutcome;
14
- } | {
15
- readonly kind: 'unsupported';
16
- } | {
17
- readonly kind: 'error';
18
- };
19
- export interface EnvSyncOptions {
20
- readonly apiBase: string;
21
- readonly workspaceId: string;
22
- readonly bearerToken: string;
23
- readonly fetchImpl?: typeof fetch;
24
- readonly home?: string;
25
- }
26
- export interface EnvSyncResult {
27
- readonly skills: EnvSkillOutcome;
28
- readonly documents: EnvDocumentOutcome;
29
- readonly bundleHash?: string;
30
- }
31
- export declare function syncEnvPlane(opts: EnvSyncOptions): Promise<EnvSyncResult>;
package/dist/env-sync.js DELETED
@@ -1,37 +0,0 @@
1
- import { applyDocumentsToEnv } from './documents/apply.js';
2
- import { fetchEnvBundle } from './env-bundle.js';
3
- import { syncSkillFilesToEnv } from './skills.js';
4
- export async function syncEnvPlane(opts) {
5
- const fetched = await fetchEnvBundle({
6
- apiBase: opts.apiBase,
7
- workspaceId: opts.workspaceId,
8
- bearerToken: opts.bearerToken,
9
- ...(opts.fetchImpl ? { fetchImpl: opts.fetchImpl } : {}),
10
- });
11
- if (fetched.kind !== 'ok') {
12
- const kind = fetched.kind === 'unsupported' ? 'unsupported' : 'error';
13
- return { skills: { kind }, documents: { kind } };
14
- }
15
- const home = opts.home === undefined ? {} : { home: opts.home };
16
- const skills = {
17
- kind: 'synced',
18
- summary: await syncSkillFilesToEnv(fetched.bundle.skills, {
19
- workspaceId: opts.workspaceId,
20
- ...home,
21
- }),
22
- };
23
- const documents = {
24
- kind: 'synced',
25
- outcome: await applyDocumentsToEnv(fetched.bundle.documents, {
26
- workspaceId: opts.workspaceId,
27
- ...home,
28
- }),
29
- };
30
- return {
31
- skills,
32
- documents,
33
- ...(fetched.bundle.contentHash === undefined
34
- ? {}
35
- : { bundleHash: fetched.bundle.contentHash }),
36
- };
37
- }
package/dist/index.d.ts DELETED
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env node
2
- export declare const VERBS: readonly ["init", "login", "logout", "bind", "unbind", "sync", "daemon", "status", "workspaces", "doctor", "context", "on", "off", "help", "version"];
3
- type Verb = (typeof VERBS)[number];
4
- interface ParsedArgs {
5
- readonly verb: Verb;
6
- readonly flags: Readonly<Record<string, string | true>>;
7
- }
8
- export declare function parseArgs(argv: readonly string[]): ParsedArgs;
9
- export declare function main(argv: readonly string[]): Promise<number>;
10
- export declare function isProgramEntry(argv1: string | undefined, moduleUrl: string, resolve?: (path: string) => string): boolean;
11
- export {};