forest-cli 5.23.0 → 5.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,23 @@
1
+ import AbstractCommand from '../../abstract-command';
2
+ export default class SkillsInitCommand extends AbstractCommand {
3
+ static description: string;
4
+ static flags: {
5
+ agent: import("@oclif/core/lib/interfaces").OptionFlag<string[], import("@oclif/core/lib/interfaces").CustomOptions>;
6
+ ref: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
+ force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
+ };
9
+ run(): Promise<void>;
10
+ /** Explicit `--agent` wins; otherwise detect, and only ask when there's a terminal to ask in. */
11
+ private resolveAgents;
12
+ /** Drive the agent's own plugin CLI. Returns false (and warns) when it can't be used. */
13
+ private installPluginFor;
14
+ /**
15
+ * Copy the curated skills into `.agents/skills/` for the agents that only read SKILL.md files.
16
+ * Returns null, having warned, when the route fails: the plugin route may already have installed,
17
+ * and throwing here would leave that install out of the manifest and the context files.
18
+ */
19
+ private copySkills;
20
+ private copySkillsFromMarketplace;
21
+ private logNextSteps;
22
+ }
23
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/skills/init.ts"],"names":[],"mappings":"AASA,OAAO,eAAe,MAAM,wBAAwB,CAAC;AAyBrD,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,eAAe;IAC5D,OAAgB,WAAW,SAC6H;IAExJ,OAAgB,KAAK;;;;MAanB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAkD1B,iGAAiG;YACnF,aAAa;IAwC3B,yFAAyF;IACzF,OAAO,CAAC,gBAAgB;IAwCxB;;;;OAIG;YACW,UAAU;YAcV,yBAAyB;IA6BvC,OAAO,CAAC,YAAY;CAmBrB"}
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const core_1 = require("@oclif/core");
7
+ const abstract_command_1 = __importDefault(require("../../abstract-command"));
8
+ const skills_manager_1 = require("../../services/skills/skills-manager");
9
+ class SkillsInitCommand extends abstract_command_1.default {
10
+ async run() {
11
+ const { flags } = await this.parse(SkillsInitCommand);
12
+ const agents = await this.resolveAgents(flags.agent);
13
+ const pluginAgents = agents.filter(skills_manager_1.isPluginAgent);
14
+ const copyAgents = agents.filter(agent => !(0, skills_manager_1.isPluginAgent)(agent));
15
+ const previous = (0, skills_manager_1.readManifest)();
16
+ // Plugin route first: it touches nothing in the repo beyond `.claude/settings.json`, so a
17
+ // failure here leaves the working tree as it was.
18
+ const pluginOk = pluginAgents.filter(agent => this.installPluginFor(agent, flags.ref));
19
+ // A copy route that fails leaves the files an earlier run recorded exactly where they were.
20
+ const copied = copyAgents.length
21
+ ? await this.copySkills(flags.ref, flags.force, previous)
22
+ : null;
23
+ const copyOk = copied ? copyAgents : [];
24
+ // Only what actually got set up: a plugin agent whose CLI is missing was skipped, so claiming
25
+ // it in the manifest would have `skills:update` refresh a plugin that was never installed, and
26
+ // its context file would tell the agent about a plugin it does not have.
27
+ const installed = [...pluginOk, ...copyOk];
28
+ if (!installed.length) {
29
+ this.logger.error('Nothing was installed, so nothing was recorded.');
30
+ this.exit(1);
31
+ return;
32
+ }
33
+ const files = copied ?? (0, skills_manager_1.skillDirEntries)(previous?.files ?? []);
34
+ // An earlier run's agents stay recorded: this run adds to the install, it does not replace it,
35
+ // or the skills copied for an agent it did not name would never be refreshed again.
36
+ const recorded = [...new Set([...installed, ...(previous ? (0, skills_manager_1.manifestAgents)(previous) : [])])];
37
+ const groups = (0, skills_manager_1.contextFileGroups)(recorded);
38
+ // One merged block per FILE, not per agent: AGENTS.md serves Codex, Cursor and OpenCode alike,
39
+ // and a second merge would replace the first instead of adding to it.
40
+ groups.forEach((groupAgents, file) => (0, skills_manager_1.mergeBlock)(file, (0, skills_manager_1.forestBlock)(groupAgents)));
41
+ (0, skills_manager_1.writeManifest)({
42
+ ref: flags.ref,
43
+ installedAt: new Date().toISOString(),
44
+ agents: recorded,
45
+ refs: (0, skills_manager_1.refsAfter)(previous ? (0, skills_manager_1.manifestRefs)(previous) : {}, installed, recorded, flags.ref),
46
+ files: [...files, ...groups.keys()],
47
+ });
48
+ this.logNextSteps(pluginOk, copyOk);
49
+ }
50
+ /** Explicit `--agent` wins; otherwise detect, and only ask when there's a terminal to ask in. */
51
+ async resolveAgents(fromFlag) {
52
+ if (fromFlag?.length)
53
+ return [...new Set(fromFlag)];
54
+ const detected = (0, skills_manager_1.detectAgents)();
55
+ const { inquirer, process: proc } = this.context;
56
+ const interactive = proc?.stdout?.isTTY ?? process.stdout.isTTY;
57
+ if (!interactive) {
58
+ if (!detected.length) {
59
+ throw new Error(`No coding agent detected and no --agent given. Re-run with --agent <${skills_manager_1.ALL_AGENTS.join('|')}>.`);
60
+ }
61
+ this.logger.info(`Detected ${detected.map(a => skills_manager_1.AGENT_LABELS[a]).join(', ')}.`);
62
+ return detected;
63
+ }
64
+ const { chosen } = await inquirer.prompt([
65
+ {
66
+ type: 'checkbox',
67
+ name: 'chosen',
68
+ // The hint lives in the message, not in inquirer's own one — that one is appended to the
69
+ // first render only and vanishes on the first keypress, right when it is needed most.
70
+ // Arrow keys move without selecting, so "press space" is the one thing users must know.
71
+ message: 'Which coding agent(s) do you use? (space to select, enter to confirm)',
72
+ choices: skills_manager_1.ALL_AGENTS.map(agent => ({
73
+ name: skills_manager_1.AGENT_LABELS[agent],
74
+ value: agent,
75
+ checked: detected.includes(agent),
76
+ })),
77
+ validate: (picked) => picked.length > 0 || 'Pick at least one agent.',
78
+ },
79
+ ]);
80
+ return chosen;
81
+ }
82
+ /** Drive the agent's own plugin CLI. Returns false (and warns) when it can't be used. */
83
+ installPluginFor(agent, ref) {
84
+ if (!(0, skills_manager_1.hasPluginCli)(agent)) {
85
+ this.logger.warn(`${skills_manager_1.AGENT_LABELS[agent]} selected but its CLI isn't on your PATH — skipping. ` +
86
+ `Install it, then re-run \`forest skills:init --agent ${agent}\`.`);
87
+ return false;
88
+ }
89
+ let result;
90
+ try {
91
+ result = (0, skills_manager_1.installPlugins)(agent, ref);
92
+ }
93
+ catch (error) {
94
+ // One agent's CLI failing must not cost the others their install, nor the run its manifest.
95
+ this.logger.warn(`${skills_manager_1.AGENT_LABELS[agent]}: ${error.message}`);
96
+ return false;
97
+ }
98
+ const { installed, failed } = result;
99
+ if (installed.length) {
100
+ this.logger.success(`${skills_manager_1.AGENT_LABELS[agent]}: installed the Forest plugin${installed.length > 1 ? 's' : ''} (${installed.join(', ')}).`, { lineColor: 'green' });
101
+ }
102
+ if (failed.length) {
103
+ this.logger.warn(`${skills_manager_1.AGENT_LABELS[agent]}: could not install ${failed.join(', ')}. Retry by hand with ${failed
104
+ .map(plugin => `\`${(0, skills_manager_1.pluginInstallCommand)(agent, plugin)}\``)
105
+ .join(' and ')}.`);
106
+ }
107
+ return installed.length > 0;
108
+ }
109
+ /**
110
+ * Copy the curated skills into `.agents/skills/` for the agents that only read SKILL.md files.
111
+ * Returns null, having warned, when the route fails: the plugin route may already have installed,
112
+ * and throwing here would leave that install out of the manifest and the context files.
113
+ */
114
+ async copySkills(ref, force, previous) {
115
+ try {
116
+ return await this.copySkillsFromMarketplace(ref, force, previous);
117
+ }
118
+ catch (error) {
119
+ this.logger.warn(`Could not copy the Forest skills into ${skills_manager_1.SKILLS_DIR}/: ${error.message}`);
120
+ return null;
121
+ }
122
+ }
123
+ async copySkillsFromMarketplace(ref, force, previous) {
124
+ this.logger.info(`Fetching Forest skills from ${this.chalk.bold(skills_manager_1.MARKETPLACE_REPO)}@${ref}…`);
125
+ const { root: srcRoot, cleanup } = await (0, skills_manager_1.fetchMarketplace)(ref);
126
+ try {
127
+ const { written, skipped } = (0, skills_manager_1.installSkills)(srcRoot, force, previous?.files ?? null);
128
+ // Prune only Forest-managed skill files that were installed before and are no longer in the
129
+ // bundle (manifest-scoped) — user-added files in the skill dirs are left untouched.
130
+ if (previous)
131
+ (0, skills_manager_1.removeStaleSkillFiles)((0, skills_manager_1.skillDirEntries)(previous.files), written);
132
+ this.logger.success(`Forest skills copied to ${skills_manager_1.SKILLS_DIR}/`, { lineColor: 'green' });
133
+ if (skipped.length) {
134
+ this.logger.warn(`Kept your own version of ${skipped.length} file(s) we've never written: ${skipped.join(', ')}. Delete them and re-run to take the Forest version.`);
135
+ }
136
+ return written;
137
+ }
138
+ finally {
139
+ cleanup();
140
+ }
141
+ }
142
+ logNextSteps(pluginAgents, copyAgents) {
143
+ if (pluginAgents.length) {
144
+ this.logger.info(`Restart ${pluginAgents
145
+ .map(a => skills_manager_1.AGENT_LABELS[a])
146
+ .join(' / ')} to load the plugin — then try \`/forest:start\`.`);
147
+ }
148
+ if (pluginAgents.includes('claude')) {
149
+ this.logger.info('Commit `.claude/settings.json` so your teammates get the same plugin (they run `claude plugin install forest@forest-admin-ai` once).');
150
+ }
151
+ if (copyAgents.length) {
152
+ this.logger.info(`Commit \`${skills_manager_1.SKILLS_DIR}/\` so your teammates get the skills at clone. Refresh later with \`forest skills:update\`.`);
153
+ }
154
+ }
155
+ }
156
+ exports.default = SkillsInitCommand;
157
+ SkillsInitCommand.description = 'Give your coding agent the Forest skills: installs the Forest plugin (Claude Code, Codex) or copies the skills into the repo (Cursor, OpenCode, …).';
158
+ SkillsInitCommand.flags = {
159
+ agent: core_1.Flags.string({
160
+ description: `Coding agent(s) to set up: ${skills_manager_1.ALL_AGENTS.join(', ')}. Repeatable. Skips the prompt; without it, the agents this repo or this machine points to are detected and used. Required only when nothing is detected.`,
161
+ multiple: true,
162
+ options: [...skills_manager_1.ALL_AGENTS],
163
+ }),
164
+ ref: core_1.Flags.string({ description: 'Marketplace version (git ref).', default: 'main' }),
165
+ force: core_1.Flags.boolean({
166
+ description: 'Overwrite skill files already installed by a previous run (copy route only).',
167
+ default: false,
168
+ }),
169
+ };
170
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5pdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9jb21tYW5kcy9za2lsbHMvaW5pdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQU9BLHNDQUFvQztBQUVwQyw4RUFBcUQ7QUFDckQseUVBc0I4QztBQUU5QyxNQUFxQixpQkFBa0IsU0FBUSwwQkFBZTtJQW1CNUQsS0FBSyxDQUFDLEdBQUc7UUFDUCxNQUFNLEVBQUUsS0FBSyxFQUFFLEdBQUcsTUFBTSxJQUFJLENBQUMsS0FBSyxDQUFDLGlCQUFpQixDQUFDLENBQUM7UUFDdEQsTUFBTSxNQUFNLEdBQUcsTUFBTSxJQUFJLENBQUMsYUFBYSxDQUFDLEtBQUssQ0FBQyxLQUE0QixDQUFDLENBQUM7UUFFNUUsTUFBTSxZQUFZLEdBQUcsTUFBTSxDQUFDLE1BQU0sQ0FBQyw4QkFBYSxDQUFDLENBQUM7UUFDbEQsTUFBTSxVQUFVLEdBQUcsTUFBTSxDQUFDLE1BQU0sQ0FBQyxLQUFLLENBQUMsRUFBRSxDQUFDLENBQUMsSUFBQSw4QkFBYSxFQUFDLEtBQUssQ0FBQyxDQUFDLENBQUM7UUFDakUsTUFBTSxRQUFRLEdBQUcsSUFBQSw2QkFBWSxHQUFFLENBQUM7UUFFaEMsMEZBQTBGO1FBQzFGLGtEQUFrRDtRQUNsRCxNQUFNLFFBQVEsR0FBRyxZQUFZLENBQUMsTUFBTSxDQUFDLEtBQUssQ0FBQyxFQUFFLENBQUMsSUFBSSxDQUFDLGdCQUFnQixDQUFDLEtBQUssRUFBRSxLQUFLLENBQUMsR0FBRyxDQUFDLENBQUMsQ0FBQztRQUV2Riw0RkFBNEY7UUFDNUYsTUFBTS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U7UUFDM0YsT0FBTyxFQUFFLEtBQUs7S0FDZixDQUFDO0NBQ0gsQ0FBQyJ9
@@ -0,0 +1,12 @@
1
+ import AbstractCommand from '../../abstract-command';
2
+ export default class SkillsUpdateCommand extends AbstractCommand {
3
+ static description: string;
4
+ static flags: {
5
+ ref: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
6
+ };
7
+ run(): Promise<void>;
8
+ /** True only when every Forest plugin was refreshed, so the agent now runs the requested ref. */
9
+ private upgradePluginFor;
10
+ private refreshSkills;
11
+ }
12
+ //# sourceMappingURL=update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/commands/skills/update.ts"],"names":[],"mappings":"AAIA,OAAO,eAAe,MAAM,wBAAwB,CAAC;AAsBrD,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,eAAe;IAC9D,OAAgB,WAAW,SAIP;IAEpB,OAAgB,KAAK;;MAEnB;IAEI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IA4D1B,iGAAiG;IACjG,OAAO,CAAC,gBAAgB;YAkCV,aAAa;CA8B5B"}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const core_1 = require("@oclif/core");
7
+ const abstract_command_1 = __importDefault(require("../../abstract-command"));
8
+ const skills_manager_1 = require("../../services/skills/skills-manager");
9
+ class SkillsUpdateCommand extends abstract_command_1.default {
10
+ async run() {
11
+ const { flags } = await this.parse(SkillsUpdateCommand);
12
+ const manifest = (0, skills_manager_1.readManifest)();
13
+ if (!manifest) {
14
+ this.logger.error('No Forest skills found in this repo.');
15
+ this.logger.log(`help: run ${this.chalk.bold('forest skills:init')} first.`);
16
+ this.exit(1);
17
+ return;
18
+ }
19
+ // An update targets the requested ref (default main) — but never silently: an install pinned
20
+ // to a tag/SHA jumping refs must be visible, and the way back must be obvious. Each agent is
21
+ // judged by the ref its own content came from, since one run can leave agents on different refs.
22
+ const refs = (0, skills_manager_1.manifestRefs)(manifest);
23
+ const pinned = [...new Set(Object.values(refs))].filter(ref => ref && ref !== flags.ref);
24
+ pinned.forEach(ref => {
25
+ const labels = Object.keys(refs)
26
+ .filter(agent => refs[agent] === ref)
27
+ .map(agent => skills_manager_1.AGENT_LABELS[agent]);
28
+ this.logger.warn(`${labels.join(', ')}: skills were installed from "${ref}"; updating to "${flags.ref}". ` +
29
+ `Pass ${this.chalk.bold(`--ref ${ref}`)} to stay pinned.`);
30
+ });
31
+ // Refresh exactly the agents the install targeted: refreshing one agent must never treat
32
+ // another's files as stale.
33
+ const agents = (0, skills_manager_1.manifestAgents)(manifest);
34
+ if (!agents.length) {
35
+ this.logger.warn(`No coding agent is recorded in this repo. Run ${this.chalk.bold('forest skills:init --agent <name>')} to set one up.`);
36
+ return;
37
+ }
38
+ const pluginAgents = agents.filter(skills_manager_1.isPluginAgent);
39
+ const copyAgents = agents.filter(agent => !(0, skills_manager_1.isPluginAgent)(agent));
40
+ const pluginRefreshed = pluginAgents.filter(agent => this.upgradePluginFor(agent, flags.ref));
41
+ const files = copyAgents.length ? await this.refreshSkills(manifest.files, flags.ref) : [];
42
+ // One merged block per FILE, not per agent — AGENTS.md serves Codex, Cursor and OpenCode.
43
+ const groups = (0, skills_manager_1.contextFileGroups)(agents);
44
+ groups.forEach((groupAgents, file) => (0, skills_manager_1.mergeBlock)(file, (0, skills_manager_1.forestBlock)(groupAgents)));
45
+ (0, skills_manager_1.writeManifest)({
46
+ ref: flags.ref,
47
+ installedAt: new Date().toISOString(),
48
+ agents,
49
+ // An agent whose refresh failed or was skipped keeps the ref its content still comes from.
50
+ refs: (0, skills_manager_1.refsAfter)(refs, [...pluginRefreshed, ...copyAgents], agents, flags.ref),
51
+ files: [...files, ...groups.keys()],
52
+ });
53
+ }
54
+ /** True only when every Forest plugin was refreshed, so the agent now runs the requested ref. */
55
+ upgradePluginFor(agent, ref) {
56
+ if (!(0, skills_manager_1.hasPluginCli)(agent)) {
57
+ this.logger.warn(`${skills_manager_1.AGENT_LABELS[agent]}: CLI not on your PATH — skipping its plugin refresh.`);
58
+ return false;
59
+ }
60
+ let result;
61
+ try {
62
+ result = (0, skills_manager_1.upgradePlugins)(agent, ref);
63
+ }
64
+ catch (error) {
65
+ // One agent's CLI failing must not cost the others their refresh, nor the run its manifest.
66
+ this.logger.warn(`${skills_manager_1.AGENT_LABELS[agent]}: ${error.message}`);
67
+ return false;
68
+ }
69
+ const { installed, failed } = result;
70
+ if (installed.length) {
71
+ this.logger.success(`${skills_manager_1.AGENT_LABELS[agent]}: Forest plugins refreshed (${installed.join(', ')}).`, {
72
+ lineColor: 'green',
73
+ });
74
+ }
75
+ if (failed.length) {
76
+ this.logger.warn(`${skills_manager_1.AGENT_LABELS[agent]}: could not refresh ${failed.join(', ')}.`);
77
+ }
78
+ return installed.length > 0 && !failed.length;
79
+ }
80
+ async refreshSkills(previousFiles, ref) {
81
+ this.logger.info(`Refreshing Forest skills from ${skills_manager_1.MARKETPLACE_REPO}@${ref}…`);
82
+ const { root: srcRoot, cleanup } = await (0, skills_manager_1.fetchMarketplace)(ref);
83
+ try {
84
+ // The managed skill files previously installed — candidates for stale-pruning.
85
+ const oldSkillFiles = (0, skills_manager_1.skillDirEntries)(previousFiles);
86
+ // force: managed files are Forest-owned. `previousFiles` still bounds what may be
87
+ // overwritten, so a same-named file the user wrote is preserved, not silently replaced.
88
+ const { written, skipped } = (0, skills_manager_1.installSkills)(srcRoot, true, previousFiles);
89
+ // Deletions: managed skill files removed upstream are removed locally.
90
+ const removed = (0, skills_manager_1.removeStaleSkillFiles)(oldSkillFiles, written);
91
+ this.logger.success(`Forest skills refreshed in ${skills_manager_1.SKILLS_DIR}/ (${written.length} files, ${removed.length} removed).`, { lineColor: 'green' });
92
+ if (skipped.length) {
93
+ this.logger.warn(`Kept your own version of ${skipped.length} file(s) we've never written: ${skipped.join(', ')}.`);
94
+ }
95
+ return written;
96
+ }
97
+ finally {
98
+ cleanup();
99
+ }
100
+ }
101
+ }
102
+ exports.default = SkillsUpdateCommand;
103
+ SkillsUpdateCommand.description = 'Refresh what `forest skills:init` installed (anti-drift): re-installs the Forest plugin for ' +
104
+ 'Claude Code / Codex, and re-copies the skills for the other agents — overwriting the managed ' +
105
+ 'files and pruning what was dropped upstream (git shows the diff). Files you wrote yourself are ' +
106
+ 'left untouched.';
107
+ SkillsUpdateCommand.flags = {
108
+ ref: core_1.Flags.string({ description: 'Marketplace version (git ref).', default: 'main' }),
109
+ };
110
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXBkYXRlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NvbW1hbmRzL3NraWxscy91cGRhdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFFQSxzQ0FBb0M7QUFFcEMsOEVBQXFEO0FBQ3JELHlFQW1COEM7QUFFOUMsTUFBcUIsbUJBQW9CLFNBQVEsMEJBQWU7SUFXOUQsS0FBSyxDQUFDLEdBQUc7UUFDUCxNQUFNLEVBQUUsS0FBSyxFQUFFLEdBQUcsTUFBTSxJQUFJLENBQUMsS0FBSyxDQUFDLG1CQUFtQixDQUFDLENBQUM7UUFFeEQsTUFBTSxRQUFRLEdBQUcsSUFBQSw2QkFBWSxHQUFFLENBQUM7UUFDaEMsSUFBSSxDQUFDLFFBQVEsRUFBRTtZQUNiLElBQUksQ0FBQyxNQUFNLENBQUMsS0FBSyxDQUFDLHNDQUFzQyxDQUFDLENBQUM7WUFDMUQsSUFBSSxDQUFDLE1BQU0sQ0FBQyxHQUFHLENBQUMsYUFBYSxJQUFJLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxvQkFBb0IsQ0FBQyxTQUFTLENBQU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
1
+ /**
2
+ * Shared logic for `skills:init` / `skills:update`.
3
+ *
4
+ * Two distribution routes, because coding agents split in two families:
5
+ *
6
+ * - Agents with a native plugin system (Claude Code, Codex) → we drive THEIR CLI
7
+ * (`claude plugin …` / `codex plugin …`). They fetch, version, auto-update and wire the
8
+ * Forest docs MCP themselves, and the user gets the plugin's slash commands too. Nothing
9
+ * is copied into the repo.
10
+ * - Agents that only discover `SKILL.md` files (Cursor, OpenCode, …) → we copy the same
11
+ * plugins' skills into `.agents/skills/`, the cross-agent convention they all read, so both
12
+ * routes deliver the same set.
13
+ *
14
+ * The marketplace repo is PUBLIC → no auth needed for the fetch, and both plugin CLIs read
15
+ * the same `.claude-plugin/marketplace.json` (verified against codex-cli 0.147.0), so one
16
+ * catalog serves every agent.
17
+ */
18
+ export declare const MARKETPLACE_REPO = "ForestAdmin/ai-marketplace";
19
+ export declare const MARKETPLACE_NAME = "forest-admin-ai";
20
+ /**
21
+ * The Forest plugins this command ships — the ONLY thing it decides, and it decides it once for
22
+ * both routes. These three are what "knowing Forest" means: how to build a back-office (`forest`),
23
+ * how to write agent code (`forest-code`), and how to look things up (`forest-docs`).
24
+ *
25
+ * `forest-mcp` is not one of them: it is a data-access server for querying a live project's
26
+ * records, not help for the developer, so it has no place in a command whose job is to teach the
27
+ * agent Forest. Anyone who wants it installs it themselves.
28
+ *
29
+ * Nothing below the plugin is filtered. There used to be a hand-picked list of skill NAMES, and it
30
+ * did real damage: the plugin route installs whole plugins, so a name left out still shipped
31
+ * there, and the skills cross-reference each other — `onboard` hands the production step to
32
+ * `deploy-heroku`, which the list excluded — leaving copy-route users with an `onboard` skill
33
+ * pointing at something never installed. A plugin is the unit of distribution and is coherent only
34
+ * as a whole; what it contains is the marketplace's call, not ours. Choosing plugins is a product
35
+ * decision, choosing their contents is drift waiting to happen.
36
+ */
37
+ export declare const FOREST_PLUGINS: string[];
38
+ /**
39
+ * The single skills dir on the copy route. `.agents/skills/` is the cross-agent convention:
40
+ * Cursor and OpenCode both read it (alongside their own `.cursor/`, `.opencode/`), and so does
41
+ * Codex. Claude Code is the one agent that does NOT read it — it reads `.claude/skills/` — but
42
+ * it is served by the plugin route, so a second copy would only duplicate its skills.
43
+ */
44
+ export declare const SKILLS_DIR = ".agents/skills";
45
+ /** Agents served by driving their own plugin CLI. */
46
+ export declare const PLUGIN_AGENTS: readonly ["claude", "codex"];
47
+ /** Agents served by copying SKILL.md files into SKILLS_DIR. */
48
+ export declare const COPY_AGENTS: readonly ["cursor", "opencode", "other"];
49
+ export declare const ALL_AGENTS: readonly ["claude", "codex", "cursor", "opencode", "other"];
50
+ export type PluginAgent = (typeof PLUGIN_AGENTS)[number];
51
+ export type Agent = (typeof ALL_AGENTS)[number];
52
+ export declare const AGENT_LABELS: Record<Agent, string>;
53
+ export declare const isPluginAgent: (agent: string) => agent is "claude" | "codex";
54
+ export declare const MANIFEST_PATH = ".forest/skills-manifest.json";
55
+ /** Context files, per agent. AGENTS.md is the cross-agent standard (Codex, Cursor, OpenCode). */
56
+ export declare function contextFileFor(agent: Agent): string;
57
+ /**
58
+ * The Forest block merged into a context file, describing every route that feeds THAT file.
59
+ *
60
+ * Takes the agents rather than one agent because a single file often serves both routes: AGENTS.md
61
+ * is Codex's (plugin) and Cursor's and OpenCode's (copy). Writing one block per agent would have
62
+ * the second merge replace the first — same delimiters — leaving the file describing only whichever
63
+ * route ran last.
64
+ */
65
+ export declare function forestBlock(agents: Agent[]): string;
66
+ /** Group agents by the context file they write to, so each file gets exactly one merged block. */
67
+ export declare function contextFileGroups(agents: Agent[]): Map<string, Agent[]>;
68
+ export type Manifest = {
69
+ ref: string;
70
+ installedAt: string;
71
+ /** Absent on manifests written before the field existed — those are copy-route installs. */
72
+ agents?: string[];
73
+ /** The ref each agent's content came from. Absent on manifests that predate it, whose agents all
74
+ * came from `ref`. */
75
+ refs?: Record<string, string>;
76
+ files: string[];
77
+ };
78
+ /**
79
+ * Download + extract the marketplace tarball at `ref`. Returns the extracted root dir and a
80
+ * `cleanup` the caller must run (in a finally) to delete the temp dir — otherwise every
81
+ * init/update leaks a full copy of the marketplace under the OS temp dir.
82
+ *
83
+ * Only the copy route needs this: the plugin CLIs do their own fetching.
84
+ */
85
+ export declare function fetchMarketplace(ref?: string): Promise<{
86
+ root: string;
87
+ cleanup: () => void;
88
+ }>;
89
+ /** What a copy produced: files we wrote, and files we refused to overwrite because the user
90
+ * wrote them (same path as a bundle file, but never managed by us). */
91
+ export type CopyResult = {
92
+ written: string[];
93
+ skipped: string[];
94
+ };
95
+ /**
96
+ * Recursively copy a directory. Never follows a symlink at the destination — it's replaced — so a
97
+ * planted link can't redirect a write outside the project.
98
+ *
99
+ * `isManaged` decides whether an EXISTING destination file may be overwritten. A file that is on
100
+ * disk but was never written by us is user-authored content that happens to share a bundle path:
101
+ * we leave it alone and report it, rather than silently destroying it.
102
+ */
103
+ export declare function copyDir(src: string, dest: string, isManaged?: (file: string) => boolean): CopyResult;
104
+ /**
105
+ * Copy the skills of every shipped plugin from the extracted repo into `SKILLS_DIR`.
106
+ *
107
+ * The same `FOREST_PLUGINS` the plugin route installs — one list, so the two routes cannot drift.
108
+ * A plugin with no `skills/` is simply skipped rather than rejected: `forest-docs` legitimately
109
+ * carries only an MCP config, which this route cannot wire anyway. What must not pass silently is a
110
+ * bundle carrying no skill at all, so that is what the guard checks — a marketplace whose layout
111
+ * moved under us.
112
+ *
113
+ * `previousFiles` is the file list from the previous manifest (`null` on a first run). It bounds
114
+ * what we may claim as managed AND what we may overwrite: a file we never wrote is the user's,
115
+ * both on the skip path (claiming it would let a later prune delete it) and on the force path
116
+ * (overwriting it would destroy it outright).
117
+ */
118
+ export declare function installSkills(srcRoot: string, force: boolean, previousFiles: string[] | null): CopyResult;
119
+ /** From a manifest file list, the entries that live under the skills dir (normalized for Windows,
120
+ * where manifest paths use backslashes). These are the candidates for stale-pruning on a refresh. */
121
+ export declare function skillDirEntries(files: string[]): string[];
122
+ /**
123
+ * Delete managed skill files that existed before but are no longer produced (removed upstream).
124
+ * Set-diff of previous vs current, deleting only paths that still exist *and* are safely contained
125
+ * within the skills dir. Returns what it removed.
126
+ */
127
+ export declare function removeStaleSkillFiles(previousFiles: string[], currentFiles: string[]): string[];
128
+ /** Merge a delimited Forest block into a context file (CLAUDE.md / AGENTS.md) without
129
+ * clobbering the user's own content. Creates the file if absent. */
130
+ export declare function mergeBlock(file: string, content: string): void;
131
+ /** True if the agent's CLI is installed and runnable. */
132
+ export declare function hasPluginCli(agent: PluginAgent): boolean;
133
+ /** The exact command that installs one Forest plugin, for a user retrying a failure by hand. */
134
+ export declare function pluginInstallCommand(agent: PluginAgent, plugin: string): string;
135
+ export type PluginInstallResult = {
136
+ agent: PluginAgent;
137
+ installed: string[];
138
+ failed: string[];
139
+ };
140
+ /**
141
+ * Register the Forest marketplace with the agent's CLI and install the Forest plugins.
142
+ * Throws when the marketplace cannot be added at all (nothing else can work); a single plugin
143
+ * that fails to install is reported, not fatal — the others are still worth having.
144
+ */
145
+ export declare function installPlugins(agent: PluginAgent, ref?: string): PluginInstallResult;
146
+ /**
147
+ * Refresh already-installed plugins (the plugin-route equivalent of re-copying files).
148
+ *
149
+ * Re-running `install` is not a refresh on Claude Code: it answers "already installed", exits 0 and
150
+ * fetches nothing. So its catalog is pulled first, then each plugin is installed (a no-op unless it
151
+ * was removed by hand) and updated. Codex keeps the re-install path.
152
+ */
153
+ export declare function upgradePlugins(agent: PluginAgent, ref?: string): PluginInstallResult;
154
+ /**
155
+ * Best-effort guess of which agents THIS REPO uses, so the prompt comes pre-checked and `--agent`
156
+ * stays optional in scripted runs. A missing signal is not an error: the user can always tick a
157
+ * box or pass the flag.
158
+ *
159
+ * Repo signals win over an installed binary, and deliberately so: a developer who has every agent
160
+ * CLI on their machine would otherwise get all of them pre-checked in every repo, and confirming
161
+ * the prompt would install plugins they never asked for. The PATH is consulted only when the repo
162
+ * says nothing at all — the fresh-project case (`npx create-forest`), where "what you have
163
+ * installed" is the only signal there is.
164
+ */
165
+ export declare function detectAgents(): Agent[];
166
+ /**
167
+ * The agents a manifest records. One with no `agents` predates the field, when only the copy route
168
+ * existed. An empty list is recorded, not missing: reading it as a copy install would copy skills
169
+ * nobody picked.
170
+ */
171
+ export declare function manifestAgents(manifest: Manifest): Agent[];
172
+ /**
173
+ * The ref each recorded agent's content was installed from. `ref` alone cannot say it: a run that
174
+ * adds one agent leaves the others' content where it was, at whatever ref they came from.
175
+ */
176
+ export declare function manifestRefs(manifest: Manifest): Record<string, string>;
177
+ /** Copy-route agents share one skills dir, so refreshing it moves every one of them to `ref`. */
178
+ export declare function refsAfter(previous: Record<string, string>, refreshed: Agent[], recorded: Agent[], ref: string): Record<string, string>;
179
+ export declare function readManifest(): Manifest | null;
180
+ export declare function writeManifest(manifest: Manifest): void;
181
+ //# sourceMappingURL=skills-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills-manager.d.ts","sourceRoot":"","sources":["../../../src/services/skills/skills-manager.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;GAgBG;AAEH,eAAO,MAAM,gBAAgB,+BAA+B,CAAC;AAC7D,eAAO,MAAM,gBAAgB,oBAAoB,CAAC;AAElD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,cAAc,UAA2C,CAAC;AAEvE;;;;;GAKG;AACH,eAAO,MAAM,UAAU,mBAAmB,CAAC;AAE3C,qDAAqD;AACrD,eAAO,MAAM,aAAa,8BAA+B,CAAC;AAC1D,+DAA+D;AAC/D,eAAO,MAAM,WAAW,0CAA2C,CAAC;AACpE,eAAO,MAAM,UAAU,6DAA8C,CAAC;AAEtE,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AACzD,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhD,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAM9C,CAAC;AAEF,e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