@roilab/crm-cli 0.1.0 → 0.4.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/CHANGELOG.md +125 -6
- package/SKILL.md +256 -7
- package/SURFACE.txt +148 -3
- package/dist/bin/crm.js +26 -2
- package/dist/bin/crm.js.map +1 -1
- package/dist/src/commands/access.js +104 -0
- package/dist/src/commands/access.js.map +1 -0
- package/dist/src/commands/brief.js +52 -0
- package/dist/src/commands/brief.js.map +1 -0
- package/dist/src/commands/chat.js +203 -0
- package/dist/src/commands/chat.js.map +1 -0
- package/dist/src/commands/commands.js +89 -0
- package/dist/src/commands/commands.js.map +1 -0
- package/dist/src/commands/comment.js +1 -0
- package/dist/src/commands/comment.js.map +1 -1
- package/dist/src/commands/generic.js +335 -5
- package/dist/src/commands/generic.js.map +1 -1
- package/dist/src/commands/integrations.js +236 -0
- package/dist/src/commands/integrations.js.map +1 -0
- package/dist/src/commands/mention.js +139 -0
- package/dist/src/commands/mention.js.map +1 -0
- package/dist/src/commands/options.js +21 -1
- package/dist/src/commands/options.js.map +1 -1
- package/dist/src/commands/report.js +209 -0
- package/dist/src/commands/report.js.map +1 -0
- package/dist/src/commands/review.js +136 -0
- package/dist/src/commands/review.js.map +1 -1
- package/dist/src/commands/skill.js +836 -0
- package/dist/src/commands/skill.js.map +1 -0
- package/dist/src/commands/task.js +298 -4
- package/dist/src/commands/task.js.map +1 -1
- package/dist/src/commands/time.js +242 -0
- package/dist/src/commands/time.js.map +1 -0
- package/dist/src/lib/skillBundles.js +84 -0
- package/dist/src/lib/skillBundles.js.map +1 -0
- package/dist/src/lib/skillManifest.js +77 -0
- package/dist/src/lib/skillManifest.js.map +1 -0
- package/dist/src/lib/skillSidecar.js +69 -0
- package/dist/src/lib/skillSidecar.js.map +1 -0
- package/dist/src/lib/skillWriter.js +162 -0
- package/dist/src/lib/skillWriter.js.map +1 -0
- package/dist/src/transport/envelope.js +12 -2
- package/dist/src/transport/envelope.js.map +1 -1
- package/dist/src/transport/http.js +27 -0
- package/dist/src/transport/http.js.map +1 -1
- package/dist/src/transport/run.js +6 -0
- package/dist/src/transport/run.js.map +1 -1
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/server-nudge.js +57 -0
- package/dist/src/utils/server-nudge.js.map +1 -0
- package/dist/src/utils/version-check.js +68 -0
- package/dist/src/utils/version-check.js.map +1 -1
- package/package.json +2 -1
- package/skill-bundles/tools/ahrefs-tool/SKILL.md +134 -0
- package/skill-bundles/tools/brightlocal-tool/SKILL.md +154 -0
- package/skill-bundles/tools/dataforseo-tool/SKILL.md +118 -0
- package/skill-bundles/tools/google-analytics-tool/SKILL.md +143 -0
- package/skill-bundles/tools/google-search-console-tool/SKILL.md +133 -0
- package/skill-bundles/tools/local-falcon-tool/SKILL.md +142 -0
- package/skill-bundles/tools/localseodata-tool/SKILL.md +388 -0
- package/skill-bundles/tools/lsa-spy-tool/SKILL.md +113 -0
- package/skill-bundles/tools/screaming-frog-tool/SKILL.md +166 -0
- package/skill-bundles/tools/semrush-tool/SKILL.md +121 -0
- package/skill-bundles/tools/serpapi-tool/SKILL.md +148 -0
- package/skill-bundles/tools/task-preflight/SKILL.md +149 -0
- package/skill-bundles/tools/tool-routing/SKILL.md +59 -0
- package/skill-bundles/tools/whitespark-tool/SKILL.md +129 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/** `crm time` — log, list, start/stop timers, manage budgets. */
|
|
2
|
+
import { run } from "../transport/run.js";
|
|
3
|
+
import { outputFromFlags, parseDurationMs, readFlags } from "./options.js";
|
|
4
|
+
/** Coerce a CLI arg to a number-or-iso form the REST endpoint accepts. */
|
|
5
|
+
function coerceTimestamp(v) {
|
|
6
|
+
if (v === undefined)
|
|
7
|
+
return undefined;
|
|
8
|
+
// Pure-digit input → epoch ms; everything else passed through as ISO/string
|
|
9
|
+
// and validated server-side (the endpoint runs `new Date(v)` and refuses NaN).
|
|
10
|
+
return /^\d+$/.test(v) ? Number(v) : v;
|
|
11
|
+
}
|
|
12
|
+
export function registerTime(program) {
|
|
13
|
+
const time = program
|
|
14
|
+
.command("time")
|
|
15
|
+
.description("Tracking de tiempo — entradas, timer activo y presupuestos");
|
|
16
|
+
time
|
|
17
|
+
.command("log")
|
|
18
|
+
.description("Registra una entrada de tiempo manual")
|
|
19
|
+
.option("--task <id>", "id de tarea a la que enlazar")
|
|
20
|
+
.option("--description <text>", "descripción del trabajo")
|
|
21
|
+
.option("--date <YYYY-MM-DD>", "fecha (alt. a --started-at)")
|
|
22
|
+
.option("--started-at <epoch|iso>", "inicio explícito (epoch ms o ISO 8601) — recomendado para evitar colisiones")
|
|
23
|
+
.option("--ended-at <epoch|iso>", "fin (epoch ms o ISO 8601)")
|
|
24
|
+
.option("--duration <minutes>", "duración en minutos (alt. a --ended-at)", (v) => parseInt(v, 10))
|
|
25
|
+
.action(async (opts, cmd) => {
|
|
26
|
+
const flags = readFlags(cmd);
|
|
27
|
+
await run({
|
|
28
|
+
method: "POST",
|
|
29
|
+
path: "/time-entries",
|
|
30
|
+
request: {
|
|
31
|
+
body: {
|
|
32
|
+
taskId: opts.task,
|
|
33
|
+
description: opts.description,
|
|
34
|
+
entryDate: opts.date,
|
|
35
|
+
startedAt: coerceTimestamp(opts.startedAt),
|
|
36
|
+
endedAt: coerceTimestamp(opts.endedAt),
|
|
37
|
+
durationMinutes: opts.duration,
|
|
38
|
+
},
|
|
39
|
+
idempotencyKey: flags.idempotencyKey,
|
|
40
|
+
},
|
|
41
|
+
output: outputFromFlags(flags),
|
|
42
|
+
profile: flags.profile,
|
|
43
|
+
asAgent: flags.asAgent,
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
time
|
|
47
|
+
.command("list")
|
|
48
|
+
.description("Lista entradas de tiempo del usuario actual en un rango")
|
|
49
|
+
.option("--from <YYYY-MM-DD>", "inicio del rango (incl.)")
|
|
50
|
+
.option("--to <YYYY-MM-DD>", "fin del rango (incl.)")
|
|
51
|
+
.option("--user <id>", "otro usuario (sólo owner/admin)")
|
|
52
|
+
.action(async (opts, cmd) => {
|
|
53
|
+
const flags = readFlags(cmd);
|
|
54
|
+
if (!opts.from || !opts.to) {
|
|
55
|
+
process.stderr.write("error: --from y --to son obligatorios\n");
|
|
56
|
+
process.exit(2);
|
|
57
|
+
}
|
|
58
|
+
await run({
|
|
59
|
+
method: "GET",
|
|
60
|
+
path: "/time-entries",
|
|
61
|
+
request: {
|
|
62
|
+
query: {
|
|
63
|
+
startDate: opts.from,
|
|
64
|
+
endDate: opts.to,
|
|
65
|
+
userId: opts.user,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
output: outputFromFlags(flags),
|
|
69
|
+
profile: flags.profile,
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
time
|
|
73
|
+
.command("list-task")
|
|
74
|
+
.description("Lista las entradas de tiempo vinculadas a una tarea (sin filtro por fecha).")
|
|
75
|
+
.argument("<taskId>", "id de tarea (tsk_...)")
|
|
76
|
+
.action(async (taskId, _opts, cmd) => {
|
|
77
|
+
const flags = readFlags(cmd);
|
|
78
|
+
await run({
|
|
79
|
+
method: "GET",
|
|
80
|
+
path: `/tasks/${encodeURIComponent(taskId)}/time-entries`,
|
|
81
|
+
output: outputFromFlags(flags),
|
|
82
|
+
profile: flags.profile,
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
time
|
|
86
|
+
.command("status")
|
|
87
|
+
.description("Muestra el timer activo del usuario (si lo hay)")
|
|
88
|
+
.action(async (_opts, cmd) => {
|
|
89
|
+
const flags = readFlags(cmd);
|
|
90
|
+
await run({
|
|
91
|
+
method: "GET",
|
|
92
|
+
path: "/timer",
|
|
93
|
+
output: outputFromFlags(flags),
|
|
94
|
+
profile: flags.profile,
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
time
|
|
98
|
+
.command("start")
|
|
99
|
+
.description("Inicia un timer (detiene cualquier otro activo y emite su entrada)")
|
|
100
|
+
.option("--task <id>", "id de tarea a la que vincular el timer")
|
|
101
|
+
.option("--description <text>", "descripción opcional")
|
|
102
|
+
.action(async (opts, cmd) => {
|
|
103
|
+
const flags = readFlags(cmd);
|
|
104
|
+
await run({
|
|
105
|
+
method: "POST",
|
|
106
|
+
path: "/timer/start",
|
|
107
|
+
request: {
|
|
108
|
+
body: { taskId: opts.task, description: opts.description },
|
|
109
|
+
idempotencyKey: flags.idempotencyKey,
|
|
110
|
+
},
|
|
111
|
+
output: outputFromFlags(flags),
|
|
112
|
+
profile: flags.profile,
|
|
113
|
+
asAgent: flags.asAgent,
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
time
|
|
117
|
+
.command("stop")
|
|
118
|
+
.description("Detiene el timer activo y crea la entrada de tiempo")
|
|
119
|
+
.option("--description <text>", "sobrescribe la descripción guardada")
|
|
120
|
+
.action(async (opts, cmd) => {
|
|
121
|
+
const flags = readFlags(cmd);
|
|
122
|
+
await run({
|
|
123
|
+
method: "POST",
|
|
124
|
+
path: "/timer/stop",
|
|
125
|
+
request: {
|
|
126
|
+
body: { description: opts.description },
|
|
127
|
+
idempotencyKey: flags.idempotencyKey,
|
|
128
|
+
},
|
|
129
|
+
output: outputFromFlags(flags),
|
|
130
|
+
profile: flags.profile,
|
|
131
|
+
asAgent: flags.asAgent,
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
time
|
|
135
|
+
.command("discard")
|
|
136
|
+
.description("Descarta el timer activo sin guardar entrada")
|
|
137
|
+
.action(async (_opts, cmd) => {
|
|
138
|
+
const flags = readFlags(cmd);
|
|
139
|
+
await run({
|
|
140
|
+
method: "POST",
|
|
141
|
+
path: "/timer/discard",
|
|
142
|
+
request: {
|
|
143
|
+
body: {},
|
|
144
|
+
idempotencyKey: flags.idempotencyKey,
|
|
145
|
+
},
|
|
146
|
+
output: outputFromFlags(flags),
|
|
147
|
+
profile: flags.profile,
|
|
148
|
+
asAgent: flags.asAgent,
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
time
|
|
152
|
+
.command("update")
|
|
153
|
+
.description("Actualiza una entrada de tiempo (duración, descripción o tarea)")
|
|
154
|
+
.argument("<id>", "id de la entrada (timeEntries)")
|
|
155
|
+
.option("--started-at <epoch|iso>", "nuevo inicio")
|
|
156
|
+
.option("--ended-at <epoch|iso>", "nuevo fin")
|
|
157
|
+
.option("--description <text>", "nueva descripción")
|
|
158
|
+
.option("--task <id>", "re-asignar a otra tarea")
|
|
159
|
+
.action(async (id, opts, cmd) => {
|
|
160
|
+
const flags = readFlags(cmd);
|
|
161
|
+
await run({
|
|
162
|
+
method: "PATCH",
|
|
163
|
+
path: `/time-entries/${encodeURIComponent(id)}`,
|
|
164
|
+
request: {
|
|
165
|
+
body: {
|
|
166
|
+
startedAt: coerceTimestamp(opts.startedAt),
|
|
167
|
+
endedAt: coerceTimestamp(opts.endedAt),
|
|
168
|
+
description: opts.description,
|
|
169
|
+
taskId: opts.task,
|
|
170
|
+
},
|
|
171
|
+
idempotencyKey: flags.idempotencyKey,
|
|
172
|
+
},
|
|
173
|
+
output: outputFromFlags(flags),
|
|
174
|
+
profile: flags.profile,
|
|
175
|
+
waitForApproval: flags.waitForApproval,
|
|
176
|
+
waitTimeoutMs: parseDurationMs(flags.timeout),
|
|
177
|
+
asAgent: flags.asAgent,
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
time
|
|
181
|
+
.command("delete")
|
|
182
|
+
.description("Soft-delete de una entrada de tiempo")
|
|
183
|
+
.argument("<id>", "id de la entrada")
|
|
184
|
+
.option("--reason <text>", "motivo (queda en el audit trail)")
|
|
185
|
+
.action(async (id, opts, cmd) => {
|
|
186
|
+
const flags = readFlags(cmd);
|
|
187
|
+
await run({
|
|
188
|
+
method: "DELETE",
|
|
189
|
+
path: `/time-entries/${encodeURIComponent(id)}`,
|
|
190
|
+
request: {
|
|
191
|
+
body: { reason: opts.reason },
|
|
192
|
+
idempotencyKey: flags.idempotencyKey,
|
|
193
|
+
},
|
|
194
|
+
output: outputFromFlags(flags),
|
|
195
|
+
profile: flags.profile,
|
|
196
|
+
asAgent: flags.asAgent,
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
time
|
|
200
|
+
.command("hours")
|
|
201
|
+
.description("Horas registradas por empleado × cliente para un mes (billing)")
|
|
202
|
+
.argument("<period>", "mes en formato YYYY-MM")
|
|
203
|
+
.option("--employee <email>", "filtra por email de empleado")
|
|
204
|
+
.action(async (period, opts, cmd) => {
|
|
205
|
+
const flags = readFlags(cmd);
|
|
206
|
+
await run({
|
|
207
|
+
method: "GET",
|
|
208
|
+
path: "/hours",
|
|
209
|
+
request: {
|
|
210
|
+
query: { period_ym: period, employee_email: opts.employee },
|
|
211
|
+
},
|
|
212
|
+
output: outputFromFlags(flags),
|
|
213
|
+
profile: flags.profile,
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
time
|
|
217
|
+
.command("budgets")
|
|
218
|
+
.description("Lista los presupuestos de tiempo del workspace")
|
|
219
|
+
.action(async (_opts, cmd) => {
|
|
220
|
+
const flags = readFlags(cmd);
|
|
221
|
+
await run({
|
|
222
|
+
method: "GET",
|
|
223
|
+
path: "/time-budgets",
|
|
224
|
+
output: outputFromFlags(flags),
|
|
225
|
+
profile: flags.profile,
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
time
|
|
229
|
+
.command("usage")
|
|
230
|
+
.description("Uso actual de un presupuesto (período activo)")
|
|
231
|
+
.argument("<id>", "id del presupuesto (timeBudgets)")
|
|
232
|
+
.action(async (id, _opts, cmd) => {
|
|
233
|
+
const flags = readFlags(cmd);
|
|
234
|
+
await run({
|
|
235
|
+
method: "GET",
|
|
236
|
+
path: `/time-budgets/${encodeURIComponent(id)}/usage`,
|
|
237
|
+
output: outputFromFlags(flags),
|
|
238
|
+
profile: flags.profile,
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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AC5D;YACD,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC;YAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC,CACF,CAAC;IAEJ,IAAI;SACD,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,gDAAgD,CAAC;SAC7D,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,GAAY,EAAE,EAAE;QACpC,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,GAAG,CAAC;YACR,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,eAAe;YACrB,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC;YAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEL,IAAI;SACD,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,+CAA+C,CAAC;SAC5D,QAAQ,CAAC,MAAM,EAAE,kCAAkC,CAAC;SACpD,MAAM,CAAC,KAAK,EAAE,EAAU,EAAE,KAAK,EAAE,GAAY,EAAE,EAAE;QAChD,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;QAC7B,MAAM,GAAG,CAAC;YACR,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,iBAAiB,kBAAkB,CAAC,EAAE,CAAC,QAAQ;YACrD,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC;YAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;SACvB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static skill bundle loader for `crm skill init`.
|
|
3
|
+
*
|
|
4
|
+
* The CLI ships with a `skill-bundles/` folder at the package root (see
|
|
5
|
+
* `package.json#files`). Each entry is a ready-to-drop-in `SKILL.md` (plus
|
|
6
|
+
* optional resources) — today we only ship the `tools/` bundle, covering
|
|
7
|
+
* external-tool docs (Screaming Frog, Ahrefs, BrightLocal, etc.) that don't
|
|
8
|
+
* benefit from Convex revisions.
|
|
9
|
+
*
|
|
10
|
+
* The resolver walks up from this file's runtime location to find the bundle
|
|
11
|
+
* folder whether the CLI runs from source (`cli/src/lib/...`), from the
|
|
12
|
+
* compiled dist (`cli/dist/src/lib/...`), or from an npm install
|
|
13
|
+
* (`node_modules/@roilab/crm-cli/dist/src/lib/...`).
|
|
14
|
+
*/
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
import { dirname, join, resolve } from "node:path";
|
|
17
|
+
import { existsSync, readFileSync, readdirSync, statSync, } from "node:fs";
|
|
18
|
+
/**
|
|
19
|
+
* Walk up from the CLI's current runtime location looking for `skill-bundles/`.
|
|
20
|
+
* Supports source runs, built dist, and node_modules installs.
|
|
21
|
+
*/
|
|
22
|
+
export function findBundleRoot(kind) {
|
|
23
|
+
const thisDir = dirname(fileURLToPath(import.meta.url));
|
|
24
|
+
const candidates = [];
|
|
25
|
+
let dir = thisDir;
|
|
26
|
+
for (let i = 0; i < 8; i++) {
|
|
27
|
+
candidates.push(join(dir, "skill-bundles", kind));
|
|
28
|
+
const parent = resolve(dir, "..");
|
|
29
|
+
if (parent === dir)
|
|
30
|
+
break;
|
|
31
|
+
dir = parent;
|
|
32
|
+
}
|
|
33
|
+
for (const c of candidates) {
|
|
34
|
+
if (existsSync(c) && statSync(c).isDirectory())
|
|
35
|
+
return c;
|
|
36
|
+
}
|
|
37
|
+
throw new Error(`No se encontró skill-bundles/${kind} desde ${thisDir}. Reinstala la CLI o comprueba que 'skill-bundles' esté en el paquete npm.`);
|
|
38
|
+
}
|
|
39
|
+
/** List every `*-tool` skill shipped in the `tools/` bundle. */
|
|
40
|
+
export function listBundleSkills(kind) {
|
|
41
|
+
const root = findBundleRoot(kind);
|
|
42
|
+
const out = [];
|
|
43
|
+
for (const slug of readdirSync(root)) {
|
|
44
|
+
const folder = join(root, slug);
|
|
45
|
+
let st;
|
|
46
|
+
try {
|
|
47
|
+
st = statSync(folder);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (!st.isDirectory())
|
|
53
|
+
continue;
|
|
54
|
+
const skillMd = join(folder, "SKILL.md");
|
|
55
|
+
if (!existsSync(skillMd))
|
|
56
|
+
continue;
|
|
57
|
+
const content = readFileSync(skillMd, "utf8");
|
|
58
|
+
const resources = [];
|
|
59
|
+
// Walk nested files (non-SKILL.md) so multi-file bundles ship intact.
|
|
60
|
+
const walk = (dir, rel) => {
|
|
61
|
+
for (const name of readdirSync(dir)) {
|
|
62
|
+
const abs = join(dir, name);
|
|
63
|
+
const nextRel = rel ? `${rel}/${name}` : name;
|
|
64
|
+
const s = statSync(abs);
|
|
65
|
+
if (s.isDirectory()) {
|
|
66
|
+
walk(abs, nextRel);
|
|
67
|
+
}
|
|
68
|
+
else if (s.isFile() && nextRel !== "SKILL.md") {
|
|
69
|
+
resources.push({ path: nextRel, content: readFileSync(abs, "utf8") });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
walk(folder, "");
|
|
74
|
+
out.push({
|
|
75
|
+
slug,
|
|
76
|
+
skillMdPath: skillMd,
|
|
77
|
+
content,
|
|
78
|
+
resources,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
out.sort((a, b) => a.slug.localeCompare(b.slug));
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=skillBundles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skillBundles.js","sourceRoot":"","sources":["../../../src/lib/skillBundles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EACL,UAAU,EAC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GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACjD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manifest helpers for `crm skill pull` / `update` / `diff`.
|
|
3
|
+
*
|
|
4
|
+
* The manifest lives at `.claude/skills/.crm-manifest.json` (colocated with
|
|
5
|
+
* the skills Claude Code reads). It records which revision of each skill the
|
|
6
|
+
* local user has pulled so `crm skill update` can detect drift without
|
|
7
|
+
* re-downloading every skill.
|
|
8
|
+
*
|
|
9
|
+
* Shape:
|
|
10
|
+
* {
|
|
11
|
+
* "local-seo-audit": { "revisionId": "...", "pulledAt": 1713900000000 },
|
|
12
|
+
* ...
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
16
|
+
import { dirname, join } from "node:path";
|
|
17
|
+
export const SKILLS_DIR_NAME = ".claude/skills";
|
|
18
|
+
export const MANIFEST_FILE_NAME = ".crm-manifest.json";
|
|
19
|
+
const EMPTY_MANIFEST = { version: 1, skills: {} };
|
|
20
|
+
export function manifestPath(baseDir = process.cwd()) {
|
|
21
|
+
return join(baseDir, SKILLS_DIR_NAME, MANIFEST_FILE_NAME);
|
|
22
|
+
}
|
|
23
|
+
export function skillsDirPath(baseDir = process.cwd()) {
|
|
24
|
+
return join(baseDir, SKILLS_DIR_NAME);
|
|
25
|
+
}
|
|
26
|
+
export function skillFolderPath(slug, baseDir = process.cwd()) {
|
|
27
|
+
return join(baseDir, SKILLS_DIR_NAME, slug);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Heuristic check that the current directory looks like a project root.
|
|
31
|
+
* Prevents accidental `.claude/skills/` creation in random directories like
|
|
32
|
+
* `~` or `Desktop`. Returns the first marker found, or null if none.
|
|
33
|
+
*/
|
|
34
|
+
export function detectProjectRoot(baseDir = process.cwd()) {
|
|
35
|
+
const markers = [".git", "package.json", "convex", ".claude", "pyproject.toml", "Cargo.toml"];
|
|
36
|
+
for (const marker of markers) {
|
|
37
|
+
if (existsSync(join(baseDir, marker)))
|
|
38
|
+
return marker;
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
export function loadManifest(baseDir = process.cwd()) {
|
|
43
|
+
const path = manifestPath(baseDir);
|
|
44
|
+
if (!existsSync(path))
|
|
45
|
+
return { ...EMPTY_MANIFEST, skills: {} };
|
|
46
|
+
try {
|
|
47
|
+
const raw = readFileSync(path, "utf8");
|
|
48
|
+
const parsed = JSON.parse(raw);
|
|
49
|
+
if (parsed.version !== 1) {
|
|
50
|
+
throw new Error(`Manifest version ${parsed.version} no soportado. Actualiza la CLI.`);
|
|
51
|
+
}
|
|
52
|
+
return parsed;
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
if (err instanceof SyntaxError) {
|
|
56
|
+
throw new Error(`Manifest corrupto en ${path}: ${err.message}`);
|
|
57
|
+
}
|
|
58
|
+
throw err;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export function saveManifest(manifest, baseDir = process.cwd()) {
|
|
62
|
+
const path = manifestPath(baseDir);
|
|
63
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
64
|
+
writeFileSync(path, JSON.stringify(manifest, null, 2) + "\n", "utf8");
|
|
65
|
+
}
|
|
66
|
+
export function upsertEntry(manifest, slug, entry) {
|
|
67
|
+
return {
|
|
68
|
+
...manifest,
|
|
69
|
+
skills: { ...manifest.skills, [slug]: { slug, ...entry } },
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function removeEntry(manifest, slug) {
|
|
73
|
+
const next = { ...manifest.skills };
|
|
74
|
+
delete next[slug];
|
|
75
|
+
return { ...manifest, skills: next };
|
|
76
|
+
}
|
|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AM,UAAU,WAAW,CACzB,QAAkB,EAClB,IAAY,EACZ,KAAkC;IAElC,OAAO;QACL,GAAG,QAAQ;QACX,MAAM,EAAE,EAAE,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,EAAE;KAC3D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,QAAkB,EAAE,IAAY;IAC1D,MAAM,IAAI,GAAG,EAAE,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;IACpC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;IAClB,OAAO,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-skill sidecar for the committed mirror flow.
|
|
3
|
+
*
|
|
4
|
+
* Each `.claude/skills/<slug>/.skill.json` records the Convex revision the
|
|
5
|
+
* on-disk SKILL.md was pulled from. `crm skill pull` writes it; `crm skill
|
|
6
|
+
* push` reads it to detect drift (sidecar.revisionId vs the server's current
|
|
7
|
+
* `currentRevisionId`) and to know whether the on-disk content has been edited
|
|
8
|
+
* since the pull (`contentHash`).
|
|
9
|
+
*
|
|
10
|
+
* Unlike `.crm-manifest.json` (per-dev state, gitignored) the sidecar IS
|
|
11
|
+
* committed: it travels with the SKILL.md file so any clone of the repo can
|
|
12
|
+
* tell which revision the prose corresponds to.
|
|
13
|
+
*/
|
|
14
|
+
import { createHash } from "node:crypto";
|
|
15
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "node:fs";
|
|
16
|
+
import { dirname, join } from "node:path";
|
|
17
|
+
import { SKILLS_DIR_NAME } from "./skillManifest.js";
|
|
18
|
+
export const SIDECAR_FILE_NAME = ".skill.json";
|
|
19
|
+
export function sidecarPath(slug, baseDir = process.cwd()) {
|
|
20
|
+
return join(baseDir, SKILLS_DIR_NAME, slug, SIDECAR_FILE_NAME);
|
|
21
|
+
}
|
|
22
|
+
export function readSidecar(slug, baseDir = process.cwd()) {
|
|
23
|
+
const path = sidecarPath(slug, baseDir);
|
|
24
|
+
if (!existsSync(path))
|
|
25
|
+
return null;
|
|
26
|
+
const raw = readFileSync(path, "utf8");
|
|
27
|
+
let parsed;
|
|
28
|
+
try {
|
|
29
|
+
parsed = JSON.parse(raw);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
throw new Error(`Sidecar corrupto en ${path}: ${err instanceof Error ? err.message : String(err)}`);
|
|
33
|
+
}
|
|
34
|
+
const obj = parsed;
|
|
35
|
+
if (obj.version !== 1 ||
|
|
36
|
+
typeof obj.skillId !== "string" ||
|
|
37
|
+
typeof obj.slug !== "string" ||
|
|
38
|
+
typeof obj.revisionId !== "string" ||
|
|
39
|
+
typeof obj.contentHash !== "string") {
|
|
40
|
+
throw new Error(`Sidecar inválido en ${path}. Borra el archivo y vuelve a hacer pull.`);
|
|
41
|
+
}
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
44
|
+
export function writeSidecar(slug, payload, baseDir = process.cwd()) {
|
|
45
|
+
const path = sidecarPath(slug, baseDir);
|
|
46
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
47
|
+
const sidecar = { version: 1, slug, ...payload };
|
|
48
|
+
writeFileSync(path, JSON.stringify(sidecar, null, 2) + "\n", "utf8");
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* sha256 over the canonical representation of a skill's files. Stable across
|
|
52
|
+
* pulls so two clients hashing the same content land on the same digest.
|
|
53
|
+
*
|
|
54
|
+
* Length-prefix framing (`<pathLen>:<path>|<contentLen>:<content>`) eliminates
|
|
55
|
+
* any chance of two distinct file lists hashing the same way, even if a path
|
|
56
|
+
* contains spaces or a body contains the separator characters.
|
|
57
|
+
*/
|
|
58
|
+
export function computeContentHash(files) {
|
|
59
|
+
const sorted = [...files].sort((a, b) => a.path.localeCompare(b.path));
|
|
60
|
+
const hash = createHash("sha256");
|
|
61
|
+
for (const f of sorted) {
|
|
62
|
+
const pathBytes = Buffer.byteLength(f.path, "utf8");
|
|
63
|
+
const contentBytes = Buffer.byteLength(f.content, "utf8");
|
|
64
|
+
hash.update(`${pathBytes}:${f.path}|${contentBytes}:`);
|
|
65
|
+
hash.update(f.content);
|
|
66
|
+
}
|
|
67
|
+
return `sha256:${hash.digest("hex")}`;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=skillSidecar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skillSidecar.js","sourceRoot":"","sources":["../../../src/lib/skillSidecar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAc/C,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE;IAC/D,OAAO,IAAI,CAAC,OAAO,EAAE,eAAe,EAAE,IAAI,EAAE,iBAAiB,CAAC,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE;IAC/D,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACxC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACnC,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACvC,IAAI,MAAe,CAAC;IACpB,IAAI,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,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACvE,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;IAClC,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,MAAM,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACpD,MAAM,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC1D,IAAI,CAAC,MAAM,CAAC,GAAG,SAAS,IAAI,CAAC,CAAC,IAAI,IAAI,YAAY,GAAG,CAAC,CAAC;QACvD,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,UAAU,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atomic file writer for `crm skill pull`.
|
|
3
|
+
*
|
|
4
|
+
* A skill = 1 `SKILL.md` + 0..N resource files in nested directories. We
|
|
5
|
+
* write each file to a `.tmp.<random>` sibling first, then rename into place,
|
|
6
|
+
* so a crash mid-write never leaves a half-populated skill folder on disk.
|
|
7
|
+
*
|
|
8
|
+
* Every resource path is resolved + validated against the skill folder so a
|
|
9
|
+
* crafted path like `../../etc/passwd` from a compromised server can't
|
|
10
|
+
* escape `.claude/skills/<slug>/`.
|
|
11
|
+
*/
|
|
12
|
+
import { randomBytes } from "node:crypto";
|
|
13
|
+
import { mkdirSync, renameSync, writeFileSync, existsSync, statSync, readdirSync, unlinkSync, rmdirSync, rmSync } from "node:fs";
|
|
14
|
+
import { dirname, join, resolve, sep } from "node:path";
|
|
15
|
+
function randomSuffix() {
|
|
16
|
+
return randomBytes(4).toString("hex");
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Validate a resource path is safely within the skill folder. Rejects
|
|
20
|
+
* absolute paths, `..` traversal, and anything that would resolve outside
|
|
21
|
+
* the destination directory. Always normalises to forward slashes for the
|
|
22
|
+
* manifest but uses the OS-native separator on disk.
|
|
23
|
+
*/
|
|
24
|
+
function safeJoin(rootAbs, relPath) {
|
|
25
|
+
if (relPath.length === 0)
|
|
26
|
+
throw new Error("Ruta de recurso vacía.");
|
|
27
|
+
if (relPath.startsWith("/") || /^[A-Za-z]:/.test(relPath)) {
|
|
28
|
+
throw new Error(`Ruta absoluta rechazada: ${relPath}`);
|
|
29
|
+
}
|
|
30
|
+
const target = resolve(rootAbs, relPath);
|
|
31
|
+
const rootWithSep = rootAbs.endsWith(sep) ? rootAbs : rootAbs + sep;
|
|
32
|
+
if (target !== rootAbs && !target.startsWith(rootWithSep)) {
|
|
33
|
+
throw new Error(`La ruta \`${relPath}\` escapa del directorio del skill.`);
|
|
34
|
+
}
|
|
35
|
+
return target;
|
|
36
|
+
}
|
|
37
|
+
function atomicWrite(absPath, content) {
|
|
38
|
+
mkdirSync(dirname(absPath), { recursive: true });
|
|
39
|
+
const tmp = `${absPath}.tmp.${randomSuffix()}`;
|
|
40
|
+
writeFileSync(tmp, content, "utf8");
|
|
41
|
+
renameSync(tmp, absPath);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Remove files that we wrote on a previous pull but that the new revision no
|
|
45
|
+
* longer ships. Crucially, we only delete files whose relative path is in
|
|
46
|
+
* `previousManagedPaths` — anything else under the skill folder (user-added
|
|
47
|
+
* notes, local tweaks, `.env`, etc.) is left alone. Without this guard
|
|
48
|
+
* `crm skill pull` was a silent `rm` of every file under the folder.
|
|
49
|
+
*
|
|
50
|
+
* @param rootAbs Absolute path to the skill folder.
|
|
51
|
+
* @param keepRelPaths Files in the new revision (forward-slash, relative to rootAbs).
|
|
52
|
+
* @param previousManagedPaths Files we wrote on the last pull. Empty/undef → skip pruning entirely.
|
|
53
|
+
*/
|
|
54
|
+
export function removeOrphans(rootAbs, keepRelPaths, previousManagedPaths) {
|
|
55
|
+
const removed = [];
|
|
56
|
+
if (!existsSync(rootAbs))
|
|
57
|
+
return removed;
|
|
58
|
+
if (!previousManagedPaths || previousManagedPaths.length === 0) {
|
|
59
|
+
return removed;
|
|
60
|
+
}
|
|
61
|
+
for (const rel of previousManagedPaths) {
|
|
62
|
+
if (keepRelPaths.has(rel))
|
|
63
|
+
continue;
|
|
64
|
+
const abs = join(rootAbs, ...rel.split("/"));
|
|
65
|
+
if (!existsSync(abs))
|
|
66
|
+
continue;
|
|
67
|
+
try {
|
|
68
|
+
const st = statSync(abs);
|
|
69
|
+
if (st.isFile()) {
|
|
70
|
+
unlinkSync(abs);
|
|
71
|
+
removed.push(rel);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// Race or permissions — skip; better to leave a file than corrupt state.
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Best-effort: prune empty directories left behind by the deletes. Walk top
|
|
79
|
+
// down then check leaves; we only touch dirs descended from rootAbs and
|
|
80
|
+
// never delete rootAbs itself.
|
|
81
|
+
pruneEmptyDirs(rootAbs);
|
|
82
|
+
return removed;
|
|
83
|
+
}
|
|
84
|
+
function pruneEmptyDirs(rootAbs) {
|
|
85
|
+
const visit = (dir) => {
|
|
86
|
+
if (!existsSync(dir))
|
|
87
|
+
return true;
|
|
88
|
+
let empty = true;
|
|
89
|
+
for (const name of readdirSync(dir)) {
|
|
90
|
+
const abs = join(dir, name);
|
|
91
|
+
const st = statSync(abs);
|
|
92
|
+
if (st.isDirectory()) {
|
|
93
|
+
const childEmpty = visit(abs);
|
|
94
|
+
if (childEmpty) {
|
|
95
|
+
try {
|
|
96
|
+
rmdirSync(abs);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
empty = false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
empty = false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
empty = false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return empty;
|
|
111
|
+
};
|
|
112
|
+
visit(rootAbs);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Delete a skill folder recursively. Used by `crm skill remove`. Refuses to
|
|
116
|
+
* touch anything that isn't under `.claude/skills/<slug>/` — guards against a
|
|
117
|
+
* stray slug containing `..` or path separators slipping through.
|
|
118
|
+
*
|
|
119
|
+
* Returns `true` if the folder existed and was removed, `false` if nothing
|
|
120
|
+
* was there.
|
|
121
|
+
*/
|
|
122
|
+
export function removeSkillFolder(rootAbs, slug) {
|
|
123
|
+
if (!slug || slug.includes("/") || slug.includes("\\") || slug.includes("..")) {
|
|
124
|
+
throw new Error(`Slug inválido para borrado: ${slug}`);
|
|
125
|
+
}
|
|
126
|
+
if (!existsSync(rootAbs))
|
|
127
|
+
return false;
|
|
128
|
+
const st = statSync(rootAbs);
|
|
129
|
+
if (!st.isDirectory()) {
|
|
130
|
+
throw new Error(`Ruta esperada un directorio: ${rootAbs}`);
|
|
131
|
+
}
|
|
132
|
+
rmSync(rootAbs, { recursive: true, force: true });
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Write all files for a single skill atomically (per-file rename). Creates
|
|
137
|
+
* parent directories as needed; overwrites existing files. When previous
|
|
138
|
+
* managed paths are known and the new revision drops some of them, those
|
|
139
|
+
* specific files are pruned — never any other file in the folder.
|
|
140
|
+
*
|
|
141
|
+
* @param rootAbs Absolute path to `.claude/skills/<slug>/`
|
|
142
|
+
* @param slug Skill slug (for error messages only)
|
|
143
|
+
* @param files List of files to write (SKILL.md first by convention)
|
|
144
|
+
* @param opts Optional pruning controls.
|
|
145
|
+
*/
|
|
146
|
+
export function writeSkillFiles(rootAbs, slug, files, opts = {}) {
|
|
147
|
+
if (files.length === 0) {
|
|
148
|
+
throw new Error(`No hay archivos que escribir para \`${slug}\`.`);
|
|
149
|
+
}
|
|
150
|
+
mkdirSync(rootAbs, { recursive: true });
|
|
151
|
+
const written = [];
|
|
152
|
+
for (const f of files) {
|
|
153
|
+
const targetAbs = safeJoin(rootAbs, f.path);
|
|
154
|
+
atomicWrite(targetAbs, f.content);
|
|
155
|
+
written.push(f.path);
|
|
156
|
+
}
|
|
157
|
+
if (!opts.preserveAll) {
|
|
158
|
+
removeOrphans(rootAbs, new Set(files.map((f) => f.path)), opts.previousManagedPaths);
|
|
159
|
+
}
|
|
160
|
+
return { slug, folder: rootAbs, files: written };
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=skillWriter.js.map
|