@dreamlake/dreamlake-cli 0.92.0 → 0.93.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/cli/help-examples.generated.js +2 -2
- package/dist/cli/skill/index.d.ts +30 -1
- package/dist/cli/skill/index.js +261 -103
- package/dist/cli/skill/manifest.d.ts +6 -0
- package/dist/cli/skill/manifest.js +15 -0
- package/dist/cli/skill/prefs.d.ts +6 -0
- package/dist/cli/skill/prefs.js +21 -4
- package/dist/cli/version.d.ts +1 -1
- package/dist/cli/version.js +1 -1
- package/package.json +9 -9
|
@@ -177,10 +177,10 @@ export const helpExamples = {
|
|
|
177
177
|
"sessions chat": "dreamlake sessions chat \"Which of my sessions need attention?\"\n# Allow lifecycle and messaging tools this turn:\ndreamlake sessions chat --control \"Send 'rebase on main' to the two Claude sessions working on notes\"",
|
|
178
178
|
"sessions tool-calls": "dreamlake sessions tool-calls <conversation-id>",
|
|
179
179
|
"dreamlake": "# Guided agent setup: choose agent and scope, install dreamlake-cli offline\ndreamlake init\n# Install more skills from the public release\ndreamlake skill install dreamlake-notes\n# Keep installed skills current\ndreamlake skill update",
|
|
180
|
-
"init": "dreamlake init\ndreamlake init --agent codex\ndreamlake init --agent claude --global",
|
|
180
|
+
"init": "dreamlake init\ndreamlake init --agent codex\ndreamlake init --agent claude --global\n# Claude Code and Codex: one copy in each agent's directory\ndreamlake init --agent all --global",
|
|
181
181
|
"skill": "dreamlake skill list\ndreamlake skill install dreamlake-notes\ndreamlake skill update\ndreamlake skill remove dreamlake-notes",
|
|
182
182
|
"skill list": "dreamlake skill list\n# Fetch the latest catalog and show it next to the installed versions\ndreamlake skill list --refresh\ndreamlake skill list --agent codex --json",
|
|
183
|
-
"skill install": "# The embedded dreamlake-cli skill; offline when it matches the release\ndreamlake skill install dreamlake-cli\n# A catalog skill plus whatever it requires, from the latest release\ndreamlake skill install dreamlake-notes --agent codex\n# Replace files you edited with the release copies\ndreamlake skill install dreamlake-notes --force",
|
|
183
|
+
"skill install": "# The embedded dreamlake-cli skill; offline when it matches the release\ndreamlake skill install dreamlake-cli\n# A catalog skill plus whatever it requires, from the latest release\ndreamlake skill install dreamlake-notes --agent codex\n# One copy for Claude Code and one for Codex\ndreamlake skill install dreamlake-notes --agent all --global\n# Replace files you edited with the release copies\ndreamlake skill install dreamlake-notes --force",
|
|
184
184
|
"skill update": "# Every skill with a manifest in the selected scope\ndreamlake skill update\ndreamlake skill update dreamlake-cli --global\n# Overwrite edited files; retired files you edited are still kept\ndreamlake skill update dreamlake-notes --force\n# Go back to an older release, or replace a copy whose version cannot be ordered\ndreamlake skill update dreamlake-notes --allow-downgrade",
|
|
185
185
|
"skill remove": "dreamlake skill remove dreamlake-notes\ndreamlake skill remove dreamlake-notes --agent codex --global --json",
|
|
186
186
|
"vault cloud import": "# No --file: list standard candidate paths without opening their contents.\ndreamlake vault cloud import --provider aws -p alice/aws/dev\n# Explicit selections: preview names, sizes and profile metadata, without upload.\ndreamlake vault cloud import --provider aws -p alice/aws/dev \\\n --file \"$HOME/.aws/config\" --file \"$HOME/.aws/credentials\"\n# Repeat the selection with --apply to upload.\ndreamlake vault cloud import --provider aws -p alice/aws/dev \\\n --file \"$HOME/.aws/config\" --file \"$HOME/.aws/credentials\" --apply\ndreamlake vault cloud import --provider gcp -p alice/gcp/dev \\\n --file /private/config/service-account.json --apply",
|
|
@@ -41,6 +41,8 @@ export type SkillState =
|
|
|
41
41
|
export interface SkillResult {
|
|
42
42
|
status: SkillInstallStatus;
|
|
43
43
|
skill: string;
|
|
44
|
+
/** Which agent's copy this is. Set only when the run targets more than one agent. */
|
|
45
|
+
agent?: SkillAgent;
|
|
44
46
|
/** Release tag the payload came from; null when the source carries none. */
|
|
45
47
|
version: string | null;
|
|
46
48
|
source: SkillSourceKind | null;
|
|
@@ -79,7 +81,10 @@ export interface SkillCatalogInfo {
|
|
|
79
81
|
/** The result of `install`, `update` and `init`. */
|
|
80
82
|
export interface SkillInstallResult {
|
|
81
83
|
status: SkillInstallStatus;
|
|
84
|
+
/** The agent, when the run targets exactly one. */
|
|
82
85
|
agent?: SkillAgent;
|
|
86
|
+
/** Every agent, when the run targets more than one; `agent` is then absent. */
|
|
87
|
+
agents?: SkillAgent[];
|
|
83
88
|
scope?: SkillScope;
|
|
84
89
|
catalog?: SkillCatalogInfo;
|
|
85
90
|
/** One entry per skill, requested ones first, then `requires`. */
|
|
@@ -101,6 +106,14 @@ export interface SkillInstallResult {
|
|
|
101
106
|
export interface SkillRemoveResult {
|
|
102
107
|
status: SkillRemoveStatus;
|
|
103
108
|
agent?: SkillAgent;
|
|
109
|
+
/** Every agent, when the run targets more than one; `agent` and `target` are then absent. */
|
|
110
|
+
agents?: SkillAgent[];
|
|
111
|
+
/**
|
|
112
|
+
* Multi-agent only: one single-agent result per agent the skill was found
|
|
113
|
+
* under. An agent where the skill is absent is skipped, unless it is absent
|
|
114
|
+
* under every agent — then each absence is an error here.
|
|
115
|
+
*/
|
|
116
|
+
removals?: SkillRemoveResult[];
|
|
104
117
|
scope?: SkillScope;
|
|
105
118
|
skill?: string;
|
|
106
119
|
target?: string;
|
|
@@ -171,6 +184,20 @@ export interface SkillInstallOptions {
|
|
|
171
184
|
allowDowngrade?: boolean;
|
|
172
185
|
json?: boolean;
|
|
173
186
|
}
|
|
187
|
+
/** One agent's installed state for a list row. */
|
|
188
|
+
export interface SkillAgentInstalls {
|
|
189
|
+
project: SkillScopeState;
|
|
190
|
+
global: SkillScopeState;
|
|
191
|
+
}
|
|
192
|
+
/** A list row when more than one agent is selected: `installs` replaces `project` and `global`. */
|
|
193
|
+
export interface SkillMultiListEntry extends Omit<SkillListEntry, "project" | "global"> {
|
|
194
|
+
installs: Partial<Record<SkillAgent, SkillAgentInstalls>>;
|
|
195
|
+
}
|
|
196
|
+
/** `skill list` when more than one agent is selected. */
|
|
197
|
+
export interface SkillMultiListResult extends Omit<SkillListResult, "agent" | "skills"> {
|
|
198
|
+
agents: SkillAgent[];
|
|
199
|
+
skills?: SkillMultiListEntry[];
|
|
200
|
+
}
|
|
174
201
|
export interface SkillListOptions {
|
|
175
202
|
agent?: string;
|
|
176
203
|
refresh?: boolean;
|
|
@@ -199,6 +226,7 @@ export declare function skillTarget(scopeRoot: string, name: string, agent?: Ski
|
|
|
199
226
|
* checked against it, never against a fresh resolution.
|
|
200
227
|
*/
|
|
201
228
|
export declare function ownedTarget(dir: string, name: string): OwnedDir;
|
|
229
|
+
export declare const AGENT_ERROR = "--agent must be claude, codex, all, or a comma-separated list of them";
|
|
202
230
|
/** The command that would resolve the current invocation, `--force` and `--allow-downgrade` optional. */
|
|
203
231
|
export declare function skillCommand(verb: "install" | "update" | "remove", names: string | string[], opts: SkillInstallOptions, force: boolean, allowDowngrade?: boolean): string;
|
|
204
232
|
export declare function installCommand(skill: string | string[], opts: SkillInstallOptions, force: boolean): string;
|
|
@@ -261,7 +289,8 @@ export declare function installedSkillEntries(agent: SkillAgent, options?: ListE
|
|
|
261
289
|
export declare function runSkillList(opts: SkillListOptions): Promise<number>;
|
|
262
290
|
export interface SkillInitIO {
|
|
263
291
|
interactive: boolean;
|
|
264
|
-
agent
|
|
292
|
+
/** One agent, or several to install for each of them. */
|
|
293
|
+
agent(): Promise<SkillAgent | SkillAgent[]>;
|
|
265
294
|
global(): Promise<boolean>;
|
|
266
295
|
}
|
|
267
296
|
export declare function runSkillInit(opts: SkillInstallOptions, io?: SkillInitIO): Promise<number>;
|
package/dist/cli/skill/index.js
CHANGED
|
@@ -11,6 +11,15 @@ import { collectionList } from "../collection-list.js";
|
|
|
11
11
|
// `<skill>/.dreamlake-skill.json` so `update` and `remove` never have to
|
|
12
12
|
// guess which files are theirs. Manual install is unpacking the same tarball.
|
|
13
13
|
//
|
|
14
|
+
// ONE AGENT OR SEVERAL. `--agent` (and what `init` saved) may name both
|
|
15
|
+
// agents — `all` or `claude,codex`. Each agent's copy is a separate install
|
|
16
|
+
// with its own manifest; a multi-agent run plans and applies them one by one
|
|
17
|
+
// from one catalog and one download. With exactly one agent every result is
|
|
18
|
+
// the single-agent shape, unchanged: `remindAfterInstall` reads it across CLI
|
|
19
|
+
// versions. Several agents add `agents` (and drop the top-level `agent`), tag
|
|
20
|
+
// each skill result with its `agent`, and give `remove` and `list` their own
|
|
21
|
+
// per-agent shapes (`removals`, `installs`).
|
|
22
|
+
//
|
|
14
23
|
// THREE THINGS THIS MUST NEVER DO, each from a real hazard in this tree:
|
|
15
24
|
//
|
|
16
25
|
// 0. Every write, unlink, mkdir and rmdir goes through the owned-path
|
|
@@ -47,8 +56,8 @@ import path from "node:path";
|
|
|
47
56
|
import { emitJson, fail, ok, warn } from "../helpers.js";
|
|
48
57
|
import { EMBEDDED_SKILL, ReleaseError, SKILLS_ENV, catalogFileCount, catalogUrl, compareVersions, embeddedCatalog, embeddedPayload, embeddedVersion, extractSkills, fetchLatestCatalog, fetchSkillsTarball, fmtVersion, listBundledSkills, manualDownloadUrl, resolveBundleDir, bundledFiles, versionsEqual, } from "./catalog.js";
|
|
49
58
|
import { hashFile, hasSymlinkAncestor, isDirectChild, kindOf, listDir, pinOwnedDir, pruneEmptyDirs, resolveExisting, sha256, unlinkOwnedFile, writeOwnedFile, } from "./files.js";
|
|
50
|
-
import { MANIFEST_FILE,
|
|
51
|
-
import { readSkillPreferences, writeSkillPreferences } from "./prefs.js";
|
|
59
|
+
import { AGENTS, MANIFEST_FILE, parseAgents, readManifest, writeManifest, } from "./manifest.js";
|
|
60
|
+
import { preferredAgents, readSkillPreferences, skillPreferences, writeSkillPreferences, } from "./prefs.js";
|
|
52
61
|
export { listBundledSkills, resolveBundleDir } from "./catalog.js";
|
|
53
62
|
// ─── names ───────────────────────────────────────────────────────────────────
|
|
54
63
|
//
|
|
@@ -106,11 +115,31 @@ export function skillTarget(scopeRoot, name, agent = "claude") {
|
|
|
106
115
|
export function ownedTarget(dir, name) {
|
|
107
116
|
return pinOwnedDir(targetIn(dir, name));
|
|
108
117
|
}
|
|
118
|
+
// ─── selection: agent and scope ──────────────────────────────────────────────
|
|
119
|
+
//
|
|
120
|
+
// Flags win; otherwise what `dreamlake init` saved; otherwise claude/project
|
|
121
|
+
// with a one-line hint. `--dir` beats `--project` beats `--global`.
|
|
122
|
+
export const AGENT_ERROR = "--agent must be claude, codex, all, or a comma-separated list of them";
|
|
123
|
+
function isMulti(sel) {
|
|
124
|
+
return sel.targets.length > 1;
|
|
125
|
+
}
|
|
126
|
+
/** `agent` for one agent, `agents` for several: the only difference at the top of a result. */
|
|
127
|
+
function agentFields(sel) {
|
|
128
|
+
return isMulti(sel) ? { agents: sel.agents } : { agent: sel.agents[0] };
|
|
129
|
+
}
|
|
130
|
+
function agentsLabel(sel) {
|
|
131
|
+
return [isMulti(sel) ? "agents" : "agent", `${sel.agents.join(", ")}${sel.saved ? " (saved)" : ""}`];
|
|
132
|
+
}
|
|
133
|
+
/** The options of a multi-agent run, narrowed to one agent for a command that concerns only its copy. */
|
|
134
|
+
function forAgent(opts, agent) {
|
|
135
|
+
return { ...opts, agent };
|
|
136
|
+
}
|
|
109
137
|
function selectTarget(opts) {
|
|
110
|
-
|
|
111
|
-
|
|
138
|
+
const flagged = opts.agent !== undefined ? parseAgents(opts.agent) : null;
|
|
139
|
+
if (opts.agent !== undefined && !flagged)
|
|
140
|
+
return { error: AGENT_ERROR };
|
|
112
141
|
const prefs = readSkillPreferences();
|
|
113
|
-
const
|
|
142
|
+
const agents = flagged ?? (prefs ? preferredAgents(prefs) : ["claude"]);
|
|
114
143
|
const o = opts;
|
|
115
144
|
let scope;
|
|
116
145
|
let root;
|
|
@@ -131,7 +160,8 @@ function selectTarget(opts) {
|
|
|
131
160
|
root = process.cwd();
|
|
132
161
|
}
|
|
133
162
|
return {
|
|
134
|
-
|
|
163
|
+
agents, scope, root,
|
|
164
|
+
targets: agents.map((agent) => ({ agent, dir: skillsDir(root, agent) })),
|
|
135
165
|
saved: prefs !== null && opts.agent === undefined,
|
|
136
166
|
hint: prefs === null && opts.agent === undefined,
|
|
137
167
|
};
|
|
@@ -139,7 +169,7 @@ function selectTarget(opts) {
|
|
|
139
169
|
function printHint(sel, opts) {
|
|
140
170
|
if (!sel.hint || opts.json)
|
|
141
171
|
return;
|
|
142
|
-
process.stderr.write(` hint: no saved agent — using ${sel.
|
|
172
|
+
process.stderr.write(` hint: no saved agent — using ${sel.agents.join(", ")}, ${sel.scope}; run 'dreamlake init' once to remember your choice\n`);
|
|
143
173
|
}
|
|
144
174
|
// ─── prose ───────────────────────────────────────────────────────────────────
|
|
145
175
|
//
|
|
@@ -176,6 +206,24 @@ export function skillCommand(verb, names, opts, force, allowDowngrade = false) {
|
|
|
176
206
|
export function installCommand(skill, opts, force) {
|
|
177
207
|
return skillCommand("install", skill, opts, force);
|
|
178
208
|
}
|
|
209
|
+
/**
|
|
210
|
+
* Plan and apply one payload into one agent's directory. In a multi-agent run
|
|
211
|
+
* the result carries its `agent`, and any command it suggests names only that
|
|
212
|
+
* agent; with one agent it is exactly the single-agent result.
|
|
213
|
+
*/
|
|
214
|
+
function applyTo(sel, target, payload, verb, opts, requiredBy) {
|
|
215
|
+
const owned = ownedTarget(target.dir, payload.name);
|
|
216
|
+
const force = Boolean(opts.force);
|
|
217
|
+
const allowDowngrade = Boolean(opts.allowDowngrade);
|
|
218
|
+
const plan = verb === "install"
|
|
219
|
+
? planInstall(payload, owned.skillDir, force, allowDowngrade)
|
|
220
|
+
: planUpdate(payload, owned.skillDir, force, allowDowngrade);
|
|
221
|
+
const multi = isMulti(sel);
|
|
222
|
+
const result = applyPlan(payload, owned, plan, {
|
|
223
|
+
agent: target.agent, scope: sel.scope, dir: target.dir, verb, opts: multi ? forAgent(opts, target.agent) : opts, requiredBy,
|
|
224
|
+
});
|
|
225
|
+
return multi ? { ...result, agent: target.agent } : result;
|
|
226
|
+
}
|
|
179
227
|
/** The one error exit: prose to stderr, or folded into --json. */
|
|
180
228
|
function reject(opts, message, kind, nextAction = null, base) {
|
|
181
229
|
if (opts.json) {
|
|
@@ -684,16 +732,29 @@ function printSkillResult(r, width, verb) {
|
|
|
684
732
|
function printRun(verb, requested, sel, ctx, results, opts) {
|
|
685
733
|
process.stdout.write(`${verb === "init" ? "init" : `skill ${verb}`} ${requested.join(" ")}\n`);
|
|
686
734
|
header([
|
|
687
|
-
|
|
735
|
+
agentsLabel(sel),
|
|
688
736
|
["scope", sel.scope === "dir" ? `dir ${sel.root}` : sel.scope],
|
|
689
737
|
["catalog", catalogLine(info(ctx))],
|
|
690
738
|
]);
|
|
691
739
|
const width = Math.max(...results.map((r) => r.skill.length), 1);
|
|
692
|
-
|
|
693
|
-
|
|
740
|
+
const skillVerb = verb === "update" ? "update" : "install";
|
|
741
|
+
if (isMulti(sel)) {
|
|
742
|
+
for (const t of sel.targets) {
|
|
743
|
+
const mine = results.filter((r) => r.agent === t.agent);
|
|
744
|
+
if (mine.length === 0)
|
|
745
|
+
continue;
|
|
746
|
+
process.stdout.write(`\n ${t.agent} ${t.dir}\n`);
|
|
747
|
+
for (const r of mine)
|
|
748
|
+
printSkillResult(r, width, skillVerb);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
for (const r of results)
|
|
753
|
+
printSkillResult(r, width, skillVerb);
|
|
754
|
+
}
|
|
694
755
|
const conflicts = results.filter((r) => r.status === "conflict" && r.nextAction?.kind === "run");
|
|
695
756
|
if (conflicts.length > 0) {
|
|
696
|
-
const cmd =
|
|
757
|
+
const cmd = forceCommand(skillVerb, conflicts, opts);
|
|
697
758
|
process.stderr.write(`\n overwrite ${conflicts.length > 1 ? "them" : "it"} with:\n ${cmd}\n`);
|
|
698
759
|
}
|
|
699
760
|
for (const r of results) {
|
|
@@ -701,10 +762,16 @@ function printRun(verb, requested, sel, ctx, results, opts) {
|
|
|
701
762
|
process.stderr.write(`\n next: ${r.nextAction.command}\n`);
|
|
702
763
|
}
|
|
703
764
|
}
|
|
765
|
+
/** `--force` for every conflicting skill, narrowed to one agent when only that agent's copies conflict. */
|
|
766
|
+
function forceCommand(verb, conflicts, opts) {
|
|
767
|
+
const names = [...new Set(conflicts.map((r) => r.skill))];
|
|
768
|
+
const agents = [...new Set(conflicts.flatMap((r) => (r.agent ? [r.agent] : [])))];
|
|
769
|
+
return skillCommand(verb, names, agents.length === 1 ? forAgent(opts, agents[0]) : opts, true);
|
|
770
|
+
}
|
|
704
771
|
function runNextAction(verb, results, opts) {
|
|
705
772
|
const conflicts = results.filter((r) => r.status === "conflict" && r.nextAction?.kind === "run");
|
|
706
773
|
if (conflicts.length > 0)
|
|
707
|
-
return { kind: "run", command:
|
|
774
|
+
return { kind: "run", command: forceCommand(verb, conflicts, opts) };
|
|
708
775
|
const errored = results.find((r) => r.status === "error" && r.nextAction);
|
|
709
776
|
if (errored)
|
|
710
777
|
return errored.nextAction;
|
|
@@ -738,16 +805,11 @@ export async function runSkillInstall(names, opts, internal = {}) {
|
|
|
738
805
|
}
|
|
739
806
|
printHint(sel, opts);
|
|
740
807
|
const resolved = await resolvePayloads(requested, ctx, bundleDir);
|
|
741
|
-
const common = {
|
|
808
|
+
const common = { ...agentFields(sel), scope: sel.scope, catalog: info(ctx) };
|
|
742
809
|
if (isRejection(resolved))
|
|
743
810
|
return reject(opts, resolved.message, resolved.kind, resolved.nextAction, common);
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
const plan = planInstall(payload, owned.skillDir, Boolean(opts.force), Boolean(opts.allowDowngrade));
|
|
747
|
-
return applyPlan(payload, owned, plan, {
|
|
748
|
-
agent: sel.agent, scope: sel.scope, dir: sel.dir, verb: "install", opts, requiredBy: resolved.requiredBy.get(payload.name),
|
|
749
|
-
});
|
|
750
|
-
});
|
|
811
|
+
// One catalog, one download; each agent's copy is planned and applied on its own.
|
|
812
|
+
const results = sel.targets.flatMap((target) => resolved.payloads.map((payload) => applyTo(sel, target, payload, "install", opts, resolved.requiredBy.get(payload.name))));
|
|
751
813
|
const status = aggregate(results);
|
|
752
814
|
const result = {
|
|
753
815
|
status,
|
|
@@ -780,7 +842,7 @@ function catalogOthers(catalog, exclude) {
|
|
|
780
842
|
}
|
|
781
843
|
function printInitFooter(result) {
|
|
782
844
|
const prefs = result.preferences;
|
|
783
|
-
process.stdout.write(` saved ${prefs.
|
|
845
|
+
process.stdout.write(` saved ${preferredAgents(prefs).join(" and ")}, ${prefs.scope} as the default for 'dreamlake skill' → ${prefs.path}\n`);
|
|
784
846
|
const others = result.available ?? [];
|
|
785
847
|
if (others.length === 0)
|
|
786
848
|
return;
|
|
@@ -820,10 +882,21 @@ export async function runSkillUpdate(names, opts) {
|
|
|
820
882
|
if (bad !== null)
|
|
821
883
|
return reject(opts, invalidNameMessage(bad), "invalid-name");
|
|
822
884
|
printHint(sel, opts);
|
|
823
|
-
|
|
885
|
+
// What each agent updates: the names given, or every skill with a manifest
|
|
886
|
+
// in its directory. With several agents, a named skill that is absent under
|
|
887
|
+
// one of them is skipped there — unless it is absent under all of them,
|
|
888
|
+
// which is reported per agent as `not-installed`.
|
|
889
|
+
const perAgent = new Map(sel.targets.map((t) => {
|
|
890
|
+
if (names.length === 0)
|
|
891
|
+
return [t.agent, managedSkills(t.dir)];
|
|
892
|
+
if (!isMulti(sel))
|
|
893
|
+
return [t.agent, names];
|
|
894
|
+
return [t.agent, names.filter((name) => kindOf(targetIn(t.dir, name)) !== "absent" || sel.targets.every((o) => kindOf(targetIn(o.dir, name)) === "absent"))];
|
|
895
|
+
}));
|
|
896
|
+
const requested = names.length > 0 ? names : [...new Set([...perAgent.values()].flat())].sort();
|
|
824
897
|
const bundleDir = resolveBundleDir();
|
|
825
898
|
const ctx = await loadCatalog(bundleDir, false);
|
|
826
|
-
const common = {
|
|
899
|
+
const common = { ...agentFields(sel), scope: sel.scope, catalog: info(ctx) };
|
|
827
900
|
if (requested.length === 0) {
|
|
828
901
|
const result = { status: "exists", ...common, skills: [], nextAction: { kind: "run", command: "dreamlake skill list" } };
|
|
829
902
|
if (opts.json) {
|
|
@@ -831,8 +904,8 @@ export async function runSkillUpdate(names, opts) {
|
|
|
831
904
|
return 0;
|
|
832
905
|
}
|
|
833
906
|
process.stdout.write(`skill update\n`);
|
|
834
|
-
header([["agent", sel.
|
|
835
|
-
warn(`no installed skills with a manifest under ${sel.dir}`);
|
|
907
|
+
header([[isMulti(sel) ? "agents" : "agent", sel.agents.join(", ")], ["scope", sel.scope === "dir" ? `dir ${sel.root}` : sel.scope]]);
|
|
908
|
+
warn(`no installed skills with a manifest under ${sel.targets.map((t) => t.dir).join(" or ")}`);
|
|
836
909
|
process.stdout.write(`\n next: dreamlake skill list\n`);
|
|
837
910
|
return 0;
|
|
838
911
|
}
|
|
@@ -841,14 +914,16 @@ export async function runSkillUpdate(names, opts) {
|
|
|
841
914
|
// planUpdate's guard). A skill installed from the release is updated from
|
|
842
915
|
// the release or not at all.
|
|
843
916
|
if (ctx.origin !== "release") {
|
|
844
|
-
const fromRelease = requested.filter((name) => {
|
|
917
|
+
const fromRelease = requested.filter((name) => sel.targets.some((t) => {
|
|
918
|
+
if (!perAgent.get(t.agent).includes(name))
|
|
919
|
+
return false;
|
|
845
920
|
try {
|
|
846
|
-
return readManifest(targetIn(
|
|
921
|
+
return readManifest(targetIn(t.dir, name))?.source === "catalog";
|
|
847
922
|
}
|
|
848
923
|
catch {
|
|
849
924
|
return false; // An invalid manifest is reported by planUpdate.
|
|
850
925
|
}
|
|
851
|
-
});
|
|
926
|
+
}));
|
|
852
927
|
if (fromRelease.length > 0) {
|
|
853
928
|
const why = ctx.unreachable ? `cannot reach the skills release (${ctx.unreachable})` : "this build has no catalog and the release was not consulted";
|
|
854
929
|
return reject(opts, `${why} — ${fromRelease.join(", ")} ${fromRelease.length > 1 ? "were" : "was"} installed from the release and can only be updated from it`, "catalog-unreachable", { kind: "download", url: manualDownloadUrl() }, common);
|
|
@@ -858,11 +933,11 @@ export async function runSkillUpdate(names, opts) {
|
|
|
858
933
|
if (isRejection(resolved))
|
|
859
934
|
return reject(opts, resolved.message, resolved.kind, resolved.nextAction, common);
|
|
860
935
|
// `update` touches what was named (or installed); `requires` are not pulled in.
|
|
861
|
-
const
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
936
|
+
const results = sel.targets.flatMap((target) => {
|
|
937
|
+
const mine = perAgent.get(target.agent);
|
|
938
|
+
return resolved.payloads
|
|
939
|
+
.filter((p) => mine.includes(p.name))
|
|
940
|
+
.map((payload) => applyTo(sel, target, payload, "update", opts));
|
|
866
941
|
});
|
|
867
942
|
const status = aggregate(results);
|
|
868
943
|
const result = {
|
|
@@ -888,34 +963,67 @@ export async function runSkillRemove(name, opts) {
|
|
|
888
963
|
if (!isSkillName(name))
|
|
889
964
|
return reject(opts, invalidNameMessage(name), "invalid-name");
|
|
890
965
|
printHint(sel, opts);
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
if (
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
966
|
+
if (!isMulti(sel)) {
|
|
967
|
+
const { result, source } = removeFrom(sel, sel.targets[0], name);
|
|
968
|
+
if (opts.json)
|
|
969
|
+
emitJson(result);
|
|
970
|
+
else if (result.status === "error")
|
|
971
|
+
printRemoveError(result);
|
|
972
|
+
else
|
|
973
|
+
printRemoved(sel, result, source);
|
|
974
|
+
return result.status === "removed" ? 0 : 1;
|
|
975
|
+
}
|
|
976
|
+
// Several agents: remove each copy that is there. Absent under some agents
|
|
977
|
+
// is fine; absent under all of them is the single-agent not-installed error, per agent.
|
|
978
|
+
const all = sel.targets.map((t) => removeFrom(sel, t, name));
|
|
979
|
+
const found = all.filter((r) => r.result.kind !== "not-installed");
|
|
980
|
+
const outcomes = found.length > 0 ? found : all;
|
|
981
|
+
const removals = outcomes.map((o) => o.result);
|
|
982
|
+
const failed = removals.find((r) => r.status === "error");
|
|
983
|
+
const result = {
|
|
984
|
+
status: failed ? "error" : "removed",
|
|
985
|
+
agents: sel.agents,
|
|
986
|
+
scope: sel.scope,
|
|
987
|
+
skill: name,
|
|
988
|
+
removals,
|
|
989
|
+
nextAction: failed?.nextAction ?? null,
|
|
990
|
+
...(failed ? { error: failed.error, kind: failed.kind } : {}),
|
|
904
991
|
};
|
|
992
|
+
if (opts.json) {
|
|
993
|
+
emitJson(result);
|
|
994
|
+
}
|
|
995
|
+
else {
|
|
996
|
+
for (const [i, { result: r, source }] of outcomes.entries()) {
|
|
997
|
+
if (i > 0)
|
|
998
|
+
process.stdout.write("\n");
|
|
999
|
+
if (r.status === "error")
|
|
1000
|
+
printRemoveError(r);
|
|
1001
|
+
else
|
|
1002
|
+
printRemoved(sel, r, source);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
return failed ? 1 : 0;
|
|
1006
|
+
}
|
|
1007
|
+
/** Remove one agent's copy. Writes nothing to stdout or stderr; the caller reports. */
|
|
1008
|
+
function removeFrom(sel, t, name) {
|
|
1009
|
+
const owned = ownedTarget(t.dir, name);
|
|
1010
|
+
const target = owned.skillDir;
|
|
1011
|
+
const base = { status: "removed", agent: t.agent, scope: sel.scope, skill: name, target, nextAction: null };
|
|
1012
|
+
const rejected = (message, kind, nextAction = null) => ({ result: { ...base, status: "error", error: message, kind, nextAction } });
|
|
905
1013
|
const kind = kindOf(target);
|
|
906
1014
|
if (kind === "absent")
|
|
907
|
-
return
|
|
1015
|
+
return rejected(`${name} is not installed at ${target}`, "not-installed", { kind: "run", command: "dreamlake skill list" });
|
|
908
1016
|
if (kind !== "dir")
|
|
909
|
-
return
|
|
1017
|
+
return rejected(`${target} exists and is not a directory — nothing to remove safely`, "not-a-directory");
|
|
910
1018
|
let manifest;
|
|
911
1019
|
try {
|
|
912
1020
|
manifest = readManifest(target);
|
|
913
1021
|
}
|
|
914
1022
|
catch (err) {
|
|
915
|
-
return
|
|
1023
|
+
return rejected(`${err.file}: ${err.message}`, "invalid-manifest");
|
|
916
1024
|
}
|
|
917
1025
|
if (!manifest) {
|
|
918
|
-
return
|
|
1026
|
+
return rejected(`${target} has no ${MANIFEST_FILE} — it was not installed by dreamlake, so delete it yourself if you want it gone`, "unmanaged");
|
|
919
1027
|
}
|
|
920
1028
|
// Only a manifest-listed regular file whose hash still matches is deleted.
|
|
921
1029
|
// Everything else — an edited file, a file the manifest never listed, a
|
|
@@ -939,35 +1047,33 @@ export async function runSkillRemove(name, opts) {
|
|
|
939
1047
|
pruneEmptyDirs(owned, "x", true);
|
|
940
1048
|
}
|
|
941
1049
|
catch (err) {
|
|
942
|
-
|
|
943
|
-
if (opts.json)
|
|
944
|
-
emitJson(result);
|
|
945
|
-
else
|
|
946
|
-
fail(result.error);
|
|
947
|
-
return 1;
|
|
1050
|
+
return { result: { ...base, status: "error", version: manifest.version, deleted, error: `cannot remove from ${target}: ${err.message}`, kind: "remove-failed", nextAction: null } };
|
|
948
1051
|
}
|
|
949
1052
|
const kept = kindOf(target) === "dir" ? localExtras(target, new Set()) : [];
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
1053
|
+
return { result: { ...base, status: "removed", version: manifest.version, deleted, kept, nextAction: null }, source: manifest.source };
|
|
1054
|
+
}
|
|
1055
|
+
function printRemoveError(r) {
|
|
1056
|
+
fail(r.error);
|
|
1057
|
+
if (r.nextAction?.kind === "run")
|
|
1058
|
+
process.stderr.write(`\n next: ${r.nextAction.command}\n`);
|
|
1059
|
+
}
|
|
1060
|
+
function printRemoved(sel, r, source) {
|
|
1061
|
+
process.stdout.write(`skill remove ${r.skill}\n`);
|
|
956
1062
|
header([
|
|
957
|
-
["agent", `${
|
|
1063
|
+
["agent", `${r.agent}${sel.saved ? " (saved)" : ""}`],
|
|
958
1064
|
["scope", sel.scope === "dir" ? `dir ${sel.root}` : sel.scope],
|
|
959
|
-
["target", target],
|
|
1065
|
+
["target", r.target],
|
|
960
1066
|
]);
|
|
961
|
-
ok(`removed ${deleted.length} file(s) of ${
|
|
1067
|
+
ok(`removed ${r.deleted.length} file(s) of ${source} ${fmtVersion(r.version ?? null)}`);
|
|
1068
|
+
const kept = r.kept ?? [];
|
|
962
1069
|
if (kept.length > 0) {
|
|
963
1070
|
warn(`${kept.length} file(s) kept — edited, or not part of this skill:`);
|
|
964
1071
|
for (const rel of kept)
|
|
965
1072
|
process.stdout.write(` · ${rel}\n`);
|
|
966
1073
|
if (kept.includes("SKILL.md")) {
|
|
967
|
-
warn(`SKILL.md was kept, so the agent still discovers this skill — delete ${target} yourself to remove it fully`);
|
|
1074
|
+
warn(`SKILL.md was kept, so the agent still discovers this skill — delete ${r.target} yourself to remove it fully`);
|
|
968
1075
|
}
|
|
969
1076
|
}
|
|
970
|
-
return 0;
|
|
971
1077
|
}
|
|
972
1078
|
// ─── list ────────────────────────────────────────────────────────────────────
|
|
973
1079
|
function scopeState(target, verify) {
|
|
@@ -1052,10 +1158,73 @@ export async function runSkillList(opts) {
|
|
|
1052
1158
|
latest = { error: err.message, url: catalogUrl() };
|
|
1053
1159
|
}
|
|
1054
1160
|
}
|
|
1055
|
-
const
|
|
1161
|
+
const present = (s) => s.state === "installed" || s.state === "modified";
|
|
1162
|
+
const label = (s) => ({
|
|
1163
|
+
absent: "not installed",
|
|
1164
|
+
installed: `installed ${fmtVersion(s.version)}`,
|
|
1165
|
+
modified: `modified ${fmtVersion(s.version)}`,
|
|
1166
|
+
blocked: "blocked (not a directory)",
|
|
1167
|
+
unmanaged: "unmanaged (no manifest)",
|
|
1168
|
+
})[s.state];
|
|
1169
|
+
const printHeader = () => {
|
|
1170
|
+
process.stdout.write(`skill list\n`);
|
|
1171
|
+
header([
|
|
1172
|
+
agentsLabel(sel),
|
|
1173
|
+
["source", bundleDir ?? "none"],
|
|
1174
|
+
["catalog", snapshot ? `${fmtVersion(snapshot.version)} (embedded snapshot)` : "none"],
|
|
1175
|
+
...(latest ? [["latest", "version" in latest ? `${fmtVersion(latest.version)} (release)` : `unreachable — ${latest.error}`]] : []),
|
|
1176
|
+
]);
|
|
1177
|
+
if (latest && "error" in latest)
|
|
1178
|
+
warn(`could not refresh the catalog; showing the embedded snapshot`);
|
|
1179
|
+
};
|
|
1180
|
+
const meta = (e) => [e.latest ? fmtVersion(e.latest) : "", e.files !== null ? `${e.files} files` : "", e.embedded ? "embedded" : ""]
|
|
1181
|
+
.filter(Boolean).join(" ");
|
|
1182
|
+
const catalogInfo = { version: snapshot?.version ?? null, origin: snapshot ? "embedded" : "none" };
|
|
1183
|
+
if (isMulti(sel)) {
|
|
1184
|
+
// Rows are the same for every agent; only the installed state differs.
|
|
1185
|
+
const perAgent = sel.agents.map((agent) => ({ agent, entries: installedSkillEntries(agent, { latest: refreshed }) }));
|
|
1186
|
+
const entries = perAgent[0].entries.map(({ project: _p, global: _g, ...row }) => ({
|
|
1187
|
+
...row,
|
|
1188
|
+
installs: Object.fromEntries(perAgent.map(({ agent, entries: rows }) => {
|
|
1189
|
+
const mine = rows.find((r) => r.name === row.name);
|
|
1190
|
+
return [agent, { project: mine.project, global: mine.global }];
|
|
1191
|
+
})),
|
|
1192
|
+
}));
|
|
1193
|
+
// The first skill some agent has at neither scope; install names every agent, and copies already there are no-ops.
|
|
1194
|
+
const pending = entries.find((e) => Object.values(e.installs).some((i) => !present(i.project) && !present(i.global)));
|
|
1195
|
+
const nextAction = pending ? { kind: "run", command: installCommand(pending.name, opts, false) } : null;
|
|
1196
|
+
const result = {
|
|
1197
|
+
status: "ok", source: bundleDir, agents: sel.agents, catalog: catalogInfo, ...(latest ? { latest } : {}), skills: entries, nextAction,
|
|
1198
|
+
};
|
|
1199
|
+
if (opts.json) {
|
|
1200
|
+
emitJson(result);
|
|
1201
|
+
return 0;
|
|
1202
|
+
}
|
|
1203
|
+
printHeader();
|
|
1204
|
+
if (entries.length === 0) {
|
|
1205
|
+
warn("this build bundles no skills");
|
|
1206
|
+
return 0;
|
|
1207
|
+
}
|
|
1208
|
+
const width = Math.max(...entries.map((e) => e.name.length));
|
|
1209
|
+
const agentWidth = Math.max(...sel.agents.map((a) => a.length));
|
|
1210
|
+
const stateWidth = Math.max(...entries.flatMap((e) => Object.values(e.installs).flatMap((i) => [label(i.project).length, label(i.global).length])));
|
|
1211
|
+
for (const e of entries) {
|
|
1212
|
+
process.stdout.write(`\n ${e.name.padEnd(width)} ${meta(e)}\n`);
|
|
1213
|
+
if (e.description)
|
|
1214
|
+
process.stdout.write(` ${e.description}\n`);
|
|
1215
|
+
for (const agent of sel.agents) {
|
|
1216
|
+
const i = e.installs[agent];
|
|
1217
|
+
process.stdout.write(` ${agent.padEnd(agentWidth)} project ${label(i.project).padEnd(stateWidth)} ${i.project.path}\n`);
|
|
1218
|
+
process.stdout.write(` ${agent.padEnd(agentWidth)} global ${label(i.global).padEnd(stateWidth)} ${i.global.path}\n`);
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
if (nextAction)
|
|
1222
|
+
process.stdout.write(`\n next: ${nextAction.command}\n`);
|
|
1223
|
+
return 0;
|
|
1224
|
+
}
|
|
1225
|
+
const entries = installedSkillEntries(sel.agents[0], { latest: refreshed });
|
|
1056
1226
|
// One next action, and only when there is something to do. A skill with a
|
|
1057
1227
|
// manifest at either scope is present, even if edited; `update` handles it.
|
|
1058
|
-
const present = (s) => s.state === "installed" || s.state === "modified";
|
|
1059
1228
|
const pending = entries.find((e) => !present(e.project) && !present(e.global));
|
|
1060
1229
|
const nextAction = pending
|
|
1061
1230
|
? { kind: "run", command: installCommand(pending.name, opts, false) }
|
|
@@ -1063,8 +1232,8 @@ export async function runSkillList(opts) {
|
|
|
1063
1232
|
const result = {
|
|
1064
1233
|
status: "ok",
|
|
1065
1234
|
source: bundleDir,
|
|
1066
|
-
agent: sel.
|
|
1067
|
-
catalog:
|
|
1235
|
+
agent: sel.agents[0],
|
|
1236
|
+
catalog: catalogInfo,
|
|
1068
1237
|
...(latest ? { latest } : {}),
|
|
1069
1238
|
skills: entries,
|
|
1070
1239
|
nextAction,
|
|
@@ -1073,32 +1242,15 @@ export async function runSkillList(opts) {
|
|
|
1073
1242
|
emitJson(result);
|
|
1074
1243
|
return 0;
|
|
1075
1244
|
}
|
|
1076
|
-
|
|
1077
|
-
header([
|
|
1078
|
-
["agent", `${sel.agent}${sel.saved ? " (saved)" : ""}`],
|
|
1079
|
-
["source", bundleDir ?? "none"],
|
|
1080
|
-
["catalog", snapshot ? `${fmtVersion(snapshot.version)} (embedded snapshot)` : "none"],
|
|
1081
|
-
...(latest ? [["latest", "version" in latest ? `${fmtVersion(latest.version)} (release)` : `unreachable — ${latest.error}`]] : []),
|
|
1082
|
-
]);
|
|
1083
|
-
if (latest && "error" in latest)
|
|
1084
|
-
warn(`could not refresh the catalog; showing the embedded snapshot`);
|
|
1245
|
+
printHeader();
|
|
1085
1246
|
if (entries.length === 0) {
|
|
1086
1247
|
warn("this build bundles no skills");
|
|
1087
1248
|
return 0;
|
|
1088
1249
|
}
|
|
1089
|
-
const label = (s) => ({
|
|
1090
|
-
absent: "not installed",
|
|
1091
|
-
installed: `installed ${fmtVersion(s.version)}`,
|
|
1092
|
-
modified: `modified ${fmtVersion(s.version)}`,
|
|
1093
|
-
blocked: "blocked (not a directory)",
|
|
1094
|
-
unmanaged: "unmanaged (no manifest)",
|
|
1095
|
-
})[s.state];
|
|
1096
1250
|
const width = Math.max(...entries.map((e) => e.name.length));
|
|
1097
1251
|
const stateWidth = Math.max(...entries.flatMap((e) => [label(e.project).length, label(e.global).length]));
|
|
1098
1252
|
for (const e of entries) {
|
|
1099
|
-
|
|
1100
|
-
.filter(Boolean).join(" ");
|
|
1101
|
-
process.stdout.write(`\n ${e.name.padEnd(width)} ${meta}\n`);
|
|
1253
|
+
process.stdout.write(`\n ${e.name.padEnd(width)} ${meta(e)}\n`);
|
|
1102
1254
|
if (e.description)
|
|
1103
1255
|
process.stdout.write(` ${e.description}\n`);
|
|
1104
1256
|
process.stdout.write(` project ${label(e.project).padEnd(stateWidth)} ${e.project.path}\n`);
|
|
@@ -1111,30 +1263,36 @@ export async function runSkillList(opts) {
|
|
|
1111
1263
|
export async function runSkillInit(opts, io = {
|
|
1112
1264
|
interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY),
|
|
1113
1265
|
agent: () => select({ message: "Which agent?", choices: [
|
|
1114
|
-
{ name: "Codex", value: "
|
|
1266
|
+
{ name: "Claude Code and Codex", value: ["claude", "codex"] },
|
|
1267
|
+
{ name: "Codex", value: ["codex"] },
|
|
1268
|
+
{ name: "Claude Code", value: ["claude"] },
|
|
1115
1269
|
] }),
|
|
1116
1270
|
global: () => select({ message: "Where should skills be installed?", choices: [
|
|
1117
1271
|
{ name: "This project", value: false }, { name: "All projects (global)", value: true },
|
|
1118
1272
|
] }),
|
|
1119
1273
|
}) {
|
|
1120
1274
|
if (opts.agent !== undefined) {
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1275
|
+
const agents = parseAgents(opts.agent);
|
|
1276
|
+
if (!agents)
|
|
1277
|
+
return reject(opts, AGENT_ERROR, "invalid-agent");
|
|
1278
|
+
return initInstall(opts, skillPreferences(agents, opts.global && !opts.dir && !opts.project ? "global" : "project"));
|
|
1124
1279
|
}
|
|
1125
1280
|
if (!io.interactive || Object.values(opts).some((v) => v !== undefined && v !== false)) {
|
|
1126
|
-
return reject(opts, "specify --agent codex or
|
|
1281
|
+
return reject(opts, "specify --agent claude, codex or all for non-interactive setup", "agent-required", { kind: "run", command: "dreamlake init --agent all" });
|
|
1127
1282
|
}
|
|
1128
|
-
let
|
|
1283
|
+
let agents;
|
|
1129
1284
|
let global;
|
|
1130
1285
|
try {
|
|
1131
|
-
|
|
1286
|
+
const chosen = await io.agent();
|
|
1287
|
+
agents = AGENTS.filter((a) => (Array.isArray(chosen) ? chosen : [chosen]).includes(a));
|
|
1132
1288
|
global = await io.global();
|
|
1133
1289
|
}
|
|
1134
1290
|
catch {
|
|
1135
1291
|
return reject(opts, "setup canceled; no skill files were written", "canceled");
|
|
1136
1292
|
}
|
|
1137
|
-
|
|
1293
|
+
if (agents.length === 0)
|
|
1294
|
+
return reject(opts, "setup canceled; no agent was chosen", "canceled");
|
|
1295
|
+
return initInstall({ ...opts, agent: agents.join(","), global }, skillPreferences(agents, global ? "global" : "project"));
|
|
1138
1296
|
}
|
|
1139
1297
|
function initInstall(opts, preferences) {
|
|
1140
1298
|
let saved;
|
|
@@ -1155,7 +1313,7 @@ function initInstall(opts, preferences) {
|
|
|
1155
1313
|
// --version` drift produced.
|
|
1156
1314
|
function scopeOptions(command) {
|
|
1157
1315
|
return command
|
|
1158
|
-
.option("--agent <agent>", "target agent: claude or
|
|
1316
|
+
.option("--agent <agent>", "target agent: claude, codex, all, or a comma list (default: what dreamlake init saved, else claude)")
|
|
1159
1317
|
.option("--global", "use your home directory instead of the current project")
|
|
1160
1318
|
.option("--project", "use the current project even if dreamlake init chose global")
|
|
1161
1319
|
.option("--dir <path>", "use this project root; overrides --global and --project");
|
|
@@ -1169,7 +1327,7 @@ function installationOptions(command) {
|
|
|
1169
1327
|
export function registerSkillCommand(program) {
|
|
1170
1328
|
program.command("init")
|
|
1171
1329
|
.description("set up agent skills: choose an agent and scope, install the embedded dreamlake-cli skill offline")
|
|
1172
|
-
.option("--agent <agent>", "claude or
|
|
1330
|
+
.option("--agent <agent>", "claude, codex, all, or a comma list; saved as the default for 'dreamlake skill' and skips the prompts")
|
|
1173
1331
|
.option("--global", "install under your home directory and save global scope")
|
|
1174
1332
|
.option("--dir <path>", "install under this project root; overrides --global")
|
|
1175
1333
|
.option("--force", "overwrite files that differ; files the skill does not own are kept")
|
|
@@ -1180,8 +1338,8 @@ export function registerSkillCommand(program) {
|
|
|
1180
1338
|
const skill = program.command("skill")
|
|
1181
1339
|
.description("install, update, remove and list agent skills from the dreamlake-skills release")
|
|
1182
1340
|
.addHelpText("after", `
|
|
1183
|
-
Claude Code uses .claude/skills/; Codex uses .agents/skills/.
|
|
1184
|
-
'dreamlake init' saves the default agent and scope; --agent, --global, --project and --dir override it.
|
|
1341
|
+
Claude Code uses .claude/skills/; Codex uses .agents/skills/. --agent all installs into both, one copy each.
|
|
1342
|
+
'dreamlake init' saves the default agent(s) and scope; --agent, --global, --project and --dir override it.
|
|
1185
1343
|
install and update download from the public release; dreamlake-cli is embedded and installs offline.
|
|
1186
1344
|
Every install writes <skill>/.dreamlake-skill.json; update and remove touch only files it lists.
|
|
1187
1345
|
remove never deletes a file you edited: it is kept and reported.
|
|
@@ -1207,7 +1365,7 @@ remove never deletes a file you edited: it is kept and reported.
|
|
|
1207
1365
|
});
|
|
1208
1366
|
collectionList(skill, "list")
|
|
1209
1367
|
.description("show the catalog with project/global installation status")
|
|
1210
|
-
.option("--agent <agent>", "target agent: claude or
|
|
1368
|
+
.option("--agent <agent>", "target agent: claude, codex, all, or a comma list (default: what dreamlake init saved, else claude)")
|
|
1211
1369
|
.option("--refresh", "fetch the latest catalog from the release and show it next to the installed versions")
|
|
1212
1370
|
.option("--json", "emit one result object")
|
|
1213
1371
|
.action(async (opts) => {
|
|
@@ -19,6 +19,12 @@ export declare class ManifestError extends Error {
|
|
|
19
19
|
}
|
|
20
20
|
export declare const AGENTS: readonly SkillAgent[];
|
|
21
21
|
export declare function isAgent(v: unknown): v is SkillAgent;
|
|
22
|
+
/**
|
|
23
|
+
* An `--agent` value: one agent, a comma-separated list, or `all`. Returns the
|
|
24
|
+
* agents in canonical order without duplicates, or null when any part is not
|
|
25
|
+
* an agent. A manifest still records exactly one agent; this is selection only.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseAgents(v: unknown): SkillAgent[] | null;
|
|
22
28
|
export declare function manifestPath(target: string): string;
|
|
23
29
|
/** Validate a parsed manifest. Throws `ManifestError` naming the first problem. */
|
|
24
30
|
export declare function validateManifest(raw: unknown, file: string): SkillManifest;
|
|
@@ -25,6 +25,21 @@ const SHA256 = /^[0-9a-f]{64}$/;
|
|
|
25
25
|
export function isAgent(v) {
|
|
26
26
|
return typeof v === "string" && AGENTS.includes(v);
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* An `--agent` value: one agent, a comma-separated list, or `all`. Returns the
|
|
30
|
+
* agents in canonical order without duplicates, or null when any part is not
|
|
31
|
+
* an agent. A manifest still records exactly one agent; this is selection only.
|
|
32
|
+
*/
|
|
33
|
+
export function parseAgents(v) {
|
|
34
|
+
if (typeof v !== "string")
|
|
35
|
+
return null;
|
|
36
|
+
const parts = v.split(",").map((p) => p.trim());
|
|
37
|
+
if (parts.length === 0 || parts.some((p) => p !== "all" && !isAgent(p)))
|
|
38
|
+
return null;
|
|
39
|
+
if (parts.includes("all"))
|
|
40
|
+
return [...AGENTS];
|
|
41
|
+
return AGENTS.filter((a) => parts.includes(a));
|
|
42
|
+
}
|
|
28
43
|
export function manifestPath(target) {
|
|
29
44
|
return path.join(target, MANIFEST_FILE);
|
|
30
45
|
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import { type SkillAgent } from "./manifest.js";
|
|
2
2
|
export interface SkillPreferences {
|
|
3
3
|
agent: SkillAgent;
|
|
4
|
+
/** Present only when more than one agent was chosen; `agent` is its first entry. */
|
|
5
|
+
agents?: SkillAgent[];
|
|
4
6
|
scope: "project" | "global";
|
|
5
7
|
}
|
|
6
8
|
export declare function preferencesPath(): string;
|
|
9
|
+
/** The saved preferences for these agents, in the shape older CLIs can read. */
|
|
10
|
+
export declare function skillPreferences(agents: SkillAgent[], scope: "project" | "global"): SkillPreferences;
|
|
11
|
+
/** Every agent the preferences select. */
|
|
12
|
+
export declare function preferredAgents(prefs: SkillPreferences): SkillAgent[];
|
|
7
13
|
/** `null` when nothing was saved or the file is unreadable — never throws. */
|
|
8
14
|
export declare function readSkillPreferences(): SkillPreferences | null;
|
|
9
15
|
export declare function writeSkillPreferences(prefs: SkillPreferences): string;
|
package/dist/cli/skill/prefs.js
CHANGED
|
@@ -1,25 +1,42 @@
|
|
|
1
|
-
// The agent and scope `dreamlake init` chose, remembered so every later
|
|
1
|
+
// The agent(s) and scope `dreamlake init` chose, remembered so every later
|
|
2
2
|
// `skill` subcommand defaults to them. Lives in the CLI state directory next
|
|
3
3
|
// to `skill-reminders.json`; `--agent`, `--global`, `--project` and `--dir`
|
|
4
4
|
// override it per invocation and never rewrite it.
|
|
5
|
+
//
|
|
6
|
+
// One agent is saved as `{ agent, scope }`, exactly as before. Several are
|
|
7
|
+
// saved as `{ agent, agents, scope }`: `agents` is the list, `agent` its first
|
|
8
|
+
// entry, so an older CLI that knows only `agent` still reads a usable file.
|
|
5
9
|
import { readFileSync } from "node:fs";
|
|
6
10
|
import path from "node:path";
|
|
7
11
|
import { updateStatePath } from "../self-update/paths.js";
|
|
8
12
|
import { writeStateFile } from "./files.js";
|
|
9
|
-
import { isAgent } from "./manifest.js";
|
|
13
|
+
import { AGENTS, isAgent } from "./manifest.js";
|
|
10
14
|
export function preferencesPath() {
|
|
11
15
|
return path.join(path.dirname(updateStatePath()), "skill-preferences.json");
|
|
12
16
|
}
|
|
17
|
+
/** The saved preferences for these agents, in the shape older CLIs can read. */
|
|
18
|
+
export function skillPreferences(agents, scope) {
|
|
19
|
+
return agents.length > 1 ? { agent: agents[0], agents, scope } : { agent: agents[0], scope };
|
|
20
|
+
}
|
|
21
|
+
/** Every agent the preferences select. */
|
|
22
|
+
export function preferredAgents(prefs) {
|
|
23
|
+
return prefs.agents ?? [prefs.agent];
|
|
24
|
+
}
|
|
13
25
|
/** `null` when nothing was saved or the file is unreadable — never throws. */
|
|
14
26
|
export function readSkillPreferences() {
|
|
15
27
|
try {
|
|
16
28
|
const parsed = JSON.parse(readFileSync(preferencesPath(), "utf8"));
|
|
17
29
|
if (!parsed || typeof parsed !== "object")
|
|
18
30
|
return null;
|
|
19
|
-
const { agent, scope } = parsed;
|
|
31
|
+
const { agent, agents, scope } = parsed;
|
|
32
|
+
const scoped = scope === "global" ? "global" : "project";
|
|
33
|
+
// A list wins when every entry is an agent; a malformed list falls back to `agent`.
|
|
34
|
+
if (Array.isArray(agents) && agents.length > 0 && agents.every(isAgent)) {
|
|
35
|
+
return skillPreferences(AGENTS.filter((a) => agents.includes(a)), scoped);
|
|
36
|
+
}
|
|
20
37
|
if (!isAgent(agent))
|
|
21
38
|
return null;
|
|
22
|
-
return { agent, scope:
|
|
39
|
+
return { agent, scope: scoped };
|
|
23
40
|
}
|
|
24
41
|
catch {
|
|
25
42
|
return null;
|
package/dist/cli/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.93.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.93.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dreamlake-ai/dreamlake-cli.git"
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"node": ">=18"
|
|
36
36
|
},
|
|
37
37
|
"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.
|
|
38
|
+
"@dreamlake/dreamlake-cli-darwin-arm64": "0.93.0",
|
|
39
|
+
"@dreamlake/dreamlake-cli-darwin-x64": "0.93.0",
|
|
40
|
+
"@dreamlake/dreamlake-cli-linux-x64": "0.93.0",
|
|
41
|
+
"@dreamlake/dreamlake-cli-linux-arm64": "0.93.0",
|
|
42
|
+
"@dreamlake/dreamlake-cli-linux-x64-musl": "0.93.0",
|
|
43
|
+
"@dreamlake/dreamlake-cli-linux-arm64-musl": "0.93.0",
|
|
44
|
+
"@dreamlake/dreamlake-cli-win32-x64": "0.93.0",
|
|
45
|
+
"@dreamlake/dreamlake-cli-win32-arm64": "0.93.0"
|
|
46
46
|
}
|
|
47
47
|
}
|