@dreamlake/dreamlake-cli 0.98.0 → 0.100.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.
- package/dist/api/index.d.ts +212 -10
- package/dist/api/index.js +6 -0
- package/dist/api/native-experiments.d.ts +77 -0
- package/dist/api/native-experiments.js +31 -0
- package/dist/api/sessions.d.ts +240 -7
- package/dist/api/sessions.js +56 -1
- package/dist/api/skills.d.ts +122 -0
- package/dist/api/skills.js +220 -0
- package/dist/cli/experiments/index.js +2 -0
- package/dist/cli/experiments/native-commands.d.ts +13 -0
- package/dist/cli/experiments/native-commands.js +88 -0
- package/dist/cli/help-examples.generated.js +22 -5
- package/dist/cli/hosts/inventory.d.ts +28 -0
- package/dist/cli/hosts/inventory.js +68 -3
- package/dist/cli/hosts/picker.d.ts +34 -0
- package/dist/cli/hosts/picker.js +116 -0
- package/dist/cli/hosts/ssh.d.ts +16 -0
- package/dist/cli/hosts/ssh.js +47 -3
- package/dist/cli/index.js +2 -0
- package/dist/cli/session-affiliation.js +3 -2
- package/dist/cli/sessions/affiliation.d.ts +12 -1
- package/dist/cli/sessions/affiliation.js +37 -0
- package/dist/cli/sessions/control.d.ts +11 -0
- package/dist/cli/sessions/control.js +49 -4
- package/dist/cli/sessions/index.js +70 -17
- package/dist/cli/sessions/live.d.ts +85 -0
- package/dist/cli/sessions/live.js +258 -0
- package/dist/cli/sessions/runner/exec.d.ts +118 -6
- package/dist/cli/sessions/runner/exec.js +298 -47
- package/dist/cli/sessions/runner/native.js +4 -1
- package/dist/cli/sessions/runner/serve.d.ts +37 -2
- package/dist/cli/sessions/runner/serve.js +273 -28
- package/dist/cli/sessions/wrap.d.ts +63 -0
- package/dist/cli/sessions/wrap.js +226 -0
- package/dist/cli/skill/index.d.ts +19 -1
- package/dist/cli/skill/index.js +65 -12
- package/dist/cli/skill/read.d.ts +25 -0
- package/dist/cli/skill/read.js +65 -0
- package/dist/cli/skill/registry.d.ts +95 -0
- package/dist/cli/skill/registry.js +284 -0
- package/dist/cli/skill/reminders.js +2 -1
- package/dist/cli/version.d.ts +1 -1
- package/dist/cli/version.js +1 -1
- package/package.json +9 -9
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { randomUUID } from 'node:crypto';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { resolveHostNamespace } from '../hosts/inventory.js';
|
|
5
|
+
import { resolveRemote, resolveToken } from '../config.js';
|
|
6
|
+
import { ApiError, createClient, PERMISSION_LEVELS } from '../../api/index.js';
|
|
7
|
+
import { readConversationFile } from './conversation.js';
|
|
8
|
+
import { sessionEnvFilePath, writeSessionEnvFile } from './affiliation.js';
|
|
9
|
+
import { claudePermissionMode, codexSandbox, defaultRoots, findClaudeTranscript, listCodexRollouts, transcriptFacts, UUID } from './runner/native.js';
|
|
10
|
+
/** The provider's flags the wrapper owns — its identity, and everything that widens or narrows what the
|
|
11
|
+
* process may do, so the level DreamLake records is the level the process runs under. A user who passes one
|
|
12
|
+
* is told which wrapper flag to use instead. */
|
|
13
|
+
const LEVELS_HINT = 'use --permission read-only|workspace-write|full-access (the recorded level must be the level the process runs under)';
|
|
14
|
+
const RESERVED = {
|
|
15
|
+
claude: {
|
|
16
|
+
'--session-id': 'the wrapper mints the session id; use `dreamlake sessions resume` / `claude --resume` for an existing one',
|
|
17
|
+
'--permission-mode': LEVELS_HINT, '--dangerously-skip-permissions': LEVELS_HINT, '--permission-prompt-tool': LEVELS_HINT,
|
|
18
|
+
'--allowedTools': LEVELS_HINT, '--disallowedTools': LEVELS_HINT, '--allowed-tools': LEVELS_HINT, '--disallowed-tools': LEVELS_HINT,
|
|
19
|
+
},
|
|
20
|
+
codex: {
|
|
21
|
+
'--sandbox': LEVELS_HINT, '-s': LEVELS_HINT, '--ask-for-approval': LEVELS_HINT, '-a': LEVELS_HINT, '--full-auto': LEVELS_HINT, '--dangerously-bypass-approvals-and-sandbox': LEVELS_HINT,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
/** Codex `-c key=value` / `--config key=value` overrides that move the sandbox or approval policy. */
|
|
25
|
+
const RESERVED_CODEX_CONFIG = /^(sandbox_mode|approval_policy|sandbox_[a-z_]+(\.[a-z_]+)*)\s*=/;
|
|
26
|
+
export function providerArgv(provider, level, rest, input) {
|
|
27
|
+
const literal = rest.indexOf('--'), inspected = literal >= 0 ? rest.slice(0, literal) : rest;
|
|
28
|
+
for (let i = 0; i < inspected.length; i++) {
|
|
29
|
+
const arg = inspected[i], key = arg.split('=')[0];
|
|
30
|
+
if (RESERVED[provider][key])
|
|
31
|
+
throw new Error(`${key} belongs to the wrapper: ${RESERVED[provider][key]}`);
|
|
32
|
+
if (provider === 'codex' && (key === '-c' || key === '--config')) {
|
|
33
|
+
const value = arg.includes('=') ? arg.slice(key.length + 1) : inspected[i + 1] ?? '';
|
|
34
|
+
if (RESERVED_CODEX_CONFIG.test(value.trim()))
|
|
35
|
+
throw new Error(`${key} ${value.split('=')[0].trim()} belongs to the wrapper: ${LEVELS_HINT}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (provider === 'claude')
|
|
39
|
+
return ['--session-id', input.nativeSessionId, '--permission-mode', claudePermissionMode(level), ...rest];
|
|
40
|
+
return ['-C', input.cwd, '--sandbox', codexSandbox(level), ...rest];
|
|
41
|
+
}
|
|
42
|
+
export const needLevel = (value) => {
|
|
43
|
+
const level = value ?? 'workspace-write';
|
|
44
|
+
if (!PERMISSION_LEVELS.includes(String(level)))
|
|
45
|
+
throw new Error('--permission must be read-only, workspace-write or full-access');
|
|
46
|
+
return level;
|
|
47
|
+
};
|
|
48
|
+
/** The one Codex rollout this launch produced: created in this directory at or after the moment the
|
|
49
|
+
* launch began — a rollout from before it, however recent, is another session's. Two candidates mean
|
|
50
|
+
* another Codex started here meanwhile; nothing is guessed then. */
|
|
51
|
+
export function discoverCodexRollout(roots, cwd, since) {
|
|
52
|
+
const found = [];
|
|
53
|
+
for (const path of listCodexRollouts(roots.codex, since)) {
|
|
54
|
+
let facts;
|
|
55
|
+
try {
|
|
56
|
+
facts = transcriptFacts('codex', path);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (facts.cwd !== cwd || !facts.nativeSessionId || !UUID.test(facts.nativeSessionId) || facts.createdAt === null || facts.createdAt < since)
|
|
62
|
+
continue;
|
|
63
|
+
found.push({ path, nativeSessionId: facts.nativeSessionId.toLowerCase(), createdAt: facts.createdAt ?? 0 });
|
|
64
|
+
}
|
|
65
|
+
if (!found.length)
|
|
66
|
+
return null;
|
|
67
|
+
if (found.length > 1)
|
|
68
|
+
return { ambiguous: found.map(f => f.nativeSessionId) };
|
|
69
|
+
return { path: found[0].path, nativeSessionId: found[0].nativeSessionId };
|
|
70
|
+
}
|
|
71
|
+
/** The provider child's environment: the wrapper's own saved-session pair when it is known (Claude), and
|
|
72
|
+
* never an inherited one — a `dreamlake claude` started from a shell that sourced another session's env
|
|
73
|
+
* file, or from inside another agent session, must not link the child's writes to that parent. Inherited
|
|
74
|
+
* provider identities go too: the child sets its own (`CLAUDE_CODE_SESSION_ID`, `CODEX_THREAD_ID`), and a
|
|
75
|
+
* stale one from a parent agent would make the child's writes ambiguous or misattributed. */
|
|
76
|
+
export function childEnv(base, pair) {
|
|
77
|
+
const { DREAMLAKE_TERMINAL_SESSION_ID: _id, DREAMLAKE_SESSION_NAMESPACE: _ns, CLAUDE_CODE_SESSION_ID: _cc, CLAUDE_SESSION_ID: _cs, CODEX_THREAD_ID: _ct, ...env } = base;
|
|
78
|
+
return pair ? { ...env, DREAMLAKE_TERMINAL_SESSION_ID: pair.id, DREAMLAKE_SESSION_NAMESPACE: pair.namespace } : env;
|
|
79
|
+
}
|
|
80
|
+
const sessionNamespace = (session, fallback) => { const slug = session.namespaceSlug; return typeof slug === 'string' && /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(slug) ? slug : fallback; };
|
|
81
|
+
/** Run the provider under DreamLake. Registration failures before the launch are fatal (nothing ran);
|
|
82
|
+
* every DreamLake call after the provider started is best effort and reported, never the exit code. */
|
|
83
|
+
export async function wrap(provider, opts, rest, deps) {
|
|
84
|
+
const level = needLevel(opts.permission), spawnChild = deps.spawn ?? ((command, args, env) => spawn(command, args, { stdio: 'inherit', env }));
|
|
85
|
+
if (opts.visibility !== undefined && !['public', 'private'].includes(opts.visibility))
|
|
86
|
+
throw new Error('--visibility must be public or private');
|
|
87
|
+
if (opts.name !== undefined && (!opts.name.trim() || opts.name.length > 128 || /[\x00-\x1f\x7f]/.test(opts.name)))
|
|
88
|
+
throw new Error('--name must contain 1–128 printable characters');
|
|
89
|
+
const api = deps.client.sessions(deps.namespace), visibility = (opts.visibility ?? 'private');
|
|
90
|
+
const register = async (nativeSessionId) => {
|
|
91
|
+
const { session } = await api.register({ provider, nativeSessionId, cwd: deps.cwd, ...(opts.name ? { name: opts.name } : {}), visibility });
|
|
92
|
+
if (!/^[a-f0-9]{24}$/.test(session.id) || String(session.codexSessionId).toLowerCase() !== nativeSessionId)
|
|
93
|
+
throw new Error('Invalid registration receipt');
|
|
94
|
+
const ns = sessionNamespace(session, deps.namespace);
|
|
95
|
+
let envFile = null;
|
|
96
|
+
// Before a Claude launch the env file is what links the session's writes, so its failure is fatal there;
|
|
97
|
+
// after a Codex run it is a convenience for later shells and only costs a warning.
|
|
98
|
+
try {
|
|
99
|
+
envFile = writeSessionEnvFile(sessionEnvFilePath(nativeSessionId, deps.home), { id: session.id, namespace: ns });
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
if (provider === 'claude')
|
|
103
|
+
throw error;
|
|
104
|
+
deps.log(`env file not written (${error instanceof Error ? error.message : String(error)}); later shells can use: export DREAMLAKE_TERMINAL_SESSION_ID=${session.id} DREAMLAKE_SESSION_NAMESPACE=${ns}`);
|
|
105
|
+
}
|
|
106
|
+
return { session, ns, envFile };
|
|
107
|
+
};
|
|
108
|
+
const beat = async (ns, sessionId, liveState) => { try {
|
|
109
|
+
await deps.client.sessions(ns).heartbeat(sessionId, { liveState, at: new Date().toISOString() });
|
|
110
|
+
}
|
|
111
|
+
catch { /* best effort; the hooks and the runner report too */ } };
|
|
112
|
+
const upload = async (ns, sessionId, nativeSessionId, path) => {
|
|
113
|
+
if (opts.upload === false)
|
|
114
|
+
return false;
|
|
115
|
+
if (!path) {
|
|
116
|
+
deps.log(`transcript of ${nativeSessionId} not found under ${provider === 'claude' ? deps.roots.claude : deps.roots.codex}; upload it later with: dreamlake sessions upload-conversation ${sessionId} --namespace ${ns} --file <path>`);
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
const conversation = await readConversationFile(path, provider, nativeSessionId);
|
|
121
|
+
const current = await deps.client.sessions(ns).conversation(sessionId);
|
|
122
|
+
const receipt = await deps.client.sessions(ns).uploadConversation(sessionId, conversation, current.revision);
|
|
123
|
+
deps.log(`transcript uploaded: ${receipt.messageCount} messages (revision ${receipt.revision.slice(0, 12)}…)`);
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
deps.log(`transcript not uploaded (${error instanceof ApiError ? error.code : error instanceof Error ? error.message : String(error)}); retry with: dreamlake sessions upload-conversation ${sessionId} --namespace ${ns} --file "${path}"`);
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
// Registration records no permission level (the route takes none), and a runner refuses a turn for a
|
|
132
|
+
// session without one — `--permission` on `send` does not help. The accurate path is one restart that
|
|
133
|
+
// records the level (a raise from "unrecorded": the person confirms on a terminal, the runner must allow
|
|
134
|
+
// it), then plain sends.
|
|
135
|
+
const recipe = (ns, sessionId) => `to message it from anywhere (needs \`dreamlake sessions serve --max-human-permission ${level}\` on this machine; the level is recorded once, on a terminal):\n dreamlake sessions control restart ${sessionId} --permission ${level} --raise --namespace ${ns}\n dreamlake sessions control send ${sessionId} "…" --namespace ${ns}`;
|
|
136
|
+
const run = (args, env) => new Promise((resolve, reject) => {
|
|
137
|
+
const child = spawnChild(provider, args, env);
|
|
138
|
+
// Ctrl-C belongs to the provider: the wrapper stays alive to upload the transcript after it exits.
|
|
139
|
+
const ignore = () => undefined, forward = () => { child.kill('SIGTERM'); };
|
|
140
|
+
process.on('SIGINT', ignore);
|
|
141
|
+
process.on('SIGTERM', forward);
|
|
142
|
+
child.once('error', error => { process.off('SIGINT', ignore); process.off('SIGTERM', forward); reject(error); });
|
|
143
|
+
child.once('exit', (code, signal) => { process.off('SIGINT', ignore); process.off('SIGTERM', forward); resolve(code ?? (signal ? 128 + (signal === 'SIGINT' ? 2 : signal === 'SIGTERM' ? 15 : 1) : 1)); });
|
|
144
|
+
});
|
|
145
|
+
const launchError = (error) => { const e = error; return e?.code === 'ENOENT' ? new Error(`${provider} is not installed or not on PATH`) : error; };
|
|
146
|
+
if (provider === 'claude') {
|
|
147
|
+
const nativeSessionId = randomUUID();
|
|
148
|
+
const { session, ns, envFile } = await register(nativeSessionId);
|
|
149
|
+
deps.log(`DreamLake session ${session.id} (@${ns}, ${visibility}, ${level}); ${recipe(ns, session.id)}`);
|
|
150
|
+
await beat(ns, session.id, 'starting');
|
|
151
|
+
const env = childEnv(deps.env ?? process.env, { id: session.id, namespace: ns });
|
|
152
|
+
let exitCode;
|
|
153
|
+
try {
|
|
154
|
+
exitCode = await run(providerArgv('claude', level, rest, { nativeSessionId, cwd: deps.cwd }), env);
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
throw launchError(error);
|
|
158
|
+
}
|
|
159
|
+
await beat(ns, session.id, 'stopped');
|
|
160
|
+
const uploaded = await upload(ns, session.id, nativeSessionId, findClaudeTranscript(deps.roots.claude, nativeSessionId));
|
|
161
|
+
return { exitCode, sessionId: session.id, nativeSessionId, uploaded, envFile };
|
|
162
|
+
}
|
|
163
|
+
// Codex has no --session-id: it names the thread only in its own rollout file. Run first, then adopt
|
|
164
|
+
// the one rollout this launch created here. Inside the session, `dreamlake` calls link through the
|
|
165
|
+
// CODEX_THREAD_ID Codex sets — and through nothing inherited, so a parent session's pair never claims the
|
|
166
|
+
// child's writes; the saved-session pair is written for later shells once the thread is known.
|
|
167
|
+
const since = (deps.now ?? Date.now)(), args = providerArgv('codex', level, rest, { cwd: deps.cwd });
|
|
168
|
+
let exitCode;
|
|
169
|
+
try {
|
|
170
|
+
exitCode = await run(args, childEnv(deps.env ?? process.env));
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
throw launchError(error);
|
|
174
|
+
}
|
|
175
|
+
const rollout = discoverCodexRollout(deps.roots, deps.cwd, since);
|
|
176
|
+
if (!rollout) {
|
|
177
|
+
deps.log(`no rollout created: no Codex rollout for ${deps.cwd} was created under ${deps.roots.codex} after the launch; nothing was registered. Register the thread by hand: dreamlake sessions register --provider codex --session <thread-id> --cwd "${deps.cwd}"`);
|
|
178
|
+
return { exitCode, sessionId: null, nativeSessionId: null, uploaded: false, envFile: null };
|
|
179
|
+
}
|
|
180
|
+
if ('ambiguous' in rollout) {
|
|
181
|
+
deps.log(`several Codex threads started here meanwhile (${rollout.ambiguous.join(', ')}); register the right one by hand: dreamlake sessions register --provider codex --session <thread-id> --cwd "${deps.cwd}"`);
|
|
182
|
+
return { exitCode, sessionId: null, nativeSessionId: null, uploaded: false, envFile: null };
|
|
183
|
+
}
|
|
184
|
+
// The provider has already run: from here on nothing may change its exit code. A refused registration
|
|
185
|
+
// or an unwritable env file is one line on stderr with the command that repairs it.
|
|
186
|
+
let registered;
|
|
187
|
+
try {
|
|
188
|
+
registered = await register(rollout.nativeSessionId);
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
deps.log(`session not registered (${error instanceof ApiError ? error.code : error instanceof Error ? error.message : String(error)}); register the thread by hand: dreamlake sessions register --provider codex --session ${rollout.nativeSessionId} --cwd "${deps.cwd}" --write-env "${sessionEnvFilePath(rollout.nativeSessionId, deps.home)}"`);
|
|
192
|
+
return { exitCode, sessionId: null, nativeSessionId: rollout.nativeSessionId, uploaded: false, envFile: null };
|
|
193
|
+
}
|
|
194
|
+
const { session, ns, envFile } = registered;
|
|
195
|
+
deps.log(`DreamLake session ${session.id} (@${ns}, ${visibility}, ${level}); ${recipe(ns, session.id)}`);
|
|
196
|
+
await beat(ns, session.id, 'stopped');
|
|
197
|
+
const uploaded = await upload(ns, session.id, rollout.nativeSessionId, rollout.path);
|
|
198
|
+
return { exitCode, sessionId: session.id, nativeSessionId: rollout.nativeSessionId, uploaded, envFile };
|
|
199
|
+
}
|
|
200
|
+
function client() {
|
|
201
|
+
const token = resolveToken();
|
|
202
|
+
if (!token)
|
|
203
|
+
throw new Error('Log in to DreamLake before starting a session under it');
|
|
204
|
+
return createClient({ remote: resolveRemote(), token });
|
|
205
|
+
}
|
|
206
|
+
export function registerAgentWrappers(program) {
|
|
207
|
+
for (const provider of ['claude', 'codex']) {
|
|
208
|
+
program.command(provider).description(`start ${provider === 'claude' ? 'Claude Code' : 'Codex'} under DreamLake: register the session, link its writes, map --permission onto ${provider === 'claude' ? '--permission-mode' : '--sandbox'}, upload the transcript on exit; every other argument goes to ${provider} unchanged`)
|
|
209
|
+
.argument('[args...]', `arguments for ${provider}`)
|
|
210
|
+
.option('--permission <level>', `read-only, workspace-write or full-access → ${provider === 'claude' ? 'plan / acceptEdits / bypassPermissions' : 'read-only / workspace-write / danger-full-access'}`, 'workspace-write')
|
|
211
|
+
.option('--name <name>', 'saved session name').option('--namespace <namespace>', 'personal namespace (default: signed-in personal namespace)').option('--visibility <visibility>', 'private (default) or public')
|
|
212
|
+
.option('--no-upload', 'do not upload the transcript when the provider exits')
|
|
213
|
+
.allowUnknownOption().allowExcessArguments()
|
|
214
|
+
.action(async (_args, opts, command) => {
|
|
215
|
+
try {
|
|
216
|
+
const home = homedir(), namespace = await resolveHostNamespace(opts.namespace);
|
|
217
|
+
const result = await wrap(provider, opts, command.args, { client: client(), namespace, roots: defaultRoots(home), cwd: process.cwd(), home, log: line => console.error(line) });
|
|
218
|
+
process.exitCode = result.exitCode;
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
console.error(error instanceof ApiError ? `(${error.status}) ${error.code}` : error instanceof Error ? error.message : String(error));
|
|
222
|
+
process.exitCode = 1;
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
@@ -3,8 +3,11 @@ import { type SkillCatalog, type SkillPayload } from "./catalog.js";
|
|
|
3
3
|
import { type OwnedDir } from "./files.js";
|
|
4
4
|
import { type SkillAgent, type SkillManifest, type SkillScope, type SkillSourceKind } from "./manifest.js";
|
|
5
5
|
import { type SkillPreferences } from "./prefs.js";
|
|
6
|
+
import { type RegistrySource } from "./registry.js";
|
|
6
7
|
export { listBundledSkills, resolveBundleDir } from "./catalog.js";
|
|
7
8
|
export type { SkillAgent, SkillScope } from "./manifest.js";
|
|
9
|
+
export { runSkillRead, type SkillReadOptions, type SkillReadOutput, type SkillReadResultJson } from "./read.js";
|
|
10
|
+
export type { RegistrySource } from "./registry.js";
|
|
8
11
|
/** What happens next. `null` means "done, stop". */
|
|
9
12
|
export type SkillNextAction = {
|
|
10
13
|
kind: "run";
|
|
@@ -156,9 +159,18 @@ export interface SkillListResult {
|
|
|
156
159
|
/** The embedded bundle's location, or null when this build carries none. */
|
|
157
160
|
source?: string | null;
|
|
158
161
|
agent?: SkillAgent;
|
|
162
|
+
/** Where the catalog rows came from. `remote` is the server's /skills registry; `unreachable` says why a default remote fell back. */
|
|
159
163
|
catalog?: {
|
|
160
164
|
version: string | null;
|
|
161
|
-
origin: "embedded" | "none";
|
|
165
|
+
origin: "embedded" | "remote" | "none";
|
|
166
|
+
unreachable?: string;
|
|
167
|
+
};
|
|
168
|
+
/** The pin that answered: this CLI's embedded manifest, or the server's skills.lock. `mismatch` is the one-line warning when the two differ. */
|
|
169
|
+
registry?: {
|
|
170
|
+
source: RegistrySource;
|
|
171
|
+
tag: string | null;
|
|
172
|
+
commit: string | null;
|
|
173
|
+
mismatch?: string;
|
|
162
174
|
};
|
|
163
175
|
/** Present with `--refresh`. */
|
|
164
176
|
latest?: {
|
|
@@ -201,6 +213,10 @@ export interface SkillMultiListResult extends Omit<SkillListResult, "agent" | "s
|
|
|
201
213
|
export interface SkillListOptions {
|
|
202
214
|
agent?: string;
|
|
203
215
|
refresh?: boolean;
|
|
216
|
+
/** Catalog rows from the embedded snapshot, offline. */
|
|
217
|
+
local?: boolean;
|
|
218
|
+
/** Catalog rows from the server's /skills registry (needs a login). */
|
|
219
|
+
remote?: boolean;
|
|
204
220
|
json?: boolean;
|
|
205
221
|
}
|
|
206
222
|
export declare function isSkillName(name: unknown): name is string;
|
|
@@ -279,6 +295,8 @@ export declare function runSkillRemove(name: string, opts: SkillInstallOptions):
|
|
|
279
295
|
export interface ListEntriesOptions {
|
|
280
296
|
/** A freshly fetched catalog (`--refresh`), consulted for `latest` first. */
|
|
281
297
|
latest?: SkillCatalog | null;
|
|
298
|
+
/** The server registry's catalog: its rows and version replace the embedded snapshot's. */
|
|
299
|
+
registry?: SkillCatalog | null;
|
|
282
300
|
/** Hash every manifest file to tell `installed` from `modified`. Off for startup reminders. */
|
|
283
301
|
verify?: boolean;
|
|
284
302
|
/** Project root; defaults to cwd. */
|
package/dist/cli/skill/index.js
CHANGED
|
@@ -58,7 +58,10 @@ import { EMBEDDED_SKILL, ReleaseError, SKILLS_ENV, catalogFileCount, catalogUrl,
|
|
|
58
58
|
import { hashFile, hasSymlinkAncestor, isDirectChild, kindOf, listDir, pinOwnedDir, pruneEmptyDirs, resolveExisting, sha256, unlinkOwnedFile, writeOwnedFile, } from "./files.js";
|
|
59
59
|
import { AGENTS, MANIFEST_FILE, parseAgents, readManifest, writeManifest, } from "./manifest.js";
|
|
60
60
|
import { preferredAgents, readSkillPreferences, skillPreferences, writeSkillPreferences, } from "./prefs.js";
|
|
61
|
+
import { runSkillRead } from "./read.js";
|
|
62
|
+
import { chooseSource, describeVersion, listFrom, localVersion, RegistryError, } from "./registry.js";
|
|
61
63
|
export { listBundledSkills, resolveBundleDir } from "./catalog.js";
|
|
64
|
+
export { runSkillRead } from "./read.js";
|
|
62
65
|
// ─── names ───────────────────────────────────────────────────────────────────
|
|
63
66
|
//
|
|
64
67
|
// A skill name is a directory name under a shared skills directory, so it is
|
|
@@ -1105,6 +1108,7 @@ function scopeState(target, verify) {
|
|
|
1105
1108
|
export function installedSkillEntries(agent, options = {}) {
|
|
1106
1109
|
const bundleDir = resolveBundleDir();
|
|
1107
1110
|
const snapshot = snapshotCatalog(bundleDir);
|
|
1111
|
+
const registry = options.registry ?? null;
|
|
1108
1112
|
const bundled = bundleDir ? listBundledSkills(bundleDir) : [];
|
|
1109
1113
|
const embeddedVer = bundleDir ? embeddedVersion(bundleDir) : null;
|
|
1110
1114
|
const latest = options.latest ?? null;
|
|
@@ -1112,16 +1116,17 @@ export function installedSkillEntries(agent, options = {}) {
|
|
|
1112
1116
|
const projectDir = skillsDir(options.cwd ?? process.cwd(), agent);
|
|
1113
1117
|
const globalDir = skillsDir(os.homedir(), agent);
|
|
1114
1118
|
const names = [...new Set([
|
|
1115
|
-
...Object.keys(snapshot?.skills ?? {}),
|
|
1119
|
+
...Object.keys((registry ?? snapshot)?.skills ?? {}),
|
|
1116
1120
|
...bundled,
|
|
1117
1121
|
...Object.keys(latest?.skills ?? {}),
|
|
1118
1122
|
])].filter(isSkillName).sort();
|
|
1119
1123
|
return names.map((name) => {
|
|
1120
|
-
const entry = latest?.skills[name] ?? snapshot?.skills[name];
|
|
1124
|
+
const entry = latest?.skills[name] ?? registry?.skills[name] ?? snapshot?.skills[name];
|
|
1121
1125
|
const embedded = bundled.includes(name);
|
|
1122
1126
|
const latestVersion = latest?.skills[name] ? latest.version
|
|
1123
|
-
:
|
|
1124
|
-
:
|
|
1127
|
+
: registry?.skills[name] ? registry.version
|
|
1128
|
+
: embedded && embeddedVer ? embeddedVer
|
|
1129
|
+
: snapshot?.skills[name] ? snapshot.version : null;
|
|
1125
1130
|
return {
|
|
1126
1131
|
name,
|
|
1127
1132
|
description: entry?.description ?? "",
|
|
@@ -1138,15 +1143,43 @@ export async function runSkillList(opts) {
|
|
|
1138
1143
|
const sel = selectTarget(opts);
|
|
1139
1144
|
if ("error" in sel)
|
|
1140
1145
|
return reject(opts, sel.error, "invalid-agent");
|
|
1146
|
+
const chosen = chooseSource(opts);
|
|
1147
|
+
if (chosen instanceof RegistryError) {
|
|
1148
|
+
return reject(opts, chosen.message, chosen.kind, chosen.kind === "not-logged-in" ? { kind: "run", command: "dreamlake login" } : null);
|
|
1149
|
+
}
|
|
1141
1150
|
const bundleDir = resolveBundleDir();
|
|
1142
1151
|
if (process.env[SKILLS_ENV] && !bundleDir) {
|
|
1143
1152
|
return reject(opts, `${SKILLS_ENV}=${process.env[SKILLS_ENV]} is not a directory`, "no-bundle");
|
|
1144
1153
|
}
|
|
1145
1154
|
const snapshot = snapshotCatalog(bundleDir);
|
|
1146
|
-
|
|
1147
|
-
|
|
1155
|
+
// The catalog rows: the server's pinned bundle when the source is remote,
|
|
1156
|
+
// else the embedded snapshot. A default remote that cannot answer falls back
|
|
1157
|
+
// to the snapshot and says so; the pin that answered is always reported.
|
|
1158
|
+
let remote = null;
|
|
1159
|
+
let mismatch = null;
|
|
1160
|
+
let fellBack = null;
|
|
1161
|
+
if (chosen.source === "remote") {
|
|
1162
|
+
try {
|
|
1163
|
+
const answer = await listFrom(chosen);
|
|
1164
|
+
if (answer.result.source === "remote")
|
|
1165
|
+
remote = answer.result;
|
|
1166
|
+
({ mismatch, fellBack } = answer);
|
|
1167
|
+
}
|
|
1168
|
+
catch (err) {
|
|
1169
|
+
return reject(opts, err.message, err instanceof RegistryError ? err.kind : "read-failed");
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
if (!remote && !bundleDir && !snapshot) {
|
|
1173
|
+
return reject(opts, `no bundled skills found — this build ships none. Point ${SKILLS_ENV} at a skills/ directory to install from a checkout${chosen.source === "local" && !chosen.explicit ? ", or log in to read the server registry" : ""}.`, "no-bundle");
|
|
1148
1174
|
}
|
|
1149
1175
|
printHint(sel, opts);
|
|
1176
|
+
if (fellBack)
|
|
1177
|
+
process.stderr.write(`⚠ ${fellBack}; showing the embedded catalog snapshot instead\n`);
|
|
1178
|
+
if (mismatch)
|
|
1179
|
+
process.stderr.write(`⚠ ${mismatch}\n`);
|
|
1180
|
+
const registryInfo = remote
|
|
1181
|
+
? { source: "remote", tag: remote.version.tag, commit: remote.version.commit, ...(mismatch ? { mismatch } : {}) }
|
|
1182
|
+
: { source: "local", ...localVersion(bundleDir) };
|
|
1150
1183
|
let latest;
|
|
1151
1184
|
let refreshed = null;
|
|
1152
1185
|
if (opts.refresh) {
|
|
@@ -1166,12 +1199,14 @@ export async function runSkillList(opts) {
|
|
|
1166
1199
|
blocked: "blocked (not a directory)",
|
|
1167
1200
|
unmanaged: "unmanaged (no manifest)",
|
|
1168
1201
|
})[s.state];
|
|
1202
|
+
const snapshotLine = snapshot ? `${fmtVersion(snapshot.version)} (embedded snapshot)` : "none";
|
|
1169
1203
|
const printHeader = () => {
|
|
1170
1204
|
process.stdout.write(`skill list\n`);
|
|
1171
1205
|
header([
|
|
1172
1206
|
agentsLabel(sel),
|
|
1173
1207
|
["source", bundleDir ?? "none"],
|
|
1174
|
-
["
|
|
1208
|
+
["registry", `${registryInfo.source} ${describeVersion(registryInfo)}`],
|
|
1209
|
+
["catalog", remote ? `${fmtVersion(remote.version.tag)} (server registry)` : fellBack ? `${snapshotLine} — registry unreachable: ${fellBack}` : snapshotLine],
|
|
1175
1210
|
...(latest ? [["latest", "version" in latest ? `${fmtVersion(latest.version)} (release)` : `unreachable — ${latest.error}`]] : []),
|
|
1176
1211
|
]);
|
|
1177
1212
|
if (latest && "error" in latest)
|
|
@@ -1179,10 +1214,13 @@ export async function runSkillList(opts) {
|
|
|
1179
1214
|
};
|
|
1180
1215
|
const meta = (e) => [e.latest ? fmtVersion(e.latest) : "", e.files !== null ? `${e.files} files` : "", e.embedded ? "embedded" : ""]
|
|
1181
1216
|
.filter(Boolean).join(" ");
|
|
1182
|
-
const catalogInfo =
|
|
1217
|
+
const catalogInfo = remote
|
|
1218
|
+
? { version: remote.version.tag, origin: "remote" }
|
|
1219
|
+
: { version: snapshot?.version ?? null, origin: snapshot ? "embedded" : "none", ...(fellBack ? { unreachable: fellBack } : {}) };
|
|
1220
|
+
const rows = (agent) => installedSkillEntries(agent, { latest: refreshed, registry: remote?.catalog ?? null });
|
|
1183
1221
|
if (isMulti(sel)) {
|
|
1184
1222
|
// Rows are the same for every agent; only the installed state differs.
|
|
1185
|
-
const perAgent = sel.agents.map((agent) => ({ agent, entries:
|
|
1223
|
+
const perAgent = sel.agents.map((agent) => ({ agent, entries: rows(agent) }));
|
|
1186
1224
|
const entries = perAgent[0].entries.map(({ project: _p, global: _g, ...row }) => ({
|
|
1187
1225
|
...row,
|
|
1188
1226
|
installs: Object.fromEntries(perAgent.map(({ agent, entries: rows }) => {
|
|
@@ -1194,7 +1232,7 @@ export async function runSkillList(opts) {
|
|
|
1194
1232
|
const pending = entries.find((e) => Object.values(e.installs).some((i) => !present(i.project) && !present(i.global)));
|
|
1195
1233
|
const nextAction = pending ? { kind: "run", command: installCommand(pending.name, opts, false) } : null;
|
|
1196
1234
|
const result = {
|
|
1197
|
-
status: "ok", source: bundleDir, agents: sel.agents, catalog: catalogInfo, ...(latest ? { latest } : {}), skills: entries, nextAction,
|
|
1235
|
+
status: "ok", source: bundleDir, agents: sel.agents, catalog: catalogInfo, registry: registryInfo, ...(latest ? { latest } : {}), skills: entries, nextAction,
|
|
1198
1236
|
};
|
|
1199
1237
|
if (opts.json) {
|
|
1200
1238
|
emitJson(result);
|
|
@@ -1222,7 +1260,7 @@ export async function runSkillList(opts) {
|
|
|
1222
1260
|
process.stdout.write(`\n next: ${nextAction.command}\n`);
|
|
1223
1261
|
return 0;
|
|
1224
1262
|
}
|
|
1225
|
-
const entries =
|
|
1263
|
+
const entries = rows(sel.agents[0]);
|
|
1226
1264
|
// One next action, and only when there is something to do. A skill with a
|
|
1227
1265
|
// manifest at either scope is present, even if edited; `update` handles it.
|
|
1228
1266
|
const pending = entries.find((e) => !present(e.project) && !present(e.global));
|
|
@@ -1234,6 +1272,7 @@ export async function runSkillList(opts) {
|
|
|
1234
1272
|
source: bundleDir,
|
|
1235
1273
|
agent: sel.agents[0],
|
|
1236
1274
|
catalog: catalogInfo,
|
|
1275
|
+
registry: registryInfo,
|
|
1237
1276
|
...(latest ? { latest } : {}),
|
|
1238
1277
|
skills: entries,
|
|
1239
1278
|
nextAction,
|
|
@@ -1336,14 +1375,26 @@ export function registerSkillCommand(program) {
|
|
|
1336
1375
|
process.exitCode = await runSkillInit(opts);
|
|
1337
1376
|
});
|
|
1338
1377
|
const skill = program.command("skill")
|
|
1339
|
-
.description("install, update, remove and
|
|
1378
|
+
.description("install, update, remove, list and read agent skills from the dreamlake-skills release")
|
|
1340
1379
|
.addHelpText("after", `
|
|
1341
1380
|
Claude Code uses .claude/skills/; Codex uses .agents/skills/. --agent all installs into both, one copy each.
|
|
1342
1381
|
'dreamlake init' saves the default agent(s) and scope; --agent, --global, --project and --dir override it.
|
|
1343
1382
|
install and update download from the public release; dreamlake-cli is embedded and installs offline.
|
|
1344
1383
|
Every install writes <skill>/.dreamlake-skill.json; update and remove touch only files it lists.
|
|
1345
1384
|
remove never deletes a file you edited: it is kept and reported.
|
|
1385
|
+
list and read answer from the server's skills registry when you are logged in, else from the embedded
|
|
1386
|
+
bundle; --remote and --local choose explicitly. Every answer names its source and the bundle's tag and commit.
|
|
1346
1387
|
`);
|
|
1388
|
+
skill.command("read")
|
|
1389
|
+
.description("print one file of a skill — SKILL.md by default — from the server registry or the embedded bundle")
|
|
1390
|
+
.argument("<name>", "skill name, e.g. dreamlake-notes")
|
|
1391
|
+
.option("--file <path>", "a path inside the skill, like actions/read.md (default: SKILL.md)")
|
|
1392
|
+
.option("--local", "read the bundle embedded in this CLI, offline")
|
|
1393
|
+
.option("--remote", "read the server's skills registry (needs a login)")
|
|
1394
|
+
.option("--json", "emit one object: the agent tool's dreamlake_skills_read fields plus source")
|
|
1395
|
+
.action(async (name, opts) => {
|
|
1396
|
+
process.exitCode = await runSkillRead(name, opts);
|
|
1397
|
+
});
|
|
1347
1398
|
installationOptions(skill.command("install")
|
|
1348
1399
|
.description("install skills (and what they require) from the release; embedded dreamlake-cli when current")
|
|
1349
1400
|
.argument("[names...]", "skill names; omit to install the embedded dreamlake-cli"))
|
|
@@ -1367,6 +1418,8 @@ remove never deletes a file you edited: it is kept and reported.
|
|
|
1367
1418
|
.description("show the catalog with project/global installation status")
|
|
1368
1419
|
.option("--agent <agent>", "target agent: claude, codex, all, or a comma list (default: what dreamlake init saved, else claude)")
|
|
1369
1420
|
.option("--refresh", "fetch the latest catalog from the release and show it next to the installed versions")
|
|
1421
|
+
.option("--local", "rows from the catalog snapshot embedded in this CLI, offline")
|
|
1422
|
+
.option("--remote", "rows from the server's skills registry (needs a login)")
|
|
1370
1423
|
.option("--json", "emit one result object")
|
|
1371
1424
|
.action(async (opts) => {
|
|
1372
1425
|
process.exitCode = await runSkillList(opts);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { SkillsErrorCode } from "../../api/skills.js";
|
|
2
|
+
import type { SkillNextAction } from "./index.js";
|
|
3
|
+
import { type RegistryRead, type RegistrySource, type SourceOptions } from "./registry.js";
|
|
4
|
+
export interface SkillReadOptions extends SourceOptions {
|
|
5
|
+
/** A path inside the skill; `SKILL.md` when omitted. */
|
|
6
|
+
file?: string;
|
|
7
|
+
json?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** `skill read --json`: the agent tool's fields (minus paging) with `source`. */
|
|
10
|
+
export interface SkillReadOutput extends RegistryRead {
|
|
11
|
+
status: "ok";
|
|
12
|
+
nextAction: null;
|
|
13
|
+
}
|
|
14
|
+
export interface SkillReadFailure {
|
|
15
|
+
status: "error";
|
|
16
|
+
error: string;
|
|
17
|
+
kind: string;
|
|
18
|
+
/** The server's error code, when the refusal is one the registry defines. */
|
|
19
|
+
code?: SkillsErrorCode;
|
|
20
|
+
nextAction: SkillNextAction;
|
|
21
|
+
}
|
|
22
|
+
export type SkillReadResultJson = SkillReadOutput | SkillReadFailure;
|
|
23
|
+
export declare function readHeader(result: RegistryRead): string;
|
|
24
|
+
export declare function runSkillRead(name: string, opts: SkillReadOptions): Promise<number>;
|
|
25
|
+
export type { RegistrySource };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// `dreamlake skill read <name> [--file <path>] [--local|--remote] [--json]`
|
|
2
|
+
//
|
|
3
|
+
// Print one file of a skill — SKILL.md by default — from the embedded bundle
|
|
4
|
+
// or the server registry (registry.ts decides which). The body is the whole
|
|
5
|
+
// of stdout so it pipes; the two header lines (what was read, which source
|
|
6
|
+
// and pin answered) go to stderr. `--json` emits one object with the same
|
|
7
|
+
// fields the built-in agent's `dreamlake_skills_read` returns, minus its
|
|
8
|
+
// paging fields, plus `source` and the group's `status` / `nextAction`.
|
|
9
|
+
import { emitJson, fail } from "../helpers.js";
|
|
10
|
+
import { chooseSource, describeVersion, readFrom, RegistryError, } from "./registry.js";
|
|
11
|
+
function nextActionFor(error, name, opts) {
|
|
12
|
+
if (error.kind === "not-logged-in")
|
|
13
|
+
return { kind: "run", command: "dreamlake login" };
|
|
14
|
+
// No local copy, or a local copy that is not the pinned one: the same read from the server answers for the pin.
|
|
15
|
+
if (error.kind === "not-embedded" || error.kind === "skill-file-mismatch") {
|
|
16
|
+
const parts = ["dreamlake", "skill", "read", name];
|
|
17
|
+
if (opts.file)
|
|
18
|
+
parts.push("--file", opts.file);
|
|
19
|
+
parts.push("--remote");
|
|
20
|
+
return { kind: "run", command: parts.join(" ") };
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
function reject(opts, error, nextAction) {
|
|
25
|
+
if (opts.json) {
|
|
26
|
+
const out = { status: "error", error: error.message, kind: error.kind, ...(error.code ? { code: error.code } : {}), nextAction };
|
|
27
|
+
emitJson(out);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
fail(error.message);
|
|
31
|
+
if (nextAction?.kind === "run")
|
|
32
|
+
process.stderr.write(`\n next: ${nextAction.command}\n`);
|
|
33
|
+
}
|
|
34
|
+
return 1;
|
|
35
|
+
}
|
|
36
|
+
export function readHeader(result) {
|
|
37
|
+
return `skill read ${result.skill}/${result.path}\n source: ${result.source} ${describeVersion(result)}${result.renamedFrom ? `\n renamed: ${result.renamedFrom} → ${result.skill}` : ""}\n`;
|
|
38
|
+
}
|
|
39
|
+
export async function runSkillRead(name, opts) {
|
|
40
|
+
const chosen = chooseSource(opts);
|
|
41
|
+
if (chosen instanceof RegistryError)
|
|
42
|
+
return reject(opts, chosen, nextActionFor(chosen, name, opts));
|
|
43
|
+
let answer;
|
|
44
|
+
try {
|
|
45
|
+
answer = await readFrom(chosen, { skill: name, path: opts.file });
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
const failure = error instanceof RegistryError ? error : new RegistryError(error.message, "read-failed");
|
|
49
|
+
return reject(opts, failure, nextActionFor(failure, name, opts));
|
|
50
|
+
}
|
|
51
|
+
const { result, mismatch, fellBack } = answer;
|
|
52
|
+
// Warnings never share stdout with the body or the JSON object.
|
|
53
|
+
if (fellBack)
|
|
54
|
+
process.stderr.write(`⚠ ${fellBack}; reading the embedded copy instead\n`);
|
|
55
|
+
if (mismatch)
|
|
56
|
+
process.stderr.write(`⚠ ${mismatch}\n`);
|
|
57
|
+
if (opts.json) {
|
|
58
|
+
const out = { status: "ok", ...result, nextAction: null };
|
|
59
|
+
emitJson(out);
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
process.stderr.write(readHeader(result));
|
|
63
|
+
process.stdout.write(result.content.endsWith("\n") || result.content === "" ? result.content : `${result.content}\n`);
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type Transport } from "../../api/client.js";
|
|
2
|
+
import { type SkillReadResult, type SkillsErrorCode } from "../../api/skills.js";
|
|
3
|
+
import { type SkillCatalog } from "./catalog.js";
|
|
4
|
+
export type RegistrySource = "local" | "remote";
|
|
5
|
+
/** The pin that answered. Null fields mean the local bundle carries no manifest. */
|
|
6
|
+
export interface RegistryVersion {
|
|
7
|
+
tag: string | null;
|
|
8
|
+
commit: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface RegistryList {
|
|
11
|
+
source: RegistrySource;
|
|
12
|
+
version: RegistryVersion;
|
|
13
|
+
catalog: SkillCatalog;
|
|
14
|
+
/** Skills this CLI embeds (always known, whichever source answered). */
|
|
15
|
+
embedded: string[];
|
|
16
|
+
}
|
|
17
|
+
/** The agent tool's read shape (minus paging) plus which source answered. */
|
|
18
|
+
export interface RegistryRead extends Omit<SkillReadResult, "tag" | "commit"> {
|
|
19
|
+
source: RegistrySource;
|
|
20
|
+
tag: string | null;
|
|
21
|
+
commit: string | null;
|
|
22
|
+
}
|
|
23
|
+
export interface SourceOptions {
|
|
24
|
+
local?: boolean;
|
|
25
|
+
remote?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** `kind` is the CLI's kebab-case identity; `code` is the server's, when the refusal is one the registry defines. */
|
|
28
|
+
export declare class RegistryError extends Error {
|
|
29
|
+
readonly kind: string;
|
|
30
|
+
readonly code?: SkillsErrorCode | undefined;
|
|
31
|
+
constructor(message: string, kind: string, code?: SkillsErrorCode | undefined);
|
|
32
|
+
}
|
|
33
|
+
export declare function isAvailabilityFailure(error: unknown): boolean;
|
|
34
|
+
/** The version the embedded bundle was cut from, as its manifest records it. */
|
|
35
|
+
export declare function localVersion(bundleDir?: string | null): RegistryVersion;
|
|
36
|
+
export declare function localList(): RegistryList;
|
|
37
|
+
export declare function localRead(input: {
|
|
38
|
+
skill: string;
|
|
39
|
+
path?: string;
|
|
40
|
+
}): RegistryRead;
|
|
41
|
+
export interface Connection {
|
|
42
|
+
remote: string;
|
|
43
|
+
token: string;
|
|
44
|
+
}
|
|
45
|
+
/** The active login, or null when there is none (machine identity carries no human token). */
|
|
46
|
+
export declare function remoteConnection(): Connection | null;
|
|
47
|
+
/** The shared API transport with the CLI's telemetry preference attached. */
|
|
48
|
+
export declare function remoteTransport(c: Connection): Transport;
|
|
49
|
+
export declare const remoteSkills: (c: Connection) => {
|
|
50
|
+
list: () => Promise<import("../../api/skills.js").SkillsList>;
|
|
51
|
+
skill: (name: string) => Promise<import("../../api/skills.js").SkillDetail>;
|
|
52
|
+
read: (input: {
|
|
53
|
+
skill: string;
|
|
54
|
+
path?: string;
|
|
55
|
+
}) => Promise<SkillReadResult>;
|
|
56
|
+
file: (input: {
|
|
57
|
+
skill: string;
|
|
58
|
+
path: string;
|
|
59
|
+
ifNoneMatch?: string;
|
|
60
|
+
}) => Promise<import("../../api/skills.js").SkillFileResult>;
|
|
61
|
+
};
|
|
62
|
+
export declare function remoteList(c: Connection): Promise<RegistryList>;
|
|
63
|
+
export declare function remoteRead(c: Connection, input: {
|
|
64
|
+
skill: string;
|
|
65
|
+
path?: string;
|
|
66
|
+
}): Promise<RegistryRead>;
|
|
67
|
+
export interface ChosenSource {
|
|
68
|
+
source: RegistrySource;
|
|
69
|
+
/** True when a flag chose it; the default choice may fall back. */
|
|
70
|
+
explicit: boolean;
|
|
71
|
+
connection: Connection | null;
|
|
72
|
+
}
|
|
73
|
+
export declare function chooseSource(opts: SourceOptions): ChosenSource | RegistryError;
|
|
74
|
+
/** `v2026.10.29.1 (7d13e08e9260)`, or just the short commit for a commit pin. */
|
|
75
|
+
export declare function describeVersion(v: RegistryVersion): string;
|
|
76
|
+
/** One stderr line when the server's pin is not this CLI's; null when they agree or the CLI has no bundle. */
|
|
77
|
+
export declare function pinMismatchLine(remote: RegistryVersion): string | null;
|
|
78
|
+
/** What a source answered, with the two facts a command reports beside it. */
|
|
79
|
+
export interface SourceAnswer<T> {
|
|
80
|
+
result: T;
|
|
81
|
+
/** The one-line warning when the server's pin is not this CLI's; null when they agree or the local bundle answered. */
|
|
82
|
+
mismatch: string | null;
|
|
83
|
+
/** Why a default remote could not answer, when the local bundle answered instead; null otherwise. */
|
|
84
|
+
fellBack: string | null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Read from the chosen source. In default mode a registry that cannot answer
|
|
88
|
+
* falls back to the local bundle and `fellBack` says why.
|
|
89
|
+
*/
|
|
90
|
+
export declare function readFrom(chosen: ChosenSource, input: {
|
|
91
|
+
skill: string;
|
|
92
|
+
path?: string;
|
|
93
|
+
}): Promise<SourceAnswer<RegistryRead>>;
|
|
94
|
+
/** The same for the list. */
|
|
95
|
+
export declare function listFrom(chosen: ChosenSource): Promise<SourceAnswer<RegistryList>>;
|