@wayai/cli 0.3.40 → 0.3.42
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/dist/index.js +16920 -310
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
- package/dist/commands/admin.d.ts +0 -1
- package/dist/commands/admin.js +0 -913
- package/dist/commands/admin.js.map +0 -1
- package/dist/commands/analytics.d.ts +0 -34
- package/dist/commands/analytics.js +0 -605
- package/dist/commands/analytics.js.map +0 -1
- package/dist/commands/conversations.d.ts +0 -14
- package/dist/commands/conversations.js +0 -292
- package/dist/commands/conversations.js.map +0 -1
- package/dist/commands/create-credential.d.ts +0 -20
- package/dist/commands/create-credential.js +0 -146
- package/dist/commands/create-credential.js.map +0 -1
- package/dist/commands/delete-history.d.ts +0 -15
- package/dist/commands/delete-history.js +0 -56
- package/dist/commands/delete-history.js.map +0 -1
- package/dist/commands/eval-capture.d.ts +0 -1
- package/dist/commands/eval-capture.js +0 -135
- package/dist/commands/eval-capture.js.map +0 -1
- package/dist/commands/eval-results.d.ts +0 -10
- package/dist/commands/eval-results.js +0 -168
- package/dist/commands/eval-results.js.map +0 -1
- package/dist/commands/eval.d.ts +0 -1
- package/dist/commands/eval.js +0 -49
- package/dist/commands/eval.js.map +0 -1
- package/dist/commands/evals.d.ts +0 -21
- package/dist/commands/evals.js +0 -120
- package/dist/commands/evals.js.map +0 -1
- package/dist/commands/init.d.ts +0 -16
- package/dist/commands/init.js +0 -191
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/list.d.ts +0 -13
- package/dist/commands/list.js +0 -70
- package/dist/commands/list.js.map +0 -1
- package/dist/commands/login.d.ts +0 -8
- package/dist/commands/login.js +0 -145
- package/dist/commands/login.js.map +0 -1
- package/dist/commands/logout.d.ts +0 -1
- package/dist/commands/logout.js +0 -19
- package/dist/commands/logout.js.map +0 -1
- package/dist/commands/migrate.d.ts +0 -12
- package/dist/commands/migrate.js +0 -106
- package/dist/commands/migrate.js.map +0 -1
- package/dist/commands/observability.d.ts +0 -14
- package/dist/commands/observability.js +0 -124
- package/dist/commands/observability.js.map +0 -1
- package/dist/commands/org.d.ts +0 -19
- package/dist/commands/org.js +0 -186
- package/dist/commands/org.js.map +0 -1
- package/dist/commands/pull.d.ts +0 -31
- package/dist/commands/pull.js +0 -210
- package/dist/commands/pull.js.map +0 -1
- package/dist/commands/push.d.ts +0 -25
- package/dist/commands/push.js +0 -472
- package/dist/commands/push.js.map +0 -1
- package/dist/commands/report-create.d.ts +0 -18
- package/dist/commands/report-create.js +0 -143
- package/dist/commands/report-create.js.map +0 -1
- package/dist/commands/report.d.ts +0 -16
- package/dist/commands/report.js +0 -252
- package/dist/commands/report.js.map +0 -1
- package/dist/commands/run-eval.d.ts +0 -15
- package/dist/commands/run-eval.js +0 -187
- package/dist/commands/run-eval.js.map +0 -1
- package/dist/commands/send-message.d.ts +0 -11
- package/dist/commands/send-message.js +0 -63
- package/dist/commands/send-message.js.map +0 -1
- package/dist/commands/status.d.ts +0 -17
- package/dist/commands/status.js +0 -205
- package/dist/commands/status.js.map +0 -1
- package/dist/commands/sync-mcp.d.ts +0 -16
- package/dist/commands/sync-mcp.js +0 -51
- package/dist/commands/sync-mcp.js.map +0 -1
- package/dist/commands/sync-skills.d.ts +0 -10
- package/dist/commands/sync-skills.js +0 -49
- package/dist/commands/sync-skills.js.map +0 -1
- package/dist/commands/unlock.d.ts +0 -1
- package/dist/commands/unlock.js +0 -13
- package/dist/commands/unlock.js.map +0 -1
- package/dist/commands/update-credential.d.ts +0 -29
- package/dist/commands/update-credential.js +0 -156
- package/dist/commands/update-credential.js.map +0 -1
- package/dist/commands/update.d.ts +0 -6
- package/dist/commands/update.js +0 -36
- package/dist/commands/update.js.map +0 -1
- package/dist/commands/use.d.ts +0 -1
- package/dist/commands/use.js +0 -56
- package/dist/commands/use.js.map +0 -1
- package/dist/commands/whoami.d.ts +0 -11
- package/dist/commands/whoami.js +0 -30
- package/dist/commands/whoami.js.map +0 -1
- package/dist/index.d.ts +0 -28
- package/dist/lib/analytics-constants.d.ts +0 -6
- package/dist/lib/analytics-constants.js +0 -14
- package/dist/lib/analytics-constants.js.map +0 -1
- package/dist/lib/api-client.d.ts +0 -568
- package/dist/lib/api-client.js +0 -445
- package/dist/lib/api-client.js.map +0 -1
- package/dist/lib/auth.d.ts +0 -50
- package/dist/lib/auth.js +0 -230
- package/dist/lib/auth.js.map +0 -1
- package/dist/lib/config.d.ts +0 -34
- package/dist/lib/config.js +0 -69
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/credential-utils.d.ts +0 -36
- package/dist/lib/credential-utils.js +0 -88
- package/dist/lib/credential-utils.js.map +0 -1
- package/dist/lib/diff-display.d.ts +0 -8
- package/dist/lib/diff-display.js +0 -37
- package/dist/lib/diff-display.js.map +0 -1
- package/dist/lib/eval-format.d.ts +0 -29
- package/dist/lib/eval-format.js +0 -44
- package/dist/lib/eval-format.js.map +0 -1
- package/dist/lib/hub-lock.d.ts +0 -7
- package/dist/lib/hub-lock.js +0 -116
- package/dist/lib/hub-lock.js.map +0 -1
- package/dist/lib/layout.d.ts +0 -79
- package/dist/lib/layout.js +0 -133
- package/dist/lib/layout.js.map +0 -1
- package/dist/lib/org-workspace.d.ts +0 -22
- package/dist/lib/org-workspace.js +0 -106
- package/dist/lib/org-workspace.js.map +0 -1
- package/dist/lib/parser.d.ts +0 -16
- package/dist/lib/parser.js +0 -306
- package/dist/lib/parser.js.map +0 -1
- package/dist/lib/repo-config.d.ts +0 -23
- package/dist/lib/repo-config.js +0 -91
- package/dist/lib/repo-config.js.map +0 -1
- package/dist/lib/report-edit-args.d.ts +0 -27
- package/dist/lib/report-edit-args.js +0 -56
- package/dist/lib/report-edit-args.js.map +0 -1
- package/dist/lib/report-inbox.d.ts +0 -19
- package/dist/lib/report-inbox.js +0 -73
- package/dist/lib/report-inbox.js.map +0 -1
- package/dist/lib/resource-files.d.ts +0 -29
- package/dist/lib/resource-files.js +0 -156
- package/dist/lib/resource-files.js.map +0 -1
- package/dist/lib/sentry.d.ts +0 -38
- package/dist/lib/sentry.js +0 -168
- package/dist/lib/sentry.js.map +0 -1
- package/dist/lib/skill-version.d.ts +0 -9
- package/dist/lib/skill-version.js +0 -53
- package/dist/lib/skill-version.js.map +0 -1
- package/dist/lib/sql-output.d.ts +0 -17
- package/dist/lib/sql-output.js +0 -48
- package/dist/lib/sql-output.js.map +0 -1
- package/dist/lib/token-store.d.ts +0 -37
- package/dist/lib/token-store.js +0 -354
- package/dist/lib/token-store.js.map +0 -1
- package/dist/lib/types.d.ts +0 -18
- package/dist/lib/types.js +0 -5
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/utils.d.ts +0 -97
- package/dist/lib/utils.js +0 -288
- package/dist/lib/utils.js.map +0 -1
- package/dist/lib/version-cache.d.ts +0 -10
- package/dist/lib/version-cache.js +0 -34
- package/dist/lib/version-cache.js.map +0 -1
- package/dist/lib/workspace.d.ts +0 -112
- package/dist/lib/workspace.js +0 -387
- package/dist/lib/workspace.js.map +0 -1
- package/dist/lib/yaml-writer.d.ts +0 -18
- package/dist/lib/yaml-writer.js +0 -283
- package/dist/lib/yaml-writer.js.map +0 -1
package/dist/lib/hub-lock.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
// Tripwire only: agents/users can override via `wayai unlock`.
|
|
2
|
-
import { execFileSync } from 'node:child_process';
|
|
3
|
-
import * as fs from 'node:fs';
|
|
4
|
-
import * as path from 'node:path';
|
|
5
|
-
import { UUID_RE } from './utils.js';
|
|
6
|
-
const LOCK_FILENAME = 'wayai-lock';
|
|
7
|
-
// Cache keyed by cwd so tests that chdir between checkouts re-resolve.
|
|
8
|
-
let _lockPathCache;
|
|
9
|
-
export function getLockPath() {
|
|
10
|
-
const cwd = process.cwd();
|
|
11
|
-
if (_lockPathCache && _lockPathCache.cwd === cwd)
|
|
12
|
-
return _lockPathCache.lockPath;
|
|
13
|
-
let gitDir;
|
|
14
|
-
try {
|
|
15
|
-
gitDir = execFileSync('git', ['rev-parse', '--git-dir'], {
|
|
16
|
-
cwd,
|
|
17
|
-
encoding: 'utf-8',
|
|
18
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
19
|
-
}).trim();
|
|
20
|
-
}
|
|
21
|
-
catch {
|
|
22
|
-
_lockPathCache = { cwd, lockPath: null };
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
const lockPath = gitDir ? path.resolve(cwd, gitDir, LOCK_FILENAME) : null;
|
|
26
|
-
_lockPathCache = { cwd, lockPath };
|
|
27
|
-
return lockPath;
|
|
28
|
-
}
|
|
29
|
-
// Surfaces non-ENOENT errors (EACCES) so unreadable locks don't masquerade as unlocked.
|
|
30
|
-
export function readLock() {
|
|
31
|
-
const lockPath = getLockPath();
|
|
32
|
-
if (!lockPath)
|
|
33
|
-
return null;
|
|
34
|
-
let raw;
|
|
35
|
-
try {
|
|
36
|
-
raw = fs.readFileSync(lockPath, 'utf-8');
|
|
37
|
-
}
|
|
38
|
-
catch (err) {
|
|
39
|
-
if (err.code === 'ENOENT')
|
|
40
|
-
return null;
|
|
41
|
-
throw err;
|
|
42
|
-
}
|
|
43
|
-
const trimmed = raw.trim();
|
|
44
|
-
return UUID_RE.test(trimmed) ? trimmed : null;
|
|
45
|
-
}
|
|
46
|
-
export function writeLock(hubId) {
|
|
47
|
-
if (!UUID_RE.test(hubId)) {
|
|
48
|
-
throw new Error(`Invalid hub_id (must be a UUID): ${hubId}`);
|
|
49
|
-
}
|
|
50
|
-
const lockPath = getLockPath();
|
|
51
|
-
if (!lockPath) {
|
|
52
|
-
throw new Error('Not inside a git repository — cannot write hub lock.');
|
|
53
|
-
}
|
|
54
|
-
fs.writeFileSync(lockPath, `${hubId}\n`, 'utf-8');
|
|
55
|
-
}
|
|
56
|
-
// Returns true if a lock existed and was removed, false if absent. Surfaces non-ENOENT errors.
|
|
57
|
-
export function clearLock() {
|
|
58
|
-
const lockPath = getLockPath();
|
|
59
|
-
if (!lockPath)
|
|
60
|
-
return false;
|
|
61
|
-
try {
|
|
62
|
-
fs.unlinkSync(lockPath);
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
if (err.code === 'ENOENT')
|
|
67
|
-
return false;
|
|
68
|
-
throw err;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
export function assertHubMatchesLock(resolvedHubId, hubLabel) {
|
|
72
|
-
const locked = readLock();
|
|
73
|
-
if (!locked)
|
|
74
|
-
return;
|
|
75
|
-
if (locked === resolvedHubId)
|
|
76
|
-
return;
|
|
77
|
-
const target = hubLabel ? `${hubLabel} (${resolvedHubId})` : resolvedHubId;
|
|
78
|
-
console.error([
|
|
79
|
-
`This worktree is locked to hub ${locked}, but the command resolved to ${target}.`,
|
|
80
|
-
'',
|
|
81
|
-
'This usually means a prompt was routed to the wrong worktree.',
|
|
82
|
-
'Confirm with the user before unlocking. To override:',
|
|
83
|
-
' wayai unlock # clear the lock for this worktree',
|
|
84
|
-
` wayai use ${resolvedHubId} # rebind this worktree to the new hub`,
|
|
85
|
-
].join('\n'));
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
// Best-effort: errors don't fail the parent operation (which already succeeded).
|
|
89
|
-
export function autoLockIfUnlocked(hubId) {
|
|
90
|
-
try {
|
|
91
|
-
if (readLock())
|
|
92
|
-
return false;
|
|
93
|
-
writeLock(hubId);
|
|
94
|
-
console.log(`Worktree locked to hub ${hubId} (run \`wayai unlock\` to clear).`);
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
catch (err) {
|
|
98
|
-
console.warn(` Warning: could not auto-lock worktree (${err instanceof Error ? err.message : String(err)})`);
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
// Fail-secure: readLock errors propagate (matches assertHubMatchesLock).
|
|
103
|
-
export function assertNoLockBlocksHubCreation(newHubName) {
|
|
104
|
-
const locked = readLock();
|
|
105
|
-
if (!locked)
|
|
106
|
-
return;
|
|
107
|
-
console.error([
|
|
108
|
-
`This worktree is locked to hub ${locked}, but you're about to create a new hub "${newHubName}" here.`,
|
|
109
|
-
'',
|
|
110
|
-
'This usually means a prompt was routed to the wrong worktree.',
|
|
111
|
-
'Confirm with the user before unlocking. To override:',
|
|
112
|
-
' wayai unlock # clear the lock for this worktree',
|
|
113
|
-
].join('\n'));
|
|
114
|
-
process.exit(1);
|
|
115
|
-
}
|
|
116
|
-
//# sourceMappingURL=hub-lock.js.map
|
package/dist/lib/hub-lock.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hub-lock.js","sourceRoot":"","sources":["../../src/lib/hub-lock.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,aAAa,GAAG,YAAY,CAAC;AAEnC,uEAAuE;AACvE,IAAI,cAAoE,CAAC;AAEzE,MAAM,UAAU,WAAW;IACzB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1B,IAAI,cAAc,IAAI,cAAc,CAAC,GAAG,KAAK,GAAG;QAAE,OAAO,cAAc,CAAC,QAAQ,CAAC;IAEjF,IAAI,MAAc,CAAC;IACnB,IAAI,CAAC;QACH,MAAM,GAAG,YAAY,CAAC,KAAK,EAAE,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE;YACvD,GAAG;YACH,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAChC,CAAC,CAAC,IAAI,EAAE,CAAC;IACZ,CAAC;IAAC,MAAM,CAAC;QACP,cAAc,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAA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QACb,OAAO,CAAC,IAAI,CAAC,4CAA4C,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC9G,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,6BAA6B,CAAC,UAAkB;IAC9D,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAC;IAC1B,IAAI,CAAC,MAAM;QAAE,OAAO;IAEpB,OAAO,CAAC,KAAK,CACX;QACE,kCAAkC,MAAM,2CAA2C,UAAU,SAAS;QACtG,EAAE;QACF,+DAA+D;QAC/D,sDAAsD;QACtD,gEAAgE;KACjE,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
package/dist/lib/layout.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Workspace layout descriptor + resolver.
|
|
3
|
-
*
|
|
4
|
-
* The CLI lays out hub-as-code under a single, product-namespaced root in the
|
|
5
|
-
* user's git repo:
|
|
6
|
-
*
|
|
7
|
-
* wayai-ws/
|
|
8
|
-
* org/ # org-as-code (shared resources)
|
|
9
|
-
* hubs/<hub>/ # one folder per preview hub
|
|
10
|
-
*
|
|
11
|
-
* This replaces the legacy split layout (`workspace/<hub>/` for hubs + a
|
|
12
|
-
* root-level `org/`). `resolveLayout` reads EITHER layout so existing repos —
|
|
13
|
-
* and their CI that runs `wayai push` against a committed `workspace/` — keep
|
|
14
|
-
* working until `wayai migrate` relocates them. New/fresh repos get the new
|
|
15
|
-
* layout. We never read both at once (no split-brain): the new layout wins.
|
|
16
|
-
*/
|
|
17
|
-
export interface WorkspaceLayout {
|
|
18
|
-
/** Product-namespaced root dir at the git root, e.g. 'wayai-ws'. */
|
|
19
|
-
wsDir: string;
|
|
20
|
-
/** Subdir of `wsDir` holding hub folders, e.g. 'hubs'. */
|
|
21
|
-
hubsSubdir: string;
|
|
22
|
-
/** Subdir of `wsDir` holding org-as-code, e.g. 'org'. */
|
|
23
|
-
orgSubdir: string;
|
|
24
|
-
/** Pre-migration locations to fall back to on read. */
|
|
25
|
-
legacy: {
|
|
26
|
-
wsDir: string;
|
|
27
|
-
orgAtRoot: string;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* MIRROR of the canonical layout in `@wayai/shared` (consumed by the backend
|
|
32
|
-
* `download_workspace` endpoint). The CLI CANNOT runtime-import `@wayai/shared`
|
|
33
|
-
* — it's a devDependency that would crash published installs with
|
|
34
|
-
* ERR_MODULE_NOT_FOUND (see `__tests__/no-shared-runtime-import.test.ts`). So
|
|
35
|
-
* this literal is duplicated locally and kept in lockstep by the drift-guard
|
|
36
|
-
* suite in `layout.test.ts`, exactly as `slugify` mirrors `slugifyKebab`.
|
|
37
|
-
*
|
|
38
|
-
* A second product (Rekor) is a second descriptor (`rekor-ws`), not a fork.
|
|
39
|
-
*/
|
|
40
|
-
export declare const WAYAI_LAYOUT: WorkspaceLayout;
|
|
41
|
-
export interface ResolvedLayout {
|
|
42
|
-
/** Absolute dir whose direct children are hub folders. */
|
|
43
|
-
hubsDir: string;
|
|
44
|
-
/** Absolute dir for org-as-code (`resources.yaml` + `resources/`). */
|
|
45
|
-
orgDir: string;
|
|
46
|
-
/** True when reading the pre-migration layout (`workspace/` + root `org/`). */
|
|
47
|
-
isLegacy: boolean;
|
|
48
|
-
/** True when the new layout is active but stale legacy dirs ALSO exist. */
|
|
49
|
-
legacyAlsoPresent: boolean;
|
|
50
|
-
}
|
|
51
|
-
/** True when `p` exists and is a directory (swallows ENOENT/EACCES). */
|
|
52
|
-
export declare function isDirectory(p: string): boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Resolve the active hub + org directories for a repo, handling the legacy
|
|
55
|
-
* layout. Pure (no side effects) so it's trivially testable — call
|
|
56
|
-
* `warnLayoutOnce` separately for the user-facing nudge.
|
|
57
|
-
*/
|
|
58
|
-
export declare function resolveLayout(gitRoot: string, layout?: WorkspaceLayout): ResolvedLayout;
|
|
59
|
-
/** Convenience: the dir whose direct children are hub folders. */
|
|
60
|
-
export declare function resolveHubsDir(gitRoot: string): string;
|
|
61
|
-
/** Convenience: the org-as-code dir. */
|
|
62
|
-
export declare function resolveOrgDir(gitRoot: string): string;
|
|
63
|
-
/**
|
|
64
|
-
* Display label for the hubs dir relative to the git root (e.g. "wayai-ws/hubs",
|
|
65
|
-
* or "workspace" for a legacy repo) — for user-facing messages. Falls back to the
|
|
66
|
-
* canonical new-layout label (derived from WAYAI_LAYOUT, never a bare literal)
|
|
67
|
-
* when not in a git repo.
|
|
68
|
-
*/
|
|
69
|
-
export declare function hubsDirLabel(gitRoot: string | null): string;
|
|
70
|
-
/** Reset the one-time warning guard (test-only). */
|
|
71
|
-
export declare function _resetLayoutWarning(): void;
|
|
72
|
-
/**
|
|
73
|
-
* Emit a user-facing nudge about the layout, at most once per process for the
|
|
74
|
-
* interactive case. When stale legacy dirs sit alongside the new layout, warn
|
|
75
|
-
* LOUDLY on every run in non-TTY/CI — a CI `wayai push` that silently ignores
|
|
76
|
-
* edits to a committed `workspace/` is a footgun. Callers must commit
|
|
77
|
-
* `wayai migrate` in the same change that updates their CI.
|
|
78
|
-
*/
|
|
79
|
-
export declare function warnLayoutOnce(gitRoot: string): void;
|
package/dist/lib/layout.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Workspace layout descriptor + resolver.
|
|
3
|
-
*
|
|
4
|
-
* The CLI lays out hub-as-code under a single, product-namespaced root in the
|
|
5
|
-
* user's git repo:
|
|
6
|
-
*
|
|
7
|
-
* wayai-ws/
|
|
8
|
-
* org/ # org-as-code (shared resources)
|
|
9
|
-
* hubs/<hub>/ # one folder per preview hub
|
|
10
|
-
*
|
|
11
|
-
* This replaces the legacy split layout (`workspace/<hub>/` for hubs + a
|
|
12
|
-
* root-level `org/`). `resolveLayout` reads EITHER layout so existing repos —
|
|
13
|
-
* and their CI that runs `wayai push` against a committed `workspace/` — keep
|
|
14
|
-
* working until `wayai migrate` relocates them. New/fresh repos get the new
|
|
15
|
-
* layout. We never read both at once (no split-brain): the new layout wins.
|
|
16
|
-
*/
|
|
17
|
-
import * as fs from 'node:fs';
|
|
18
|
-
import * as path from 'node:path';
|
|
19
|
-
/**
|
|
20
|
-
* MIRROR of the canonical layout in `@wayai/shared` (consumed by the backend
|
|
21
|
-
* `download_workspace` endpoint). The CLI CANNOT runtime-import `@wayai/shared`
|
|
22
|
-
* — it's a devDependency that would crash published installs with
|
|
23
|
-
* ERR_MODULE_NOT_FOUND (see `__tests__/no-shared-runtime-import.test.ts`). So
|
|
24
|
-
* this literal is duplicated locally and kept in lockstep by the drift-guard
|
|
25
|
-
* suite in `layout.test.ts`, exactly as `slugify` mirrors `slugifyKebab`.
|
|
26
|
-
*
|
|
27
|
-
* A second product (Rekor) is a second descriptor (`rekor-ws`), not a fork.
|
|
28
|
-
*/
|
|
29
|
-
export const WAYAI_LAYOUT = {
|
|
30
|
-
wsDir: 'wayai-ws',
|
|
31
|
-
hubsSubdir: 'hubs',
|
|
32
|
-
orgSubdir: 'org',
|
|
33
|
-
legacy: { wsDir: 'workspace', orgAtRoot: 'org' },
|
|
34
|
-
};
|
|
35
|
-
/** True when `p` exists and is a directory (swallows ENOENT/EACCES). */
|
|
36
|
-
export function isDirectory(p) {
|
|
37
|
-
try {
|
|
38
|
-
return fs.statSync(p).isDirectory();
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Resolve the active hub + org directories for a repo, handling the legacy
|
|
46
|
-
* layout. Pure (no side effects) so it's trivially testable — call
|
|
47
|
-
* `warnLayoutOnce` separately for the user-facing nudge.
|
|
48
|
-
*/
|
|
49
|
-
export function resolveLayout(gitRoot, layout = WAYAI_LAYOUT) {
|
|
50
|
-
const newWs = path.join(gitRoot, layout.wsDir);
|
|
51
|
-
const legacyWs = path.join(gitRoot, layout.legacy.wsDir);
|
|
52
|
-
const legacyOrg = path.join(gitRoot, layout.legacy.orgAtRoot);
|
|
53
|
-
const newExists = isDirectory(newWs);
|
|
54
|
-
const legacyExists = isDirectory(legacyWs) || isDirectory(legacyOrg);
|
|
55
|
-
if (newExists) {
|
|
56
|
-
return {
|
|
57
|
-
hubsDir: path.join(newWs, layout.hubsSubdir),
|
|
58
|
-
orgDir: path.join(newWs, layout.orgSubdir),
|
|
59
|
-
isLegacy: false,
|
|
60
|
-
legacyAlsoPresent: legacyExists,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
if (legacyExists) {
|
|
64
|
-
return {
|
|
65
|
-
hubsDir: legacyWs,
|
|
66
|
-
orgDir: legacyOrg,
|
|
67
|
-
isLegacy: true,
|
|
68
|
-
legacyAlsoPresent: false,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
// Fresh repo → new layout (materialized on demand by init/pull/org).
|
|
72
|
-
return {
|
|
73
|
-
hubsDir: path.join(newWs, layout.hubsSubdir),
|
|
74
|
-
orgDir: path.join(newWs, layout.orgSubdir),
|
|
75
|
-
isLegacy: false,
|
|
76
|
-
legacyAlsoPresent: false,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
/** Convenience: the dir whose direct children are hub folders. */
|
|
80
|
-
export function resolveHubsDir(gitRoot) {
|
|
81
|
-
return resolveLayout(gitRoot).hubsDir;
|
|
82
|
-
}
|
|
83
|
-
/** Convenience: the org-as-code dir. */
|
|
84
|
-
export function resolveOrgDir(gitRoot) {
|
|
85
|
-
return resolveLayout(gitRoot).orgDir;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Display label for the hubs dir relative to the git root (e.g. "wayai-ws/hubs",
|
|
89
|
-
* or "workspace" for a legacy repo) — for user-facing messages. Falls back to the
|
|
90
|
-
* canonical new-layout label (derived from WAYAI_LAYOUT, never a bare literal)
|
|
91
|
-
* when not in a git repo.
|
|
92
|
-
*/
|
|
93
|
-
export function hubsDirLabel(gitRoot) {
|
|
94
|
-
if (!gitRoot)
|
|
95
|
-
return path.join(WAYAI_LAYOUT.wsDir, WAYAI_LAYOUT.hubsSubdir);
|
|
96
|
-
return path.relative(gitRoot, resolveLayout(gitRoot).hubsDir);
|
|
97
|
-
}
|
|
98
|
-
let _layoutWarned = false;
|
|
99
|
-
/** Reset the one-time warning guard (test-only). */
|
|
100
|
-
export function _resetLayoutWarning() {
|
|
101
|
-
_layoutWarned = false;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Emit a user-facing nudge about the layout, at most once per process for the
|
|
105
|
-
* interactive case. When stale legacy dirs sit alongside the new layout, warn
|
|
106
|
-
* LOUDLY on every run in non-TTY/CI — a CI `wayai push` that silently ignores
|
|
107
|
-
* edits to a committed `workspace/` is a footgun. Callers must commit
|
|
108
|
-
* `wayai migrate` in the same change that updates their CI.
|
|
109
|
-
*/
|
|
110
|
-
export function warnLayoutOnce(gitRoot) {
|
|
111
|
-
const r = resolveLayout(gitRoot);
|
|
112
|
-
if (r.legacyAlsoPresent) {
|
|
113
|
-
const msg = `Warning: both ${WAYAI_LAYOUT.wsDir}/ and legacy ${WAYAI_LAYOUT.legacy.wsDir}/ ` +
|
|
114
|
-
`(or root ${WAYAI_LAYOUT.legacy.orgAtRoot}/) exist. The legacy dirs are IGNORED. ` +
|
|
115
|
-
`Finish \`wayai migrate\` and delete them.`;
|
|
116
|
-
// Non-TTY (CI): always loud, never suppressed.
|
|
117
|
-
if (!process.stdout.isTTY) {
|
|
118
|
-
console.warn(msg);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
if (!_layoutWarned) {
|
|
122
|
-
_layoutWarned = true;
|
|
123
|
-
console.warn(msg);
|
|
124
|
-
}
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
if (r.isLegacy && !_layoutWarned) {
|
|
128
|
-
_layoutWarned = true;
|
|
129
|
-
console.warn(`Note: using the legacy ${WAYAI_LAYOUT.legacy.wsDir}/ layout. ` +
|
|
130
|
-
`Run \`wayai migrate\` to move to ${WAYAI_LAYOUT.wsDir}/.`);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=layout.js.map
|
package/dist/lib/layout.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/lib/layout.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAalC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAoB;IAC3C,KAAK,EAAE,UAAU;IACjB,UAAU,EAAE,MAAM;IAClB,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE;CACjD,CAAC;AAaF,wEAAwE;AACxE,MAAM,UAAU,WAAW,CAAC,CAAS;IACnC,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAe,EACf,SAA0B,YAAY;IAEtC,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACzD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,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
|
3
|
-
* or the legacy root-level `org/` for un-migrated repos; see `layout.ts`).
|
|
4
|
-
*
|
|
5
|
-
* <orgDir>/
|
|
6
|
-
* resources.yaml # resource metadata (files stripped, like hub.yaml)
|
|
7
|
-
* resources/<slug>/... # file trees (SKILL.md, docs/…, binaries)
|
|
8
|
-
*
|
|
9
|
-
* Sits beside the hub folders under the same `wayai-ws/` root. One org per repo
|
|
10
|
-
* (org id comes from `.wayai.yaml`). Reuses the shared resource file-tree
|
|
11
|
-
* primitives so binary/hash/orphan rules match hub-as-code exactly.
|
|
12
|
-
*/
|
|
13
|
-
import type { OrgResourcesPayload } from './types.js';
|
|
14
|
-
export declare const ORG_MANIFEST_NAME = "resources.yaml";
|
|
15
|
-
export declare function getOrgDir(gitRoot: string): string;
|
|
16
|
-
export declare function orgManifestExists(orgDir: string): boolean;
|
|
17
|
-
/** Read `org/resources.yaml` + scan `org/resources/<slug>/` into a payload. */
|
|
18
|
-
export declare function parseOrgResources(orgDir: string): OrgResourcesPayload;
|
|
19
|
-
/** Write `resources.yaml` (files stripped) + file trees + orphan-dir cleanup. */
|
|
20
|
-
export declare function writeOrgResources(orgDir: string, payload: OrgResourcesPayload): void;
|
|
21
|
-
/** Download binary files (download_url, no inline content) into `org/resources/<slug>/`. */
|
|
22
|
-
export declare function downloadOrgBinaryFiles(orgDir: string, payload: OrgResourcesPayload): Promise<void>;
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Org-as-code workspace — the org dir for the active layout (`wayai-ws/org/`,
|
|
3
|
-
* or the legacy root-level `org/` for un-migrated repos; see `layout.ts`).
|
|
4
|
-
*
|
|
5
|
-
* <orgDir>/
|
|
6
|
-
* resources.yaml # resource metadata (files stripped, like hub.yaml)
|
|
7
|
-
* resources/<slug>/... # file trees (SKILL.md, docs/…, binaries)
|
|
8
|
-
*
|
|
9
|
-
* Sits beside the hub folders under the same `wayai-ws/` root. One org per repo
|
|
10
|
-
* (org id comes from `.wayai.yaml`). Reuses the shared resource file-tree
|
|
11
|
-
* primitives so binary/hash/orphan rules match hub-as-code exactly.
|
|
12
|
-
*/
|
|
13
|
-
import * as fs from 'node:fs';
|
|
14
|
-
import * as path from 'node:path';
|
|
15
|
-
import * as yaml from 'js-yaml';
|
|
16
|
-
import { slugify } from './utils.js';
|
|
17
|
-
import { resolveLayout } from './layout.js';
|
|
18
|
-
import { scanResourceFiles, writeResourceFileTree, downloadBinaryFiles } from './resource-files.js';
|
|
19
|
-
import { YAML_DUMP_OPTIONS } from './yaml-writer.js';
|
|
20
|
-
export const ORG_MANIFEST_NAME = 'resources.yaml';
|
|
21
|
-
export function getOrgDir(gitRoot) {
|
|
22
|
-
return resolveLayout(gitRoot).orgDir;
|
|
23
|
-
}
|
|
24
|
-
export function orgManifestExists(orgDir) {
|
|
25
|
-
return fs.existsSync(path.join(orgDir, ORG_MANIFEST_NAME));
|
|
26
|
-
}
|
|
27
|
-
/** Read `org/resources.yaml` + scan `org/resources/<slug>/` into a payload. */
|
|
28
|
-
export function parseOrgResources(orgDir) {
|
|
29
|
-
const manifestPath = path.join(orgDir, ORG_MANIFEST_NAME);
|
|
30
|
-
let manifest = {};
|
|
31
|
-
if (fs.existsSync(manifestPath)) {
|
|
32
|
-
manifest = yaml.load(fs.readFileSync(manifestPath, 'utf-8')) ?? {};
|
|
33
|
-
}
|
|
34
|
-
const rawResources = Array.isArray(manifest.resources)
|
|
35
|
-
? manifest.resources
|
|
36
|
-
: [];
|
|
37
|
-
const resourcesDir = path.join(orgDir, 'resources');
|
|
38
|
-
const resources = rawResources.map((res) => {
|
|
39
|
-
const resource = { name: res.name };
|
|
40
|
-
if (res.id)
|
|
41
|
-
resource.id = res.id;
|
|
42
|
-
if (res.type)
|
|
43
|
-
resource.type = res.type;
|
|
44
|
-
if (res.description)
|
|
45
|
-
resource.description = res.description;
|
|
46
|
-
if (res.enabled === false)
|
|
47
|
-
resource.enabled = false;
|
|
48
|
-
if (res.user_browsable)
|
|
49
|
-
resource.user_browsable = res.user_browsable;
|
|
50
|
-
if (res.skill_name)
|
|
51
|
-
resource.skill_name = res.skill_name;
|
|
52
|
-
if (res.environment)
|
|
53
|
-
resource.environment = res.environment;
|
|
54
|
-
if (Array.isArray(res.tags))
|
|
55
|
-
resource.tags = res.tags;
|
|
56
|
-
if (Array.isArray(res.folders))
|
|
57
|
-
resource.folders = res.folders;
|
|
58
|
-
const resDir = path.join(resourcesDir, slugify(resource.name));
|
|
59
|
-
if (fs.existsSync(resDir)) {
|
|
60
|
-
const files = scanResourceFiles(resDir, '');
|
|
61
|
-
if (files.length > 0)
|
|
62
|
-
resource.files = files;
|
|
63
|
-
}
|
|
64
|
-
return resource;
|
|
65
|
-
});
|
|
66
|
-
return { version: 1, resources };
|
|
67
|
-
}
|
|
68
|
-
/** Write `resources.yaml` (files stripped) + file trees + orphan-dir cleanup. */
|
|
69
|
-
export function writeOrgResources(orgDir, payload) {
|
|
70
|
-
fs.mkdirSync(orgDir, { recursive: true });
|
|
71
|
-
const resources = payload.resources ?? [];
|
|
72
|
-
// Manifest carries metadata + folders; file content lives on disk.
|
|
73
|
-
const manifestResources = resources.map((r) => {
|
|
74
|
-
const { files: _files, ...rest } = r;
|
|
75
|
-
return rest;
|
|
76
|
-
});
|
|
77
|
-
fs.writeFileSync(path.join(orgDir, ORG_MANIFEST_NAME), yaml.dump({ version: 1, resources: manifestResources }, YAML_DUMP_OPTIONS), 'utf-8');
|
|
78
|
-
const resourcesDir = path.join(orgDir, 'resources');
|
|
79
|
-
const currentSlugs = new Set();
|
|
80
|
-
for (const resource of resources) {
|
|
81
|
-
const resSlug = slugify(resource.name);
|
|
82
|
-
currentSlugs.add(resSlug);
|
|
83
|
-
writeResourceFileTree(path.join(resourcesDir, resSlug), resource.files || []);
|
|
84
|
-
}
|
|
85
|
-
// Remove orphan resource directories.
|
|
86
|
-
if (fs.existsSync(resourcesDir)) {
|
|
87
|
-
for (const entry of fs.readdirSync(resourcesDir, { withFileTypes: true })) {
|
|
88
|
-
if (entry.isDirectory() && !currentSlugs.has(entry.name)) {
|
|
89
|
-
fs.rmSync(path.join(resourcesDir, entry.name), { recursive: true, force: true });
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/** Download binary files (download_url, no inline content) into `org/resources/<slug>/`. */
|
|
95
|
-
export async function downloadOrgBinaryFiles(orgDir, payload) {
|
|
96
|
-
let count = 0;
|
|
97
|
-
for (const resource of payload.resources ?? []) {
|
|
98
|
-
if (!resource.files)
|
|
99
|
-
continue;
|
|
100
|
-
const resDir = path.join(orgDir, 'resources', slugify(resource.name));
|
|
101
|
-
count += await downloadBinaryFiles(resDir, resource.files);
|
|
102
|
-
}
|
|
103
|
-
if (count > 0)
|
|
104
|
-
console.log(`Downloaded ${count} binary resource file(s).`);
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=org-workspace.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"org-workspace.js","sourceRoot":"","sources":["../../src/lib/org-workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACpG,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAElD,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,iBAAiB,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CAAC;IACH,CAAC;AACH,CAAC;AAED,4FAA4F;AAC5F,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,MAAc,EAAE,OAA4B;IACvF,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,SAAS,IAAI,EAAE,EAAE,CAAC;QAC/C,IAAI,CAAC,QAAQ,CAAC,KAAK;YAAE,SAAS;QAC9B,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QACtE,KAAK,IAAI,MAAM,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,KAAK,GAAG,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,2BAA2B,CAAC,CAAC;AAC7E,CAAC"}
|
package/dist/lib/parser.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parse hub.yaml + agents/<slug>.yaml + agents/*.md into HubAsCodePayload.
|
|
3
|
-
* Falls back to wayai.yaml for backward compatibility.
|
|
4
|
-
*/
|
|
5
|
-
import type { HubAsCodePayload } from './types.js';
|
|
6
|
-
/**
|
|
7
|
-
* Parse a hub folder into a HubAsCodePayload.
|
|
8
|
-
* Reads hub.yaml (or wayai.yaml for backward compat) and resolves agents from
|
|
9
|
-
* agents/<slug>.yaml files (or inline agents array for old format).
|
|
10
|
-
* Resolves agent instructions from companion .md files.
|
|
11
|
-
*/
|
|
12
|
-
export interface ParseHubFolderOptions {
|
|
13
|
-
/** When true, allow hub_id and hub_environment to be absent (for new hubs not yet created on platform). */
|
|
14
|
-
allowNewHub?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export declare function parseHubFolder(hubFolder: string, opts?: ParseHubFolderOptions): HubAsCodePayload;
|