@creator-notes/cnotes 0.149.2 → 0.150.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/.claude-plugin/plugin.json +1 -1
- package/dist/commands/init.js +15 -3
- package/dist/commands/skills.js +46 -2
- package/dist/lib/install-skill.js +25 -0
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -9,7 +9,7 @@ import { canWrite, chooseWorkspace, firstWriteLines, workspaceId, workspaceName
|
|
|
9
9
|
import { buildClaudeConfig } from "./mcp.js";
|
|
10
10
|
import { bold, dim, green, cyan, CHECK, ARROW, WARN } from "../lib/style.js";
|
|
11
11
|
import { installMcpConfig, getConfigPath } from "../lib/install-mcp.js";
|
|
12
|
-
import { hasAgentConfigDir, installSkill, getSkillDestPath, skillTargetLabel, SKILL_TARGETS, } from "../lib/install-skill.js";
|
|
12
|
+
import { hasAgentConfigDir, installSkill, getSkillDestPath, noAgentFolderLines, skillTargetLabel, SKILL_TARGETS, } from "../lib/install-skill.js";
|
|
13
13
|
import { installClaudeSessionHook, isClaudeSessionHookInstalled, SESSION_HOOK_COMMAND, SESSION_HOOK_COMMAND_NPX, } from "../lib/install-hook.js";
|
|
14
14
|
function printBanner(version) {
|
|
15
15
|
const width = 41; // inner width of the box
|
|
@@ -407,9 +407,12 @@ async function runInitNonInteractive() {
|
|
|
407
407
|
}
|
|
408
408
|
}
|
|
409
409
|
// ── Install the agent skill(s) (best-effort, no prompt) ──
|
|
410
|
-
|
|
410
|
+
const skillTargets = SKILL_TARGETS.filter(hasAgentConfigDir);
|
|
411
|
+
for (const target of skillTargets) {
|
|
411
412
|
installSkillForTarget(target);
|
|
412
413
|
}
|
|
414
|
+
if (skillTargets.length === 0)
|
|
415
|
+
sayNoAgentFolder(cli);
|
|
413
416
|
// ── Conversation capture (Claude Code SessionStart hook) ──
|
|
414
417
|
// Best-effort + silent on failure: the env-var fallback still works, and a
|
|
415
418
|
// headless run must never fail setup over an optional capture hook.
|
|
@@ -441,8 +444,10 @@ async function runInitNonInteractive() {
|
|
|
441
444
|
async function maybeInstallSkill() {
|
|
442
445
|
// Install for whichever agents the user actually has (Claude Code, Codex, Cursor, Grok).
|
|
443
446
|
const targets = SKILL_TARGETS.filter(hasAgentConfigDir);
|
|
444
|
-
if (targets.length === 0)
|
|
447
|
+
if (targets.length === 0) {
|
|
448
|
+
sayNoAgentFolder(detectCnCommand());
|
|
445
449
|
return;
|
|
450
|
+
}
|
|
446
451
|
const labels = targets.map(skillTargetLabel).join(" and ");
|
|
447
452
|
console.log();
|
|
448
453
|
const { confirm } = await import("@inquirer/prompts");
|
|
@@ -456,6 +461,13 @@ async function maybeInstallSkill() {
|
|
|
456
461
|
installSkillForTarget(target);
|
|
457
462
|
}
|
|
458
463
|
}
|
|
464
|
+
/** No agent folder to install into: name the command that prints the instructions. */
|
|
465
|
+
function sayNoAgentFolder(cli) {
|
|
466
|
+
const [first, ...rest] = noAgentFolderLines(cli);
|
|
467
|
+
console.log(` ${WARN} ${first}`);
|
|
468
|
+
for (const line of rest)
|
|
469
|
+
console.log(` ${line.replace(`${cli} skills show`, cyan(`${cli} skills show`))}`);
|
|
470
|
+
}
|
|
459
471
|
/** Install (or refresh) the bundled skill for one agent, reporting the result. */
|
|
460
472
|
function installSkillForTarget(target) {
|
|
461
473
|
const label = skillTargetLabel(target);
|
package/dist/commands/skills.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from "fs";
|
|
2
|
+
import { dirname, join } from "path";
|
|
1
3
|
import { resolveBaseConfig } from "../lib/config.js";
|
|
2
|
-
import { EXIT_CODES, handleError, ValidationError } from "../lib/errors.js";
|
|
4
|
+
import { CliError, EXIT_CODES, handleError, ValidationError } from "../lib/errors.js";
|
|
3
5
|
import { outputJson } from "../lib/output.js";
|
|
4
|
-
import { SKILL_CATALOG, SKILL_TARGETS, resolveCatalogSkill, hasAgentConfigDir, installSkillFolder, installedSkillState, skillTargetLabel, } from "../lib/install-skill.js";
|
|
6
|
+
import { bundledSkillMdPath, SKILL_CATALOG, SKILL_TARGETS, resolveCatalogSkill, hasAgentConfigDir, installSkillFolder, installedSkillState, skillTargetLabel, } from "../lib/install-skill.js";
|
|
5
7
|
/**
|
|
6
8
|
* Decide which agents to install for. An explicit `--agent` wins; otherwise
|
|
7
9
|
* install for every agent the user already uses (its config dir exists), and
|
|
@@ -132,4 +134,46 @@ Examples:
|
|
|
132
134
|
handleError(error, cfg.json);
|
|
133
135
|
}
|
|
134
136
|
});
|
|
137
|
+
skills
|
|
138
|
+
.command("show [name]")
|
|
139
|
+
.description("Print a bundled skill's SKILL.md (default: cnotes, the core instructions), for an agent with no skills folder")
|
|
140
|
+
.addHelpText("after", `
|
|
141
|
+
Prints the file exactly, so it can also be saved where your agent reads its instructions.
|
|
142
|
+
Where its references/ files are goes to stderr.
|
|
143
|
+
|
|
144
|
+
Examples:
|
|
145
|
+
$ cnotes skills show
|
|
146
|
+
$ cnotes skills show wayfind
|
|
147
|
+
$ cnotes skills show > AGENTS.md`)
|
|
148
|
+
.action((name) => {
|
|
149
|
+
const cfg = resolveBaseConfig(program.opts());
|
|
150
|
+
try {
|
|
151
|
+
const found = bundledSkillMdPath(name ?? "cnotes");
|
|
152
|
+
if (!found) {
|
|
153
|
+
const known = SKILL_CATALOG.map((s) => s.name).join(", ");
|
|
154
|
+
throw new ValidationError(`Unknown skill "${name}". Available: ${known}.`);
|
|
155
|
+
}
|
|
156
|
+
if (!existsSync(found.path)) {
|
|
157
|
+
throw new CliError(`Bundled skill not found at ${found.path}.`, EXIT_CODES.GENERIC, "Reinstall the CLI: npm install -g @creator-notes/cnotes@latest");
|
|
158
|
+
}
|
|
159
|
+
const markdown = readFileSync(found.path, "utf8");
|
|
160
|
+
const refDir = join(dirname(found.path), "references");
|
|
161
|
+
const references = existsSync(refDir)
|
|
162
|
+
? readdirSync(refDir).filter((f) => f.endsWith(".md")).sort().map((f) => join(refDir, f))
|
|
163
|
+
: [];
|
|
164
|
+
// The file is the answer, so it prints as markdown even when piped
|
|
165
|
+
// (every other command turns to JSON there); JSON only when asked.
|
|
166
|
+
if (program.opts().json || process.env.CNOTES_JSON === "1") {
|
|
167
|
+
outputJson({ name: found.name, path: found.path, markdown, references });
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
process.stdout.write(markdown);
|
|
171
|
+
if (references.length > 0) {
|
|
172
|
+
process.stderr.write(`\nThe references/ files this skill points to are in ${refDir}: read one when SKILL.md names it.\n`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
handleError(error, cfg.json);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
135
179
|
}
|
|
@@ -221,6 +221,31 @@ function bundledSkillDir(name) {
|
|
|
221
221
|
return resolve(homedir(), ".cnotes", "bundled-skills", "missing", name);
|
|
222
222
|
return resolve(root, name);
|
|
223
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* The SKILL.md of a bundled skill in this install: `cnotes` (the core skill,
|
|
226
|
+
* the default) or a catalog name or alias. Null for a name this CLI does not
|
|
227
|
+
* ship. `cnotes skills show` prints it.
|
|
228
|
+
*/
|
|
229
|
+
export function bundledSkillMdPath(name = "cnotes") {
|
|
230
|
+
const q = name.trim().toLowerCase();
|
|
231
|
+
if (q === "cnotes" || q === "cn")
|
|
232
|
+
return { name: "cnotes", path: getBundledSkillPath() };
|
|
233
|
+
const skill = resolveCatalogSkill(q);
|
|
234
|
+
return skill ? { name: skill.name, path: resolve(bundledSkillDir(skill.name), "SKILL.md") } : null;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* What init says when this home holds none of the agent folders it installs
|
|
238
|
+
* into: an agent it does not know, or a Grok Bot computer without ~/.grok.
|
|
239
|
+
* Without it the agent starts its first write knowing only `--help`.
|
|
240
|
+
*/
|
|
241
|
+
export function noAgentFolderLines(cli) {
|
|
242
|
+
const agents = SKILL_TARGETS.map(skillTargetLabel);
|
|
243
|
+
const named = `${agents.slice(0, -1).join(", ")} or ${agents[agents.length - 1]}`;
|
|
244
|
+
return [
|
|
245
|
+
`No ${named} folder in this home directory, so no skill file was installed.`,
|
|
246
|
+
` Read the instructions before the first write: ${cli} skills show`,
|
|
247
|
+
];
|
|
248
|
+
}
|
|
224
249
|
/** Where a skill folder should be copied for a given agent. */
|
|
225
250
|
function skillFolderDest(name, target) {
|
|
226
251
|
return resolve(agentConfigDir(target), "skills", name);
|