@dreamlake/dreamlake-cli 0.101.0 → 0.102.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/host-moves.d.ts +20 -0
- package/dist/api/host-moves.js +18 -0
- package/dist/api/index.d.ts +1 -1
- package/dist/cli/auth/materialized.d.ts +6 -0
- package/dist/cli/auth/materialized.js +2 -1
- package/dist/cli/config.d.ts +2 -2
- package/dist/cli/config.js +13 -5
- package/dist/cli/help-examples.generated.js +1 -0
- package/dist/cli/hosts/index.js +5 -5
- package/dist/cli/hosts/move.d.ts +3 -0
- package/dist/cli/hosts/move.js +5 -0
- package/dist/cli/hosts/ssh-transport.d.ts +27 -0
- package/dist/cli/hosts/ssh-transport.js +79 -0
- package/dist/cli/hosts/ssh.js +2 -3
- package/dist/cli/index.js +2 -0
- package/dist/cli/infra/index.js +2 -2
- package/dist/cli/jobs/index.js +1 -1
- package/dist/cli/namespace.d.ts +10 -0
- package/dist/cli/namespace.js +70 -0
- package/dist/cli/notes/index.js +31 -33
- package/dist/cli/version.d.ts +1 -1
- package/dist/cli/version.js +1 -1
- package/package.json +10 -9
package/dist/api/host-moves.d.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import { type Transport } from './client.js';
|
|
2
|
+
/** Saved sessions stay at their original addresses; existing sharing is removed. */
|
|
3
|
+
export type HostMoveRetainedSessions = {
|
|
4
|
+
count: number;
|
|
5
|
+
policy: 'retain_original_namespace_make_private';
|
|
6
|
+
accessChanges: {
|
|
7
|
+
public: number;
|
|
8
|
+
shared: number;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
/** Run history and acknowledged executions retain their original namespace and identities. */
|
|
12
|
+
export type HostMoveRetainedRuns = {
|
|
13
|
+
count: number;
|
|
14
|
+
terminal: number;
|
|
15
|
+
active: number;
|
|
16
|
+
policy: 'retain_original_namespace_acknowledged_runs';
|
|
17
|
+
};
|
|
2
18
|
export type HostMovePreview = {
|
|
3
19
|
apiVersion: 1;
|
|
4
20
|
hostId: string;
|
|
@@ -12,6 +28,8 @@ export type HostMovePreview = {
|
|
|
12
28
|
previewHash: string;
|
|
13
29
|
blockers: string[];
|
|
14
30
|
executable: boolean;
|
|
31
|
+
sessions?: HostMoveRetainedSessions;
|
|
32
|
+
runs?: HostMoveRetainedRuns;
|
|
15
33
|
};
|
|
16
34
|
export type HostMoveRequest = {
|
|
17
35
|
destinationNamespace: string;
|
|
@@ -25,6 +43,8 @@ export type HostMoveReceipt = Omit<HostMovePreview, 'previewHash' | 'blockers' |
|
|
|
25
43
|
recordedAt: string;
|
|
26
44
|
replayed: boolean;
|
|
27
45
|
};
|
|
46
|
+
export declare function validateHostMoveSessions(value: unknown): void;
|
|
47
|
+
export declare function validateHostMoveRuns(value: unknown): void;
|
|
28
48
|
export declare function validateHostMovePreview(value: unknown, hostId: string, destinationNamespace: string): HostMovePreview;
|
|
29
49
|
export declare function validateHostMoveReceipt(value: unknown, hostId: string, request: HostMoveRequest): HostMoveReceipt;
|
|
30
50
|
export declare function hostMoveApi(t: Transport, namespace: string): {
|
package/dist/api/host-moves.js
CHANGED
|
@@ -6,11 +6,29 @@ const base = (namespace, hostId) => {
|
|
|
6
6
|
invalid();
|
|
7
7
|
return `/namespaces/${seg(namespace)}/hosts/${hostId}/move`;
|
|
8
8
|
};
|
|
9
|
+
export function validateHostMoveSessions(value) {
|
|
10
|
+
if (value === undefined)
|
|
11
|
+
return;
|
|
12
|
+
const v = value;
|
|
13
|
+
if (!v || v.policy !== 'retain_original_namespace_make_private' || !Number.isSafeInteger(v.count) || v.count < 0 ||
|
|
14
|
+
!v.accessChanges || !['public', 'shared'].every(key => { const n = v.accessChanges[key]; return Number.isSafeInteger(n) && n >= 0 && n <= v.count; }))
|
|
15
|
+
invalid();
|
|
16
|
+
}
|
|
17
|
+
export function validateHostMoveRuns(value) {
|
|
18
|
+
if (value === undefined)
|
|
19
|
+
return;
|
|
20
|
+
const v = value;
|
|
21
|
+
if (!v || v.policy !== 'retain_original_namespace_acknowledged_runs' ||
|
|
22
|
+
![v.count, v.terminal, v.active].every(n => Number.isSafeInteger(n) && n >= 0) || v.terminal + v.active !== v.count)
|
|
23
|
+
invalid();
|
|
24
|
+
}
|
|
9
25
|
function common(v, hostId, destinationNamespace) {
|
|
10
26
|
if (!v || v.apiVersion !== 1 || v.hostId !== hostId || v.destinationNamespace !== destinationNamespace ||
|
|
11
27
|
![v.sourceNamespaceId, v.destinationNamespaceId, v.ownerUserId, v.name].every(nonempty) ||
|
|
12
28
|
v.visibility !== 'private' || !Number.isSafeInteger(v.revision) || v.revision < 0)
|
|
13
29
|
invalid();
|
|
30
|
+
validateHostMoveSessions(v.sessions);
|
|
31
|
+
validateHostMoveRuns(v.runs);
|
|
14
32
|
}
|
|
15
33
|
export function validateHostMovePreview(value, hostId, destinationNamespace) {
|
|
16
34
|
const v = value;
|
package/dist/api/index.d.ts
CHANGED
|
@@ -2122,4 +2122,4 @@ export { documentEdits, documentInsertion } from "./note-edits.js";
|
|
|
2122
2122
|
export * from "./note-facade.js";
|
|
2123
2123
|
export type { NoteReadingOptions, NoteReadingPage, NoteFocusedRead } from "./note-reading.js";
|
|
2124
2124
|
export { lineRange, focusedRead, InvalidLineRange } from "./note-reading.js";
|
|
2125
|
-
export type { HostMovePreview, HostMoveRequest, HostMoveReceipt } from "./host-moves.js";
|
|
2125
|
+
export type { HostMovePreview, HostMoveRequest, HostMoveReceipt, HostMoveRetainedSessions, HostMoveRetainedRuns } from "./host-moves.js";
|
|
@@ -10,6 +10,12 @@ export interface MaterializedConfig {
|
|
|
10
10
|
remote_url?: string;
|
|
11
11
|
/** Cached namespace slug for the materialized (remote, token) pair. */
|
|
12
12
|
namespace?: string;
|
|
13
|
+
/** Local CLI default, bound to the validated connection without storing another bearer. */
|
|
14
|
+
default_namespace?: {
|
|
15
|
+
namespace: string;
|
|
16
|
+
remote: string;
|
|
17
|
+
tokenSha256: string;
|
|
18
|
+
};
|
|
13
19
|
device_secret?: string;
|
|
14
20
|
[key: string]: unknown;
|
|
15
21
|
}
|
|
@@ -91,6 +91,7 @@ export function projectEnv(env, dir) {
|
|
|
91
91
|
updateConfig({
|
|
92
92
|
remote_url: env.server.replace(/\/+$/, ""),
|
|
93
93
|
namespace: env.namespace || undefined,
|
|
94
|
+
default_namespace: undefined,
|
|
94
95
|
}, dir);
|
|
95
96
|
}
|
|
96
97
|
/** Remove the connection (logout with no env left). Keeps device_secret. */
|
|
@@ -98,5 +99,5 @@ export function clearProjection(dir) {
|
|
|
98
99
|
const tokens = readJson(tokensPath(dir));
|
|
99
100
|
delete tokens[TOKEN_SLOT];
|
|
100
101
|
writeJson(tokensPath(dir), tokens);
|
|
101
|
-
updateConfig({ remote_url: undefined, namespace: undefined }, dir);
|
|
102
|
+
updateConfig({ remote_url: undefined, namespace: undefined, default_namespace: undefined }, dir);
|
|
102
103
|
}
|
package/dist/cli/config.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export declare function resolveToken(flag?: string, dir?: string): string | null
|
|
|
8
8
|
/** Decode a JWT payload without verifying the signature. Returns {} on failure. */
|
|
9
9
|
export declare function decodeJwtPayload(token: string): Record<string, unknown>;
|
|
10
10
|
/**
|
|
11
|
-
* Resolve the
|
|
12
|
-
* explicit
|
|
11
|
+
* Resolve a command's default namespace without changing the signed-in user's identity:
|
|
12
|
+
* explicit → selected CLI namespace → personal cache → GET /auth/me → JWT decode.
|
|
13
13
|
*
|
|
14
14
|
* The cache is only trusted when the effective (remote, token) is exactly
|
|
15
15
|
* the materialized pair — under a flag or env-var override it may describe
|
package/dist/cli/config.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import { identityMode, loadMachineConfig } from "./auth/machine.js";
|
|
2
|
-
// Shared connection config —
|
|
3
|
-
//
|
|
3
|
+
// Shared connection config — token and remote match dreamlake-py.
|
|
4
|
+
// Namespace selection is CLI-local; SDK domain methods take explicit scopes:
|
|
4
5
|
//
|
|
5
6
|
// token: flag → DREAMLAKE_API_KEY → ~/.dreamlake/tokens.json → null
|
|
6
7
|
// remote: flag → DREAMLAKE_REMOTE → config.json remote_url → prod
|
|
7
|
-
// namespace: explicit
|
|
8
|
+
// namespace: explicit → selected CLI namespace → personal cache → GET /auth/me → JWT decode
|
|
8
9
|
//
|
|
9
10
|
// The multi-env cache (auth.yml) is deliberately absent here — it is a
|
|
10
11
|
// write-path convenience for `env use` and is never consulted to answer
|
|
@@ -56,8 +57,8 @@ export function decodeJwtPayload(token) {
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
/**
|
|
59
|
-
* Resolve the
|
|
60
|
-
* explicit
|
|
60
|
+
* Resolve a command's default namespace without changing the signed-in user's identity:
|
|
61
|
+
* explicit → selected CLI namespace → personal cache → GET /auth/me → JWT decode.
|
|
61
62
|
*
|
|
62
63
|
* The cache is only trusted when the effective (remote, token) is exactly
|
|
63
64
|
* the materialized pair — under a flag or env-var override it may describe
|
|
@@ -67,6 +68,13 @@ export async function resolveNamespace(explicit, opts) {
|
|
|
67
68
|
if (explicit)
|
|
68
69
|
return explicit;
|
|
69
70
|
const cfg = readConfig(opts.dir);
|
|
71
|
+
const selected = cfg.default_namespace;
|
|
72
|
+
if (selected && typeof selected === 'object' && selected.remote === stripTrailingSlash(opts.remote) &&
|
|
73
|
+
selected.tokenSha256 === createHash('sha256').update(opts.token).digest('hex')) {
|
|
74
|
+
if (typeof selected.namespace !== 'string' || !/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(selected.namespace))
|
|
75
|
+
throw new Error('Saved CLI namespace is invalid; run dreamlake su <namespace> again');
|
|
76
|
+
return selected.namespace;
|
|
77
|
+
}
|
|
70
78
|
if (cfg.namespace &&
|
|
71
79
|
cfg.remote_url &&
|
|
72
80
|
stripTrailingSlash(cfg.remote_url) === stripTrailingSlash(opts.remote) &&
|
|
@@ -12,6 +12,7 @@ export const helpExamples = {
|
|
|
12
12
|
"runnable execute": "dreamlake runnable execute exec/acme/recipes.process@EXECUTION_DIGEST \\\n --queue cpu --inputs record.json --timeout-seconds 600 --json\ndreamlake runnable execute exec/acme/recipes.process@EXECUTION_DIGEST \\\n --queue cpu --inputs record.json --timeout-seconds 600 --attempt 2 --json",
|
|
13
13
|
"runnable execution-receipt": "dreamlake runnable execution-receipt exec/acme/recipes.process@EXECUTION_DIGEST \\\n --queue cpu --inputs record.json --timeout-seconds 600 --wait-seconds 30",
|
|
14
14
|
"hosts": "dreamlake hosts\ndreamlake hosts --all\ndreamlake hosts -h\ndreamlake hosts list -h",
|
|
15
|
+
"su": "dreamlake su fortyfive\ndreamlake hosts list\ndreamlake hosts list --namespace geyang\ndreamlake su geyang",
|
|
15
16
|
"nymph": "dreamlake nymph\ndreamlake nymph --json",
|
|
16
17
|
"nymph setup": "dreamlake nymph setup --name alice/computers/laptop --lakeshore-id CONNECTION_ID",
|
|
17
18
|
"nymph config": "dreamlake nymph config --name alice/computers/laptop",
|
package/dist/cli/hosts/index.js
CHANGED
|
@@ -134,7 +134,7 @@ export function registerHostsCommand(program) {
|
|
|
134
134
|
process.exitCode = await runHostsEnroll(opts);
|
|
135
135
|
});
|
|
136
136
|
collectionList(group, "list").description("list active (verified online) hosts across all groups and pages in one namespace")
|
|
137
|
-
.option("--namespace <namespace>", "namespace slug (default:
|
|
137
|
+
.option("--namespace <namespace>", "namespace slug (default: selected CLI namespace, otherwise personal)")
|
|
138
138
|
.option("--group <group>", "limit to one group")
|
|
139
139
|
.option("--archived <mode>", "catalog visibility: exclude (default), include, or only")
|
|
140
140
|
.option("--all", "include offline hosts and hosts with unknown connection state")
|
|
@@ -155,7 +155,7 @@ export function registerHostsCommand(program) {
|
|
|
155
155
|
});
|
|
156
156
|
group.command("enrollments").description("inspect enrollment identities and observed presence for one host; read-only")
|
|
157
157
|
.argument("<selector>", "host ID or namespace/group/host")
|
|
158
|
-
.option("--namespace <namespace>", "namespace for a host ID (default:
|
|
158
|
+
.option("--namespace <namespace>", "namespace for a host ID (default: selected CLI namespace, otherwise personal)")
|
|
159
159
|
.option("--json", "emit machine-readable enrollment details and observed presence freshness")
|
|
160
160
|
.action(async (selector, opts) => {
|
|
161
161
|
try {
|
|
@@ -175,7 +175,7 @@ export function registerHostsCommand(program) {
|
|
|
175
175
|
group.command("metrics").description("read timestamped CPU, RAM, and disk observations for one enrollment")
|
|
176
176
|
.argument("<selector>", "host ID or namespace/group/host")
|
|
177
177
|
.requiredOption("--enrollment <id>", "exact enrollment ID from hosts enrollments")
|
|
178
|
-
.option("--namespace <namespace>", "namespace for a host ID (default:
|
|
178
|
+
.option("--namespace <namespace>", "namespace for a host ID (default: selected CLI namespace, otherwise personal)")
|
|
179
179
|
.option("--resolution <seconds>", "history resolution: 10, 60, 900, or 3600 seconds", "60")
|
|
180
180
|
.option("--json", "emit latest sample, retained history, and freshness")
|
|
181
181
|
.action(async (selector, opts) => {
|
|
@@ -196,7 +196,7 @@ export function registerHostsCommand(program) {
|
|
|
196
196
|
.argument("<selector>", "host ID or namespace/group/host")
|
|
197
197
|
.requiredOption("--enrollment <id>", "exact enrollment ID from hosts enrollments")
|
|
198
198
|
.requiredOption("--action <action>", "ssh or tracked-run (ordinary uv-run/uvx)")
|
|
199
|
-
.option("--namespace <namespace>", "namespace for a host ID (default:
|
|
199
|
+
.option("--namespace <namespace>", "namespace for a host ID (default: selected CLI namespace, otherwise personal)")
|
|
200
200
|
.option("--json", "emit the backend readiness verdict and observation timestamps")
|
|
201
201
|
.action(async (selector, opts) => {
|
|
202
202
|
try {
|
|
@@ -256,7 +256,7 @@ export function registerHostsCommand(program) {
|
|
|
256
256
|
}
|
|
257
257
|
group.command("status").description("inspect a host's backend-reported connection and enrollments")
|
|
258
258
|
.argument("<selector>", "host ID, namespace/group/host or quoted namespace/group/*")
|
|
259
|
-
.option("--namespace <namespace>", "namespace for a host ID (default:
|
|
259
|
+
.option("--namespace <namespace>", "namespace for a host ID (default: selected CLI namespace, otherwise personal)")
|
|
260
260
|
.option("--page <number>", "group listing page (default 1)")
|
|
261
261
|
.option("--page-size <number>", "listing page size (default 100, maximum 100)")
|
|
262
262
|
.option("--json", "emit machine-readable output")
|
package/dist/cli/hosts/move.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type HostMoveRetainedSessions, type HostMoveRetainedRuns } from '../../api/host-moves.js';
|
|
1
2
|
import type { Command } from 'commander';
|
|
2
3
|
import { hostRequest } from './api.js';
|
|
3
4
|
export interface HostMovePreview {
|
|
@@ -13,6 +14,8 @@ export interface HostMovePreview {
|
|
|
13
14
|
previewHash: string;
|
|
14
15
|
blockers: string[];
|
|
15
16
|
executable: boolean;
|
|
17
|
+
sessions?: HostMoveRetainedSessions;
|
|
18
|
+
runs?: HostMoveRetainedRuns;
|
|
16
19
|
}
|
|
17
20
|
export interface HostMoveReceipt extends Omit<HostMovePreview, 'previewHash' | 'blockers' | 'executable'> {
|
|
18
21
|
operationId: string;
|
package/dist/cli/hosts/move.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { validateHostMoveSessions, validateHostMoveRuns } from '../../api/host-moves.js';
|
|
1
2
|
import { hostApiPath, hostRequest } from './api.js';
|
|
2
3
|
import { resolveHostNamespace } from './inventory.js';
|
|
3
4
|
function input(hostId, to) {
|
|
@@ -10,6 +11,8 @@ function common(value, hostId, to) {
|
|
|
10
11
|
value.sourceNamespaceId === value.destinationNamespaceId || typeof value.name !== 'string' || !value.name.startsWith(`${to}/`) ||
|
|
11
12
|
typeof value.ownerUserId !== 'string' || !value.ownerUserId || value.visibility !== 'private' || !Number.isSafeInteger(value.revision) || value.revision < 0 || value.revision > 2147483647)
|
|
12
13
|
throw new Error('Host API returned an invalid private move response');
|
|
14
|
+
validateHostMoveSessions(value.sessions);
|
|
15
|
+
validateHostMoveRuns(value.runs);
|
|
13
16
|
}
|
|
14
17
|
export async function previewHostMove(hostId, opts, request = hostRequest) {
|
|
15
18
|
input(hostId, opts.to);
|
|
@@ -55,6 +58,8 @@ export function registerHostMoveCommand(group) {
|
|
|
55
58
|
console.log(JSON.stringify(result, null, 2));
|
|
56
59
|
else
|
|
57
60
|
console.log([`Host: ${result.name}`, 'Access: Private — only you', `Revision: ${result.revision}`,
|
|
61
|
+
...(result.sessions ? [`Saved sessions: ${result.sessions.count} retained at their original addresses; private to you`, `Session access changes: ${result.sessions.accessChanges.public} public and ${result.sessions.accessChanges.shared} shared become private`] : []),
|
|
62
|
+
...(result.runs ? [`Runs retained: ${result.runs.count} (${result.runs.terminal} terminal, ${result.runs.active} active acknowledged); original namespace and execution identity unchanged`] : []),
|
|
58
63
|
...('previewHash' in result ? [`Preview hash: ${result.previewHash}`, result.executable ? 'Ready to move. Apply with --confirm and these reviewed inputs.' : `Blocked: ${result.blockers.join(', ')}`]
|
|
59
64
|
: [`Operation ID: ${result.operationId}`, `Request ID: ${result.requestId}`, result.replayed ? 'Stored original receipt; inspect the host for its current location.' : 'Move committed.'])].join('\n'));
|
|
60
65
|
if ('executable' in result && !result.executable)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Socket } from 'node:net';
|
|
2
|
+
import { Duplex } from 'node:stream';
|
|
3
|
+
import type WebSocket from 'ws';
|
|
4
|
+
/**
|
|
5
|
+
* Feed ws bounded raw chunks through the public Duplex contract. Pausing a
|
|
6
|
+
* WebSocket cannot stop frames already decoded from one large Bun TCP chunk.
|
|
7
|
+
* This adapter leaves the raw socket in pull mode and admits at most 16 KiB
|
|
8
|
+
* per read, so the decoder returns control before another full relay frame.
|
|
9
|
+
*/
|
|
10
|
+
export declare class SshIngress extends Duplex {
|
|
11
|
+
private socket;
|
|
12
|
+
private pulling;
|
|
13
|
+
private connected;
|
|
14
|
+
private pendingWrite?;
|
|
15
|
+
constructor(socket: Socket, secure?: boolean);
|
|
16
|
+
get connecting(): boolean;
|
|
17
|
+
get encrypted(): boolean | undefined;
|
|
18
|
+
setTimeout(ms: number, callback?: () => void): this;
|
|
19
|
+
setNoDelay(value?: boolean): this;
|
|
20
|
+
setKeepAlive(value?: boolean, delay?: number): this;
|
|
21
|
+
private pull;
|
|
22
|
+
_read(): void;
|
|
23
|
+
_write(bytes: Buffer, encoding: BufferEncoding, done: (error?: Error | null) => void): void;
|
|
24
|
+
_final(done: () => void): void;
|
|
25
|
+
_destroy(error: Error | null, done: (error?: Error | null) => void): void;
|
|
26
|
+
}
|
|
27
|
+
export declare function sshSocket(url: string, ticket?: string): WebSocket;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { connect as netConnect, isIP } from 'node:net';
|
|
2
|
+
import { connect as tlsConnect } from 'node:tls';
|
|
3
|
+
import { Duplex } from 'node:stream';
|
|
4
|
+
// A package alias keeps Bun from substituting its built-in ws shim.
|
|
5
|
+
import PackageWebSocket from 'ws-transport';
|
|
6
|
+
/**
|
|
7
|
+
* Feed ws bounded raw chunks through the public Duplex contract. Pausing a
|
|
8
|
+
* WebSocket cannot stop frames already decoded from one large Bun TCP chunk.
|
|
9
|
+
* This adapter leaves the raw socket in pull mode and admits at most 16 KiB
|
|
10
|
+
* per read, so the decoder returns control before another full relay frame.
|
|
11
|
+
*/
|
|
12
|
+
export class SshIngress extends Duplex {
|
|
13
|
+
socket;
|
|
14
|
+
pulling = false;
|
|
15
|
+
connected = false;
|
|
16
|
+
pendingWrite;
|
|
17
|
+
constructor(socket, secure = false) {
|
|
18
|
+
super({ highWaterMark: 16384 });
|
|
19
|
+
this.socket = socket;
|
|
20
|
+
socket.on('readable', () => this.pull());
|
|
21
|
+
socket.on('end', () => this.push(null));
|
|
22
|
+
socket.on('error', error => this.destroy(error));
|
|
23
|
+
socket.on('close', () => this.destroy());
|
|
24
|
+
socket.on('timeout', () => this.emit('timeout'));
|
|
25
|
+
socket.on('connect', () => this.emit('connect'));
|
|
26
|
+
socket.once(secure ? 'secureConnect' : 'connect', () => {
|
|
27
|
+
this.connected = true;
|
|
28
|
+
const pending = this.pendingWrite;
|
|
29
|
+
this.pendingWrite = undefined;
|
|
30
|
+
if (pending)
|
|
31
|
+
socket.write(pending.bytes, pending.encoding, pending.done);
|
|
32
|
+
if (secure)
|
|
33
|
+
this.emit('secureConnect');
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
get connecting() { return this.socket.connecting; }
|
|
37
|
+
get encrypted() { return this.socket.encrypted; }
|
|
38
|
+
setTimeout(ms, callback) { this.socket.setTimeout(ms, callback); return this; }
|
|
39
|
+
setNoDelay(value) { this.socket.setNoDelay(value); return this; }
|
|
40
|
+
setKeepAlive(value, delay) { this.socket.setKeepAlive(value, delay); return this; }
|
|
41
|
+
pull() {
|
|
42
|
+
if (!this.pulling || this.destroyed)
|
|
43
|
+
return;
|
|
44
|
+
const bytes = this.socket.read(Math.min(16384, this.socket.readableLength || 16384));
|
|
45
|
+
if (bytes && !this.push(bytes))
|
|
46
|
+
this.pulling = false;
|
|
47
|
+
}
|
|
48
|
+
_read() { this.pulling = true; this.pull(); }
|
|
49
|
+
_write(bytes, encoding, done) {
|
|
50
|
+
// Bun's TLS socket rejects writes during asynchronous DNS/handshake. Keep
|
|
51
|
+
// just the stream's current write until the authenticated connection exists.
|
|
52
|
+
if (!this.connected)
|
|
53
|
+
this.pendingWrite = { bytes, encoding, done };
|
|
54
|
+
else
|
|
55
|
+
this.socket.write(bytes, encoding, done);
|
|
56
|
+
}
|
|
57
|
+
_final(done) { this.socket.end(done); }
|
|
58
|
+
_destroy(error, done) {
|
|
59
|
+
const pending = this.pendingWrite;
|
|
60
|
+
this.pendingWrite = undefined;
|
|
61
|
+
this.socket.destroy();
|
|
62
|
+
pending?.done(error ?? new Error('SSH socket closed before connection'));
|
|
63
|
+
done(error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
export function sshSocket(url, ticket) {
|
|
67
|
+
const secure = new URL(url).protocol === 'wss:';
|
|
68
|
+
return new PackageWebSocket(url, ticket ? 'nymph-ssh.v1' : [], {
|
|
69
|
+
...(ticket ? { headers: { Authorization: `Bearer ${ticket}` } } : {}),
|
|
70
|
+
perMessageDeflate: false, maxPayload: 65537, handshakeTimeout: 10000, followRedirects: false,
|
|
71
|
+
// ws documents a Duplex socket; its type declaration narrows this to net.Socket.
|
|
72
|
+
createConnection: ((options) => {
|
|
73
|
+
const opts = { ...options, path: secure ? undefined : options.socketPath };
|
|
74
|
+
if (secure && !opts.servername && opts.servername !== '')
|
|
75
|
+
opts.servername = isIP(opts.host ?? '') ? '' : opts.host;
|
|
76
|
+
return new SshIngress(secure ? tlsConnect(opts) : netConnect(opts), secure);
|
|
77
|
+
}),
|
|
78
|
+
});
|
|
79
|
+
}
|
package/dist/cli/hosts/ssh.js
CHANGED
|
@@ -7,7 +7,7 @@ import { createServer } from 'node:net';
|
|
|
7
7
|
import { Duplex } from 'node:stream';
|
|
8
8
|
import { promisify } from 'node:util';
|
|
9
9
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
10
|
-
import
|
|
10
|
+
import { sshSocket } from './ssh-transport.js';
|
|
11
11
|
import { select } from '@inquirer/prompts';
|
|
12
12
|
import { HostApiError, hostApiPath, hostRequest } from './api.js';
|
|
13
13
|
import { hostStatus } from './enroll.js';
|
|
@@ -25,8 +25,7 @@ export const defaultSshIO = {
|
|
|
25
25
|
request: hostRequest, fetch: (...args) => fetch(...args), terminal: () => Boolean(process.stderr.isTTY),
|
|
26
26
|
interactive: () => Boolean(process.stdin.isTTY && process.stderr.isTTY),
|
|
27
27
|
pick: (inventory, selector, command) => pickHost(inventory, selector, command, { input: process.stdin, output: process.stderr, color: !process.env.NO_COLOR }),
|
|
28
|
-
socket:
|
|
29
|
-
perMessageDeflate: false, maxPayload: 65537, handshakeTimeout: 10000, followRedirects: false }),
|
|
28
|
+
socket: sshSocket,
|
|
30
29
|
spawn: args => spawn('ssh', args, { stdio: 'inherit' }),
|
|
31
30
|
};
|
|
32
31
|
/** Only a selector that named no host earns suggestions; auth, namespace and transport errors pass through unchanged. */
|
package/dist/cli/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { registerNamespaceCommand } from "./namespace.js";
|
|
1
2
|
import { registerNymphCommand } from "./nymph/index.js";
|
|
2
3
|
import { collectionList } from "./collection-list.js";
|
|
3
4
|
import { configureTelemetryCommand, deliverTelemetry, installTelemetryOptOut, registerTelemetryCommand, startCommandTelemetry } from './telemetry.js';
|
|
@@ -114,6 +115,7 @@ async function main(argv) {
|
|
|
114
115
|
process.env.DREAMLAKE_IDENTITY = mode;
|
|
115
116
|
}
|
|
116
117
|
});
|
|
118
|
+
registerNamespaceCommand(program);
|
|
117
119
|
registerMachineCommand(program);
|
|
118
120
|
registerTelemetryCommand(program);
|
|
119
121
|
program.hook("preAction", (_program, action) => configureTelemetryCommand(action));
|
package/dist/cli/infra/index.js
CHANGED
|
@@ -19,10 +19,10 @@ export function registerInfraCommand(program) {
|
|
|
19
19
|
const cmd = (name === "list" ? collectionList(infra) : infra.command(name === "create" ? "create <name>" : `${name} <stack-id>`))
|
|
20
20
|
.option("--remote <url>", "API remote").option("--token <token>", "API credential (never printed)").option("--json", "JSON output");
|
|
21
21
|
if (name === "list")
|
|
22
|
-
cmd.requiredOption("--project <slug>", "owner/access project").option("--namespace <slug>", "default:
|
|
22
|
+
cmd.requiredOption("--project <slug>", "owner/access project").option("--namespace <slug>", "default: selected CLI namespace, otherwise personal");
|
|
23
23
|
if (name === "create")
|
|
24
24
|
cmd.requiredOption("--project <slug>", "owner project")
|
|
25
|
-
.option("--namespace <slug>", "default:
|
|
25
|
+
.option("--namespace <slug>", "default: selected CLI namespace, otherwise personal")
|
|
26
26
|
.requiredOption("--environment <label>", "Terraform environment")
|
|
27
27
|
.requiredOption("--repository <url>", "HTTPS repository URL")
|
|
28
28
|
.requiredOption("--directory <path>", "relative Terraform root (empty string allowed)")
|
package/dist/cli/jobs/index.js
CHANGED
|
@@ -44,7 +44,7 @@ function hostId(value) {
|
|
|
44
44
|
return value;
|
|
45
45
|
}
|
|
46
46
|
function common(command) {
|
|
47
|
-
return command.option("--namespace <slug>", "namespace (default:
|
|
47
|
+
return command.option("--namespace <slug>", "namespace (default: selected CLI namespace, otherwise personal)").option("--json", "output the full API JSON receipt");
|
|
48
48
|
}
|
|
49
49
|
function printReceipt(result, json) {
|
|
50
50
|
console.log(json ? JSON.stringify(result) : `${jobText(result.job)}${result.alreadyRegistered ? "\nAlready registered." : ""}`);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
export declare function selectNamespace(value: string, options?: {
|
|
3
|
+
dir?: string;
|
|
4
|
+
fetch?: typeof fetch;
|
|
5
|
+
}): Promise<{
|
|
6
|
+
namespace: string;
|
|
7
|
+
personalNamespace: string;
|
|
8
|
+
remote: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function registerNamespaceCommand(program: Command): void;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Persistent CLI scope; it never replaces a login, an identity or the GUI workspace. */
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { readConfig, readToken, updateConfig } from './auth/materialized.js';
|
|
4
|
+
import { resolveRemote, resolveToken } from './config.js';
|
|
5
|
+
const slug = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
6
|
+
const normalizeRemote = (remote) => remote.replace(/\/+$/, '');
|
|
7
|
+
export async function selectNamespace(value, options = {}) {
|
|
8
|
+
const namespace = value.replace(/^@/, '');
|
|
9
|
+
if (!slug.test(namespace))
|
|
10
|
+
throw new Error('Use dreamlake su <namespace> with an exact namespace name');
|
|
11
|
+
const remote = resolveRemote(undefined, options.dir), token = resolveToken(undefined, options.dir);
|
|
12
|
+
if (!token)
|
|
13
|
+
throw new Error('Log in to DreamLake before selecting a namespace');
|
|
14
|
+
const materialized = () => readToken(options.dir) === token && normalizeRemote(readConfig(options.dir).remote_url ?? '') === remote;
|
|
15
|
+
if (!materialized())
|
|
16
|
+
throw new Error('Select a saved login with dreamlake auth env use before persisting a namespace; explicit connection overrides are not saved');
|
|
17
|
+
const request = options.fetch ?? fetch;
|
|
18
|
+
const get = async (path, json) => {
|
|
19
|
+
let response;
|
|
20
|
+
try {
|
|
21
|
+
response = await request(remote + path, { method: json === undefined ? 'GET' : 'POST',
|
|
22
|
+
headers: { Authorization: `Bearer ${token}`, ...(json === undefined ? {} : { 'Content-Type': 'application/json' }) },
|
|
23
|
+
...(json === undefined ? {} : { body: JSON.stringify(json) }), redirect: 'error', signal: AbortSignal.timeout(10000) });
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
throw new Error('Could not verify namespace access; the saved selection was not changed');
|
|
27
|
+
}
|
|
28
|
+
if (!response.ok)
|
|
29
|
+
throw new Error(`Could not verify namespace access (HTTP ${response.status}); the saved selection was not changed`);
|
|
30
|
+
try {
|
|
31
|
+
return await response.json();
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
throw new Error('Invalid namespace access response; the saved selection was not changed');
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const me = await get('/auth/me');
|
|
38
|
+
if (!me || typeof me.namespace?.slug !== 'string' || !slug.test(me.namespace.slug))
|
|
39
|
+
throw new Error('Could not verify the signed-in personal namespace');
|
|
40
|
+
if (namespace !== me.namespace.slug) {
|
|
41
|
+
const memberships = await get('/graphql', { query: 'query { myOrganizations { slug } }', variables: {} });
|
|
42
|
+
if (!memberships || typeof memberships !== 'object' || memberships.errors?.length || !Array.isArray(memberships.data?.myOrganizations))
|
|
43
|
+
throw new Error('Could not verify organization memberships; the saved selection was not changed');
|
|
44
|
+
if (!memberships.data.myOrganizations.some(org => org?.slug === namespace))
|
|
45
|
+
throw new Error(`You do not have namespace membership in '${namespace}'; the saved selection was not changed`);
|
|
46
|
+
}
|
|
47
|
+
// Recheck after I/O. The stored digest also prevents another process's login switch from reusing this selection.
|
|
48
|
+
if (!materialized())
|
|
49
|
+
throw new Error('The login changed while checking namespace access; retry against the intended login');
|
|
50
|
+
updateConfig({ default_namespace: { namespace, remote, tokenSha256: createHash('sha256').update(token).digest('hex') } }, options.dir);
|
|
51
|
+
return { namespace, personalNamespace: me.namespace.slug, remote };
|
|
52
|
+
}
|
|
53
|
+
export function registerNamespaceCommand(program) {
|
|
54
|
+
program.command('su').description('persist the default namespace for CLI commands under the current login')
|
|
55
|
+
.argument('<namespace>', 'personal or organization namespace name; no special personal alias')
|
|
56
|
+
.option('--json', 'emit the selected namespace and unchanged personal identity')
|
|
57
|
+
.action(async (namespace, options) => {
|
|
58
|
+
try {
|
|
59
|
+
const selected = await selectNamespace(namespace);
|
|
60
|
+
if (options.json)
|
|
61
|
+
console.log(JSON.stringify(selected, null, 2));
|
|
62
|
+
else
|
|
63
|
+
console.log(`Default namespace: ${selected.namespace}\nSigned-in personal namespace: ${selected.personalNamespace}`);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
console.error(error instanceof Error ? error.message : 'Namespace selection failed');
|
|
67
|
+
process.exitCode = 1;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
package/dist/cli/notes/index.js
CHANGED
|
@@ -231,7 +231,7 @@ export function registerNotesCommand(program) {
|
|
|
231
231
|
.option("--file <path>", "initial body from a file ('-' for stdin)")
|
|
232
232
|
.option("--text <string>", "initial body, inline")
|
|
233
233
|
.option("--public", "anyone can read it (default: private)")
|
|
234
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
234
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
235
235
|
.option("--json", "emit JSON")
|
|
236
236
|
.action(async (name, opts) => { process.exitCode = await runNotesCreate(name, opts); });
|
|
237
237
|
// ── notes list ──
|
|
@@ -240,7 +240,7 @@ export function registerNotesCommand(program) {
|
|
|
240
240
|
.option("--include-archived", "include archived notes")
|
|
241
241
|
.option("--limit <n>", "page size", "50")
|
|
242
242
|
.option("--offset <n>", "skip this many rows first (zero-based paging: 0, 20, 40, …)")
|
|
243
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
243
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
244
244
|
.option("--shared", "list notes other people shared with you, across namespaces")
|
|
245
245
|
.option("--json", "emit JSON")
|
|
246
246
|
.action(async (opts) => { process.exitCode = await runNotesList(opts); });
|
|
@@ -250,7 +250,7 @@ export function registerNotesCommand(program) {
|
|
|
250
250
|
.description("find notes by title or body text")
|
|
251
251
|
.option("--include-archived", "include archived notes")
|
|
252
252
|
.option("--limit <n>", "page size", "50")
|
|
253
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
253
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
254
254
|
.option("--json", "emit JSON")
|
|
255
255
|
.action(async (query, opts) => { process.exitCode = await runNotesSearch(query, opts); });
|
|
256
256
|
// ── notes grep ──
|
|
@@ -266,7 +266,7 @@ export function registerNotesCommand(program) {
|
|
|
266
266
|
.option("--note <ids>", "comma-separated note ids or slugs to search")
|
|
267
267
|
.option("-C, --context <n>", "lines of context either side")
|
|
268
268
|
.option("--limit <n>", "maximum number of hits", "50")
|
|
269
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
269
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
270
270
|
.option("--json", "emit JSON (each hit carries its etag and character range)")
|
|
271
271
|
.action(async (query, opts) => { process.exitCode = await runNotesGrep(query, opts); });
|
|
272
272
|
const media = notes.command("media").allowExcessArguments(false)
|
|
@@ -287,7 +287,7 @@ export function registerNotesCommand(program) {
|
|
|
287
287
|
.option("--trashed", "list the trash instead of the live files")
|
|
288
288
|
.option("--content-type <type>", "only files stored with this exact type")
|
|
289
289
|
.option("--note <ref>", "the note: slug, id or exact title")
|
|
290
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
290
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
291
291
|
.option("--json", "emit JSON")
|
|
292
292
|
.option("--limit <n>", "how many files to show")
|
|
293
293
|
.option("--offset <n>", "skip this many first")
|
|
@@ -299,7 +299,7 @@ export function registerNotesCommand(program) {
|
|
|
299
299
|
.option("--content-type <type>", "declare the type instead of letting it be inferred")
|
|
300
300
|
.option("--overwrite", "replace a file already at that path")
|
|
301
301
|
.option("--note <ref>", "the note: slug, id or exact title")
|
|
302
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
302
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
303
303
|
.option("--json", "emit JSON")
|
|
304
304
|
.action(async (local, opts) => { process.exitCode = await runFilesUpload(local, opts); });
|
|
305
305
|
strict(files.command("download"))
|
|
@@ -308,13 +308,13 @@ export function registerNotesCommand(program) {
|
|
|
308
308
|
.option("-o, --output <path>", "where to write it; '-' or omitted means stdout")
|
|
309
309
|
.option("--overwrite", "replace the local file if it exists")
|
|
310
310
|
.option("--note <ref>", "the note: slug, id or exact title")
|
|
311
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
311
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
312
312
|
.action(async (file, opts) => { process.exitCode = await runFilesDownload(file, opts); });
|
|
313
313
|
strict(files.command("cat"))
|
|
314
314
|
.argument("<file>", "file id or path within the note")
|
|
315
315
|
.description("print a text file; refuses a binary rather than mangling it")
|
|
316
316
|
.option("--note <ref>", "the note: slug, id or exact title")
|
|
317
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
317
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
318
318
|
.option("--json", "emit JSON (includes the etag)")
|
|
319
319
|
.action(async (file, opts) => { process.exitCode = await runFilesCat(file, opts); });
|
|
320
320
|
strict(files.command("write"))
|
|
@@ -327,7 +327,7 @@ export function registerNotesCommand(program) {
|
|
|
327
327
|
.option("--overwrite", "replace a file already at that path")
|
|
328
328
|
.option("--if-match <etag>", "only write if the file is still at this revision")
|
|
329
329
|
.option("--note <ref>", "the note: slug, id or exact title")
|
|
330
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
330
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
331
331
|
.option("--json", "emit JSON")
|
|
332
332
|
.action(async (p, opts) => { process.exitCode = await runFilesWrite(p, opts); });
|
|
333
333
|
strict(files.command("mv"))
|
|
@@ -337,7 +337,7 @@ export function registerNotesCommand(program) {
|
|
|
337
337
|
.option("--overwrite", "replace a file already at the destination")
|
|
338
338
|
.option("--if-match <etag>", "only move if the file is still at this revision")
|
|
339
339
|
.option("--note <ref>", "the note: slug, id or exact title")
|
|
340
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
340
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
341
341
|
.option("--json", "emit JSON")
|
|
342
342
|
.action(async (file, to, opts) => { process.exitCode = await runFilesMove(file, to, opts); });
|
|
343
343
|
strict(files.command("cp"))
|
|
@@ -347,7 +347,7 @@ export function registerNotesCommand(program) {
|
|
|
347
347
|
.option("--idempotency-key <key>", "keep one original text/copy operation for recovery")
|
|
348
348
|
.option("--overwrite", "replace a file already at the destination")
|
|
349
349
|
.option("--note <ref>", "the note: slug, id or exact title")
|
|
350
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
350
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
351
351
|
.option("--json", "emit JSON")
|
|
352
352
|
.action(async (file, to, opts) => { process.exitCode = await runFilesCopy(file, to, opts); });
|
|
353
353
|
for (const [action, description] of [
|
|
@@ -359,7 +359,7 @@ export function registerNotesCommand(program) {
|
|
|
359
359
|
.argument("<operation>", "operation ID from the original response")
|
|
360
360
|
.description(description)
|
|
361
361
|
.option("--note <ref>", "the note: slug, id or exact title")
|
|
362
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
362
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
363
363
|
.option("--json", "emit JSON")
|
|
364
364
|
.action(async (operation, opts) => { process.exitCode = await runFilesOperation(action, operation, opts); });
|
|
365
365
|
}
|
|
@@ -369,7 +369,7 @@ export function registerNotesCommand(program) {
|
|
|
369
369
|
.option("--purge", "delete the stored bytes — not recoverable")
|
|
370
370
|
.option("--if-match <etag>", "only delete if the file is still at this revision")
|
|
371
371
|
.option("--note <ref>", "the note: slug, id or exact title")
|
|
372
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
372
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
373
373
|
.option("--json", "emit JSON")
|
|
374
374
|
.action(async (file, opts) => { process.exitCode = await runFilesRm(file, opts); });
|
|
375
375
|
strict(files.command("restore"))
|
|
@@ -377,7 +377,7 @@ export function registerNotesCommand(program) {
|
|
|
377
377
|
.description("bring a file back from the trash")
|
|
378
378
|
.option("--path <path>", "restore it here instead of where it was")
|
|
379
379
|
.option("--note <ref>", "the note: slug, id or exact title")
|
|
380
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
380
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
381
381
|
.option("--json", "emit JSON")
|
|
382
382
|
.action(async (file, opts) => { process.exitCode = await runFilesRestore(file, opts); });
|
|
383
383
|
strict(files.command("preview"))
|
|
@@ -387,14 +387,14 @@ export function registerNotesCommand(program) {
|
|
|
387
387
|
.option("--revoke", "withdraw the shared link; every copy stops working")
|
|
388
388
|
.option("--open", "open the link in a browser")
|
|
389
389
|
.option("--note <ref>", "the note: slug, id or exact title")
|
|
390
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
390
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
391
391
|
.option("--json", "emit JSON")
|
|
392
392
|
.action(async (file, opts) => { process.exitCode = await runFilesPreview(file, opts); });
|
|
393
393
|
// ── notes sections ──
|
|
394
394
|
strict(notes.command("sections"))
|
|
395
395
|
.argument("<note>", "note id, slug or name")
|
|
396
396
|
.description("list the addressable sections (a heading plus everything under it)")
|
|
397
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
397
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
398
398
|
.option("--json", "emit JSON")
|
|
399
399
|
.action(async (ref, opts) => { process.exitCode = await runNotesSections(ref, opts); });
|
|
400
400
|
// ── notes read ──
|
|
@@ -422,7 +422,7 @@ export function registerNotesCommand(program) {
|
|
|
422
422
|
.option("--format <format>", "incremental format: diff (default) or inline-dff")
|
|
423
423
|
.option("--legacy", "use the previous body-only/etag interface")
|
|
424
424
|
.option("--section <anchor>", "print only this section")
|
|
425
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
425
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
426
426
|
.option("-n, --numbered", "prefix each line with its number, like `cat -n`")
|
|
427
427
|
.option("--json", "emit exact content, SHA-256 hash and opaque write revision")
|
|
428
428
|
.option("--if-match <etag>", "verify: fail unless the note is still at this revision")
|
|
@@ -436,7 +436,7 @@ export function registerNotesCommand(program) {
|
|
|
436
436
|
.option("--legacy", "use the previous diff/etag interface")
|
|
437
437
|
.requiredOption("--since <ref>", "retained content hash or time reference")
|
|
438
438
|
.option("--context <n>", "legacy unchanged context lines per hunk (0–100)")
|
|
439
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
439
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
440
440
|
.option("--json", "emit base/hash/revision and selected patch format")
|
|
441
441
|
.action(async (ref, opts) => { process.exitCode = await runNotesDiff(ref, opts); });
|
|
442
442
|
// ── notes write ──
|
|
@@ -452,7 +452,7 @@ export function registerNotesCommand(program) {
|
|
|
452
452
|
.option("--base-revision <revision>", "compare the target body to this original retained source snapshot")
|
|
453
453
|
.option("--exact", "require the original revision to remain current")
|
|
454
454
|
.option("--command-id <id>", "caller-stable id (8–128 chars of A-Za-z0-9._:-); a retry with the same id returns the same receipt")
|
|
455
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
455
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
456
456
|
.option("--json", "emit JSON")
|
|
457
457
|
.option("--dry-run", "show the write that would be sent, and send nothing")
|
|
458
458
|
.action(async (ref, opts) => { process.exitCode = await runNotesWrite(ref, opts); });
|
|
@@ -467,7 +467,7 @@ export function registerNotesCommand(program) {
|
|
|
467
467
|
.option("--base-revision <revision>", "append against this original retained source snapshot")
|
|
468
468
|
.option("--exact", "require the original revision to remain current")
|
|
469
469
|
.option("--command-id <id>", "caller-stable id (8–128 chars of A-Za-z0-9._:-); a retry with the same id returns the same receipt")
|
|
470
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
470
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
471
471
|
.option("--json", "emit JSON")
|
|
472
472
|
.option("--dry-run", "show the write that would be sent, and send nothing")
|
|
473
473
|
.action(async (ref, opts) => { process.exitCode = await runNotesAppend(ref, opts); });
|
|
@@ -484,7 +484,7 @@ export function registerNotesCommand(program) {
|
|
|
484
484
|
.option("--if-match <revision>", "compatibility exact-mode token; must match --base-revision when both are given")
|
|
485
485
|
.option("--command-id <id>", "caller-stable id (8–128 chars of A-Za-z0-9._:-); a retry with the same id returns the same receipt")
|
|
486
486
|
.option("--force", "legacy only: apply without a precondition")
|
|
487
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
487
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
488
488
|
.option("--json", "emit JSON")
|
|
489
489
|
.option("--dry-run", "show the write that would be sent, and send nothing")
|
|
490
490
|
.action(async (ref, opts) => { process.exitCode = await runNotesPatch(ref, opts); });
|
|
@@ -498,7 +498,7 @@ export function registerNotesCommand(program) {
|
|
|
498
498
|
.option("--text <string>", "the section text, inline")
|
|
499
499
|
.option("--if-match <etag>", "only insert if the note is still at this etag")
|
|
500
500
|
.option("--force", "insert without a precondition")
|
|
501
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
501
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
502
502
|
.option("--json", "emit JSON")
|
|
503
503
|
.option("--dry-run", "show the write that would be sent, and send nothing")
|
|
504
504
|
.action(async (ref, opts) => { process.exitCode = await runNotesAddSection(ref, opts); });
|
|
@@ -519,7 +519,7 @@ export function registerNotesCommand(program) {
|
|
|
519
519
|
.option("--case-sensitive", "match case for a literal query (the default)")
|
|
520
520
|
.option("--no-case-sensitive", "ignore case for a literal query")
|
|
521
521
|
.option("--json", "emit matches with note, hash and the source revision")
|
|
522
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
522
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
523
523
|
.action(async (query, opts) => { process.exitCode = await runNotesFind(query, opts); });
|
|
524
524
|
strict(notes.command("toc"))
|
|
525
525
|
.description("the note's outline, with line and character ranges")
|
|
@@ -527,7 +527,7 @@ export function registerNotesCommand(program) {
|
|
|
527
527
|
.option("--html", "parse as HTML rather than Markdown")
|
|
528
528
|
.option("--at <revision>", "outline the retained snapshot at this revision")
|
|
529
529
|
.option("--json", "emit entries with note, hash and the source revision")
|
|
530
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
530
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
531
531
|
.action(async (opts) => { process.exitCode = await runNotesToc(opts); });
|
|
532
532
|
strict(notes.command("replace"))
|
|
533
533
|
.description("replace text; one match required unless --all or --count")
|
|
@@ -552,7 +552,7 @@ export function registerNotesCommand(program) {
|
|
|
552
552
|
.option("--command-id <id>", "caller-stable id (8–128 chars of A-Za-z0-9._:-); a retry with the same id returns the same receipt")
|
|
553
553
|
.option("--dry-run", "print what would be written and stop")
|
|
554
554
|
.option("--json", "emit the new revision")
|
|
555
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
555
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
556
556
|
.option("--html <markup>", "with --selector: replace the element's contents with markup (not escaped)")
|
|
557
557
|
.action(async (query, opts) => { process.exitCode = await runNotesReplace(query, opts); });
|
|
558
558
|
strict(notes.command("insert"))
|
|
@@ -574,7 +574,7 @@ export function registerNotesCommand(program) {
|
|
|
574
574
|
.option("--command-id <id>", "caller-stable id (8–128 chars of A-Za-z0-9._:-); a retry with the same id returns the same receipt")
|
|
575
575
|
.option("--dry-run", "print what would be written and stop")
|
|
576
576
|
.option("--json", "emit the new revision")
|
|
577
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
577
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
578
578
|
.option("--selector <css>", "insert relative to this element instead of a line")
|
|
579
579
|
.option("--position <where>", "with --selector: before | after | prepend | append", "append")
|
|
580
580
|
.action(async (note, opts) => { process.exitCode = await runNotesInsert(note, opts); });
|
|
@@ -600,13 +600,13 @@ export function registerNotesCommand(program) {
|
|
|
600
600
|
.option("--command-id <id>", "caller-stable id (8–128 chars of A-Za-z0-9._:-); a retry with the same id returns the same receipt")
|
|
601
601
|
.option("--dry-run", "print what would be written and stop")
|
|
602
602
|
.option("--json", "emit the new revision")
|
|
603
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
603
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
604
604
|
.action(async (query, opts) => { process.exitCode = await runNotesDelete(query, opts); });
|
|
605
605
|
strict(notes.command("command-status"))
|
|
606
606
|
.argument("<note>", "note id, slug or name")
|
|
607
607
|
.argument("<command-id>", "the --command-id of an earlier write")
|
|
608
608
|
.description("the durable outcome of one identified write: pending, accepted, no-write or unknown")
|
|
609
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
609
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
610
610
|
.option("--json", "emit JSON")
|
|
611
611
|
.action(async (ref, commandId, opts) => { process.exitCode = await runNotesCommandStatus(ref, commandId, opts); });
|
|
612
612
|
strict(notes.command("select"))
|
|
@@ -618,7 +618,7 @@ export function registerNotesCommand(program) {
|
|
|
618
618
|
.option("--hash <sha256>", "require this current source hash before publishing")
|
|
619
619
|
.option("--note <ref>", "the note: slug, id or exact title")
|
|
620
620
|
.option("--json", "emit the selection receipt, or CSS element with source revision")
|
|
621
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
621
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
622
622
|
.action(async (css, opts) => {
|
|
623
623
|
if (opts.text !== undefined || !css || opts.section !== undefined || opts.occurrence !== undefined || opts.hash !== undefined) {
|
|
624
624
|
process.exitCode = await runNotesTextSelect(css, opts);
|
|
@@ -633,7 +633,7 @@ export function registerNotesCommand(program) {
|
|
|
633
633
|
.description("remove a section and everything under it")
|
|
634
634
|
.option("--if-match <etag>", "only remove if the note is still at this etag")
|
|
635
635
|
.option("--force", "remove without a precondition")
|
|
636
|
-
.option("--namespace <slug>", "whose notes (default:
|
|
636
|
+
.option("--namespace <slug>", "whose notes (default: selected CLI namespace, otherwise personal)")
|
|
637
637
|
.option("--json", "emit JSON")
|
|
638
638
|
.option("--dry-run", "show the write that would be sent, and send nothing")
|
|
639
639
|
.action(async (ref, anchor, opts) => { process.exitCode = await runNotesRmSection(ref, anchor, opts); });
|
|
@@ -670,9 +670,7 @@ export async function runNotesList(opts) {
|
|
|
670
670
|
if (opts.json)
|
|
671
671
|
return emitJson({ notes: rows }), 0;
|
|
672
672
|
if (rows.length === 0) {
|
|
673
|
-
//
|
|
674
|
-
// one, and an org's notes live somewhere else entirely — a bare "no
|
|
675
|
-
// notes" reads as "there are none" when it means "none here".
|
|
673
|
+
// Always name the effective namespace, including a persisted `su` selection.
|
|
676
674
|
process.stdout.write(opts.shared
|
|
677
675
|
? "no notes shared with you\n"
|
|
678
676
|
: `no notes in '${c.ns}'\n an organization's notes are in its own namespace — ` +
|
package/dist/cli/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.102.0";
|
package/dist/cli/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreamlake/dreamlake-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.102.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dreamlake-ai/dreamlake-cli.git"
|
|
@@ -29,19 +29,20 @@
|
|
|
29
29
|
"aws4fetch": "^1.0.20",
|
|
30
30
|
"commander": "^12.1.0",
|
|
31
31
|
"ws": "^8.22.0",
|
|
32
|
+
"ws-transport": "npm:ws@8.22.0",
|
|
32
33
|
"yaml": "^2.6.1"
|
|
33
34
|
},
|
|
34
35
|
"engines": {
|
|
35
36
|
"node": ">=18"
|
|
36
37
|
},
|
|
37
38
|
"optionalDependencies": {
|
|
38
|
-
"@dreamlake/dreamlake-cli-darwin-arm64": "0.
|
|
39
|
-
"@dreamlake/dreamlake-cli-darwin-x64": "0.
|
|
40
|
-
"@dreamlake/dreamlake-cli-linux-x64": "0.
|
|
41
|
-
"@dreamlake/dreamlake-cli-linux-arm64": "0.
|
|
42
|
-
"@dreamlake/dreamlake-cli-linux-x64-musl": "0.
|
|
43
|
-
"@dreamlake/dreamlake-cli-linux-arm64-musl": "0.
|
|
44
|
-
"@dreamlake/dreamlake-cli-win32-x64": "0.
|
|
45
|
-
"@dreamlake/dreamlake-cli-win32-arm64": "0.
|
|
39
|
+
"@dreamlake/dreamlake-cli-darwin-arm64": "0.102.0",
|
|
40
|
+
"@dreamlake/dreamlake-cli-darwin-x64": "0.102.0",
|
|
41
|
+
"@dreamlake/dreamlake-cli-linux-x64": "0.102.0",
|
|
42
|
+
"@dreamlake/dreamlake-cli-linux-arm64": "0.102.0",
|
|
43
|
+
"@dreamlake/dreamlake-cli-linux-x64-musl": "0.102.0",
|
|
44
|
+
"@dreamlake/dreamlake-cli-linux-arm64-musl": "0.102.0",
|
|
45
|
+
"@dreamlake/dreamlake-cli-win32-x64": "0.102.0",
|
|
46
|
+
"@dreamlake/dreamlake-cli-win32-arm64": "0.102.0"
|
|
46
47
|
}
|
|
47
48
|
}
|