@futurelastic/colab-handbook 1.18.0-rc.6 → 1.18.0-rc.7
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/README.md +16 -0
- package/README.vi.md +15 -0
- package/package.json +1 -1
- package/tools/lib/engines.js +53 -1
- package/tools/lib/install-check.js +63 -4
package/README.md
CHANGED
|
@@ -317,11 +317,27 @@ linked, so an existing machine changes nothing. Finding none, it installs for
|
|
|
317
317
|
Claude Code and says so. The per-runtime facts live in [`engines/`](engines/),
|
|
318
318
|
one file each — that folder is the source for the table above.
|
|
319
319
|
|
|
320
|
+
**Sessions that run in a private home** never see a user-level folder. For
|
|
321
|
+
those, copy the skills into the repo itself:
|
|
322
|
+
|
|
323
|
+
```sh
|
|
324
|
+
./install.sh --repo ~/code/app --engine opencode # → ~/code/app/.opencode/skills
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Every skill is copied as plain files (a linked folder or file is
|
|
328
|
+
dereferenced, never linked), with a manifest of what was copied. The command
|
|
329
|
+
prints each file it wrote, so you can commit them. A re-run refreshes the
|
|
330
|
+
copies the repo has not edited and leaves edited ones alone. `--check` reports
|
|
331
|
+
the copy and its version, and marks it ✗ behind once a skill changes in the
|
|
332
|
+
clone. Only agent runtimes whose `engines/` file names a `project_skills_dir`
|
|
333
|
+
have this route; today that is opencode.
|
|
334
|
+
|
|
320
335
|
| Flag | What it does |
|
|
321
336
|
|---|---|
|
|
322
337
|
| *(none)* | Symlink `skills/` into each chosen agent runtime's user-level folder, so they are available in every repo you open. Asks at a terminal; otherwise keeps what is linked (see [*Choose your agent runtime*](#choose-your-agent-runtime)). |
|
|
323
338
|
| `--engine <id>[,<id>]` | Install for these agent runtimes (`claude`, `codex`, `opencode` — the files in `engines/`), no question asked. |
|
|
324
339
|
| `--skills-dir <path>` | Also install into this folder, for an agent `engines/` does not know. |
|
|
340
|
+
| `--repo <path> --engine <id>` | Instead of a user-level install, **copy** the skills into that repo's project skills folder, for sessions that run in a private home. Prints the files to commit. |
|
|
325
341
|
| `--tools` | The `colab` CLI twice: a **symlink** at `~/.local/bin/colab` for your sessions (it prints the `PATH` line if needed), and a stamped **frozen copy** at `~/.colab/bin/colab` for always-on services. Also creates an empty `~/.colab/state.json` if there is none. |
|
|
326
342
|
| `--hooks` | Point this clone's git at `.githooks/`: a gitleaks secret scan and an identity scan whose vocabulary you keep outside every repo (see [`templates/README.md`](templates/README.md)). |
|
|
327
343
|
| `--fleet` | Seed `~/.colab/repos.txt` with format notes only, if absent. It stays machine-local because it names your private repos; `colab register` fills it. |
|
package/README.vi.md
CHANGED
|
@@ -316,11 +316,26 @@ sẵn, nên máy đã cài không thay đổi gì. Không thấy agent runtime n
|
|
|
316
316
|
Code và nói rõ điều đó. Thông tin từng agent runtime nằm trong [`engines/`](engines/),
|
|
317
317
|
mỗi agent runtime một file — thư mục đó là nguồn của bảng trên.
|
|
318
318
|
|
|
319
|
+
**Phiên chạy trong một home riêng** không bao giờ thấy thư mục cấp user. Với
|
|
320
|
+
những phiên đó, hãy chép skill vào chính repo:
|
|
321
|
+
|
|
322
|
+
```sh
|
|
323
|
+
./install.sh --repo ~/code/app --engine opencode # → ~/code/app/.opencode/skills
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
Mỗi skill được chép thành file thường (thư mục hay file là link thì được chép
|
|
327
|
+
nội dung, không bao giờ để link), kèm một manifest ghi những gì đã chép. Lệnh in
|
|
328
|
+
ra từng file nó đã ghi để bạn commit. Chạy lại thì làm mới các bản chép mà repo
|
|
329
|
+
chưa sửa, và để nguyên bản đã sửa. `--check` báo bản chép cùng phiên bản của nó,
|
|
330
|
+
và đánh ✗ (đã cũ) khi một skill trong clone thay đổi. Chỉ agent runtime nào có
|
|
331
|
+
file `engines/` khai `project_skills_dir` mới có đường này; hiện nay là opencode.
|
|
332
|
+
|
|
319
333
|
| Flag | Làm gì |
|
|
320
334
|
|---|---|
|
|
321
335
|
| *(không có)* | Symlink `skills/` vào thư mục cấp user của từng agent runtime đã chọn, để mở repo nào cũng có. Ở terminal thì hỏi; không thì giữ những gì đã link (xem [*Chọn agent runtime*](#chọn-agent-runtime)). |
|
|
322
336
|
| `--engine <id>[,<id>]` | Cài cho các agent runtime này (`claude`, `codex`, `opencode` — các file trong `engines/`), không hỏi. |
|
|
323
337
|
| `--skills-dir <path>` | Cài thêm vào thư mục này, cho agent mà `engines/` chưa biết. |
|
|
338
|
+
| `--repo <path> --engine <id>` | Thay cho cài cấp user: **chép** skill vào thư mục skill của project trong repo đó, cho phiên chạy trong một home riêng. In ra các file cần commit. |
|
|
324
339
|
| `--tools` | CLI `colab` cài hai lần: một **symlink** ở `~/.local/bin/colab` cho các phiên làm việc của bạn (in sẵn dòng `PATH` nếu cần), và một **bản đóng băng** có đóng dấu ở `~/.colab/bin/colab` cho các service luôn-bật. Đồng thời tạo `~/.colab/state.json` rỗng nếu chưa có. |
|
|
325
340
|
| `--hooks` | Trỏ git của clone này vào `.githooks/`: quét secret bằng gitleaks, và quét danh tính với danh sách từ khoá do bạn giữ NGOÀI mọi repo (xem [`templates/README.md`](templates/README.md)). |
|
|
326
341
|
| `--fleet` | Tạo `~/.colab/repos.txt` chỉ chứa ghi chú định dạng, nếu chưa có. Nó cố tình nằm trên máy vì nó ghi tên các repo private của bạn; `colab register` mới là thứ điền vào. |
|
package/package.json
CHANGED
package/tools/lib/engines.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
const fs = require('fs');
|
|
12
12
|
const path = require('path');
|
|
13
|
+
const crypto = require('crypto');
|
|
13
14
|
|
|
14
15
|
const REPEATABLE = new Set(['note', 'caveat']);
|
|
15
16
|
|
|
@@ -49,4 +50,55 @@ function rememberedDirs(colabHome) {
|
|
|
49
50
|
return text.split(/\r?\n/).map((l) => l.trim()).filter((l) => l && !l.startsWith('#'));
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Per-repo copies (#664): `install.sh --repo <path> --engine <id>` copies the skills into the agent
|
|
55
|
+
* runtime's PROJECT skills folder (`project_skills_dir:`), for a runtime whose sessions run in a
|
|
56
|
+
* private home and never see a user-level install. Each copy is remembered in
|
|
57
|
+
* <COLAB_HOME>/skills-copies as one `<engine id>|<repo path>` line, so `--check` finds it.
|
|
58
|
+
*/
|
|
59
|
+
function rememberedCopies(colabHome) {
|
|
60
|
+
let text = '';
|
|
61
|
+
try { text = fs.readFileSync(path.join(colabHome, 'skills-copies'), 'utf8'); } catch (_) { return []; }
|
|
62
|
+
return text.split(/\r?\n/).map((l) => l.trim()).filter((l) => l && !l.startsWith('#') && l.includes('|'))
|
|
63
|
+
.map((l) => { const i = l.indexOf('|'); return { engine: l.slice(0, i), repo: l.slice(i + 1) }; });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The manifest install.sh writes beside the copies: what it copied, at which version, with what content. */
|
|
67
|
+
const COPY_MANIFEST = '.colab-handbook-skills';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A skill folder's content digest — the same algorithm as install.sh's tree_digest, and
|
|
71
|
+
* install-sh.test.js holds the two to it: sha256 over one `<sha256 of file> <relative path>\n`
|
|
72
|
+
* line per regular file, links followed, paths sorted bytewise (LC_ALL=C sort). Null when absent.
|
|
73
|
+
*/
|
|
74
|
+
function treeDigest(dir) {
|
|
75
|
+
const files = [];
|
|
76
|
+
const walk = (rel) => {
|
|
77
|
+
for (const n of fs.readdirSync(path.join(dir, rel))) {
|
|
78
|
+
const r = rel ? `${rel}/${n}` : n;
|
|
79
|
+
const st = fs.statSync(path.join(dir, r)); // stat, not lstat: links are followed, as cp -RL does
|
|
80
|
+
if (st.isDirectory()) walk(r);
|
|
81
|
+
else if (st.isFile()) files.push(r);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
try { if (!fs.statSync(dir).isDirectory()) return null; walk(''); } catch (_) { return null; }
|
|
85
|
+
files.sort((a, b) => Buffer.compare(Buffer.from(a), Buffer.from(b)));
|
|
86
|
+
const sha = (buf) => crypto.createHash('sha256').update(buf).digest('hex');
|
|
87
|
+
return sha(files.map((f) => `${sha(fs.readFileSync(path.join(dir, f)))} ${f}\n`).join(''));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Parse a COPY_MANIFEST: its stamp version, engine, and `{ <skill>: <digest> }`. Null when absent. */
|
|
91
|
+
function readCopyManifest(dir) {
|
|
92
|
+
let text;
|
|
93
|
+
try { text = fs.readFileSync(path.join(dir, COPY_MANIFEST), 'utf8'); } catch (_) { return null; }
|
|
94
|
+
const out = { version: null, engine: null, skills: {} };
|
|
95
|
+
for (const l of text.split(/\r?\n/)) {
|
|
96
|
+
let m;
|
|
97
|
+
if ((m = /^#\s*colab-handbook:\s*skills\s*@\s*(\S+)/.exec(l))) out.version = m[1];
|
|
98
|
+
else if ((m = /^#\s*engine:\s*(\S+)/.exec(l))) out.engine = m[1];
|
|
99
|
+
else if ((m = /^([0-9a-f]{64}) (.+)$/.exec(l))) out.skills[m[2]] = m[1];
|
|
100
|
+
}
|
|
101
|
+
return out;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
module.exports = { parseConf, expandHome, listEngines, rememberedDirs, rememberedCopies, COPY_MANIFEST, treeDigest, readCopyManifest };
|
|
@@ -157,7 +157,9 @@ function checkFrozen({ root, colabHome }) {
|
|
|
157
157
|
function checkSkills({ root, home, colabHome }) {
|
|
158
158
|
const src = path.join(root, 'skills');
|
|
159
159
|
let skills = [];
|
|
160
|
-
|
|
160
|
+
// stat, not the Dirent: a skill folder that is itself a link is a skill too, as install.sh's `*/` glob says (#664).
|
|
161
|
+
const isDir = (p) => { try { return fs.statSync(p).isDirectory(); } catch (_) { return false; } };
|
|
162
|
+
try { skills = fs.readdirSync(src).filter((n) => isDir(path.join(src, n))).sort(); } catch (_) { /* none */ }
|
|
161
163
|
const all = engines.listEngines(root);
|
|
162
164
|
const byId = Object.fromEntries(all.map((e) => [e.id, e]));
|
|
163
165
|
const targets = all.filter((e) => e.skills_dir).map((e) => ({ e, dir: engines.expandHome(e.skills_dir, home) }));
|
|
@@ -203,11 +205,68 @@ function checkSkills({ root, home, colabHome }) {
|
|
|
203
205
|
for (const c of e.caveat || []) rows.push({ area: 'skills', severity: WARN, text: `${e.id}: ${c}` });
|
|
204
206
|
if (e.verified && /^no\b/.test(e.verified)) rows.push({ area: 'skills', severity: WARN, text: `${e.id}: engine file not verified by a run yet — ${e.verified.replace(/^no\s*[—-]?\s*/, '')}` });
|
|
205
207
|
}
|
|
206
|
-
|
|
208
|
+
const copies = checkCopies({ root, colabHome, skills, byId });
|
|
209
|
+
if (!rows.length && !copies.length) {
|
|
207
210
|
rows.push({ area: 'skills', severity: WARN, text: `not linked for any engine — ./install.sh asks which (or --engine <id> / --skills-dir <path>)` });
|
|
208
|
-
} else if (notInstalled.length) {
|
|
211
|
+
} else if (rows.length && notInstalled.length) {
|
|
209
212
|
rows.push({ area: 'skills', severity: OK, text: `not installed for: ${notInstalled.join(', ')} — fine if deliberate; ./install.sh --engine <id> adds one` });
|
|
210
213
|
}
|
|
214
|
+
// An engine installed both ways states its caveats once.
|
|
215
|
+
const seen = new Set();
|
|
216
|
+
return [...rows, ...copies].filter((r) => (seen.has(r.text) ? false : (seen.add(r.text), true)));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Per-repo copies (#664), every one remembered in <COLAB_HOME>/skills-copies: the same row as a
|
|
221
|
+
* user-level install, plus the version the copy was stamped with. Per skill, three digests decide —
|
|
222
|
+
* the manifest's (what install.sh wrote), the copy's now, and this clone's skill now:
|
|
223
|
+
* copy ≠ manifest → edited in the repo (⚠: the repo owns its copy; a re-run leaves it alone)
|
|
224
|
+
* clone ≠ manifest = copy → behind (✗: installed, and the handbook has moved on — re-run)
|
|
225
|
+
* in the clone, not copied → missing (⚠, a skill added since — re-run), as for a link
|
|
226
|
+
* copied, gone from clone → behind too (✗, removed upstream — a re-run deletes it)
|
|
227
|
+
*/
|
|
228
|
+
function checkCopies({ root, colabHome, skills, byId }) {
|
|
229
|
+
const src = path.join(root, 'skills');
|
|
230
|
+
const rows = [];
|
|
231
|
+
for (const { engine, repo } of engines.rememberedCopies(colabHome)) {
|
|
232
|
+
const e = byId[engine] || { id: engine, caveat: [] };
|
|
233
|
+
const rel = e.project_skills_dir;
|
|
234
|
+
const rerun = `./install.sh --repo '${repo}' --engine ${engine}`;
|
|
235
|
+
if (!rel) {
|
|
236
|
+
rows.push({ area: 'skills', severity: WARN, text: `${engine} copy in ${repo}: engines/${engine}.conf names no project_skills_dir any more — remove the line from ${path.join(colabHome, 'skills-copies')} if the copy is gone` });
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
239
|
+
const dir = path.join(repo, rel);
|
|
240
|
+
const man = engines.readCopyManifest(dir);
|
|
241
|
+
if (!man) {
|
|
242
|
+
rows.push({ area: 'skills', severity: WARN, text: `${engine} (${e.label || engine}) ${dir}: no ${engines.COPY_MANIFEST} — the copy is gone, or was not written by install.sh. Re-copy: ${rerun}, or drop the line from ${path.join(colabHome, 'skills-copies')}` });
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
const current = []; const behind = []; const edited = []; const missing = []; const removed = [];
|
|
246
|
+
for (const name of skills) {
|
|
247
|
+
const want = man.skills[name];
|
|
248
|
+
if (!want) { missing.push(name); continue; }
|
|
249
|
+
const now = engines.treeDigest(path.join(dir, name));
|
|
250
|
+
if (now !== want) { edited.push(name); continue; }
|
|
251
|
+
if (engines.treeDigest(path.join(src, name)) !== want) behind.push(name);
|
|
252
|
+
else current.push(name);
|
|
253
|
+
}
|
|
254
|
+
for (const name of Object.keys(man.skills)) {
|
|
255
|
+
if (skills.includes(name)) continue;
|
|
256
|
+
if (engines.treeDigest(path.join(dir, name)) === man.skills[name]) removed.push(name);
|
|
257
|
+
}
|
|
258
|
+
const parts = [`${current.length}/${skills.length} current`];
|
|
259
|
+
if (behind.length) parts.push(`BEHIND the handbook: ${behind.join(', ')} — re-run ${rerun}, then commit`);
|
|
260
|
+
if (removed.length) parts.push(`copies of skills the handbook no longer has: ${removed.join(', ')} — re-run ${rerun} to remove them`);
|
|
261
|
+
if (missing.length) parts.push(`missing ${missing.join(', ')} — re-run ${rerun}`);
|
|
262
|
+
if (edited.length) parts.push(`edited in the repo (left as is; a re-run will not refresh them): ${edited.join(', ')}`);
|
|
263
|
+
rows.push({
|
|
264
|
+
area: 'skills',
|
|
265
|
+
severity: (behind.length || removed.length) ? FAIL : (missing.length || edited.length) ? WARN : OK,
|
|
266
|
+
text: `${engine} (${e.label || engine}) ${dir} — copy @ ${man.version || 'unknown'}: ${parts.join('; ')}`,
|
|
267
|
+
});
|
|
268
|
+
for (const c of e.caveat || []) rows.push({ area: 'skills', severity: WARN, text: `${e.id}: ${c}` });
|
|
269
|
+
}
|
|
211
270
|
return rows;
|
|
212
271
|
}
|
|
213
272
|
|
|
@@ -352,5 +411,5 @@ if (require.main === module) {
|
|
|
352
411
|
|
|
353
412
|
module.exports = {
|
|
354
413
|
OK, WARN, FAIL,
|
|
355
|
-
dispatchedCommands, checkSkills, checkLink, checkFrozen, checkState, checkFleet, checkHooks, checkNotify, runChecks, render,
|
|
414
|
+
dispatchedCommands, checkSkills, checkCopies, checkLink, checkFrozen, checkState, checkFleet, checkHooks, checkNotify, runChecks, render,
|
|
356
415
|
};
|