@kntic/kntic 0.4.5 → 0.4.6
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/package.json +1 -1
- package/src/commands/update.js +10 -10
- package/src/commands/update.test.js +24 -24
- package/src/commands/usage.js +2 -2
package/package.json
CHANGED
package/src/commands/update.js
CHANGED
|
@@ -183,11 +183,11 @@ function extractLibOnly(tarball, destDir) {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
/**
|
|
186
|
-
* Extract .kntic/lib/**, .kntic/adrs/**, and .kntic/hooks/
|
|
186
|
+
* Extract .kntic/lib/**, .kntic/adrs/**, and .kntic/hooks/gia/internal/** from a tarball
|
|
187
187
|
* into the destination directory.
|
|
188
188
|
*
|
|
189
189
|
* - .kntic/lib and .kntic/adrs are **replaced** (cleared first, then extracted).
|
|
190
|
-
* - .kntic/hooks/
|
|
190
|
+
* - .kntic/hooks/gia/internal is **updated** (existing files are overwritten or new files
|
|
191
191
|
* added, but files not present in the archive are preserved).
|
|
192
192
|
* - .kntic/gia/weights.json is **replaced** if present in the archive.
|
|
193
193
|
*
|
|
@@ -197,20 +197,20 @@ function extractLibOnly(tarball, destDir) {
|
|
|
197
197
|
function extractUpdate(tarball, destDir) {
|
|
198
198
|
const libDir = path.join(destDir, ".kntic", "lib");
|
|
199
199
|
const adrsDir = path.join(destDir, ".kntic", "adrs");
|
|
200
|
-
const
|
|
200
|
+
const giaInternalDir = path.join(destDir, ".kntic", "hooks", "gia", "internal");
|
|
201
201
|
const giaDir = path.join(destDir, ".kntic", "gia");
|
|
202
202
|
|
|
203
203
|
// Ensure target directories exist
|
|
204
204
|
fs.mkdirSync(libDir, { recursive: true });
|
|
205
205
|
fs.mkdirSync(adrsDir, { recursive: true });
|
|
206
|
-
fs.mkdirSync(
|
|
206
|
+
fs.mkdirSync(giaInternalDir, { recursive: true });
|
|
207
207
|
fs.mkdirSync(giaDir, { recursive: true });
|
|
208
208
|
|
|
209
209
|
// Clear lib and adrs (full replacement)
|
|
210
210
|
clearDirectory(libDir);
|
|
211
211
|
clearDirectory(adrsDir);
|
|
212
212
|
|
|
213
|
-
// Note:
|
|
213
|
+
// Note: gia/internal hooks are NOT cleared — update semantics (overwrite/add, preserve others)
|
|
214
214
|
// Note: gia is NOT cleared — only weights.json is replaced
|
|
215
215
|
|
|
216
216
|
// Extract .kntic/lib/ and .kntic/adrs/ (guaranteed to be in the archive)
|
|
@@ -219,14 +219,14 @@ function extractUpdate(tarball, destDir) {
|
|
|
219
219
|
{ stdio: "pipe" }
|
|
220
220
|
);
|
|
221
221
|
|
|
222
|
-
// Extract .kntic/hooks/
|
|
222
|
+
// Extract .kntic/hooks/gia/internal/ separately — archive may not contain it
|
|
223
223
|
try {
|
|
224
224
|
execSync(
|
|
225
|
-
`tar xzf "${tarball}" -C "${destDir}" "./.kntic/hooks/
|
|
225
|
+
`tar xzf "${tarball}" -C "${destDir}" "./.kntic/hooks/gia/internal/"`,
|
|
226
226
|
{ stdio: "pipe" }
|
|
227
227
|
);
|
|
228
228
|
} catch (_) {
|
|
229
|
-
// No .kntic/hooks/
|
|
229
|
+
// No .kntic/hooks/gia/internal/ in the archive — that's fine
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
// Extract .kntic/gia/weights.json separately — archive may not contain it
|
|
@@ -256,7 +256,7 @@ async function update(options = {}) {
|
|
|
256
256
|
console.log("Updating .kntic/lib …");
|
|
257
257
|
extractLibOnly(tmpFile, ".");
|
|
258
258
|
} else {
|
|
259
|
-
console.log("Updating .kntic/lib, .kntic/adrs, .kntic/hooks/
|
|
259
|
+
console.log("Updating .kntic/lib, .kntic/adrs, .kntic/hooks/gia/internal, and .kntic/gia/weights.json …");
|
|
260
260
|
extractUpdate(tmpFile, ".");
|
|
261
261
|
}
|
|
262
262
|
|
|
@@ -270,7 +270,7 @@ async function update(options = {}) {
|
|
|
270
270
|
if (libOnly) {
|
|
271
271
|
console.log("Done. .kntic/lib updated successfully.");
|
|
272
272
|
} else {
|
|
273
|
-
console.log("Done. .kntic/lib, .kntic/adrs, .kntic/hooks/
|
|
273
|
+
console.log("Done. .kntic/lib, .kntic/adrs, .kntic/hooks/gia/internal, and .kntic/gia/weights.json updated successfully.");
|
|
274
274
|
}
|
|
275
275
|
}
|
|
276
276
|
|
|
@@ -216,13 +216,13 @@ describe("extractUpdate", () => {
|
|
|
216
216
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
217
217
|
});
|
|
218
218
|
|
|
219
|
-
it("extracts .kntic/lib, .kntic/adrs, and .kntic/hooks/
|
|
219
|
+
it("extracts .kntic/lib, .kntic/adrs, and .kntic/hooks/gia/internal from the archive", () => {
|
|
220
220
|
const tarball = createTarball(tmpDir, {
|
|
221
221
|
".kntic/lib/orchestrator.py": "# orchestrator\n",
|
|
222
222
|
".kntic/lib/skills/validator.py": "# validator\n",
|
|
223
223
|
".kntic/adrs/ADR-001.md": "# ADR 001\n",
|
|
224
224
|
".kntic/adrs/ADR-002.md": "# ADR 002\n",
|
|
225
|
-
".kntic/hooks/
|
|
225
|
+
".kntic/hooks/gia/internal/check.sh": "#!/bin/sh\necho check\n",
|
|
226
226
|
".kntic/MEMORY.MD": "# Memory\n",
|
|
227
227
|
"README.md": "# Hello\n",
|
|
228
228
|
});
|
|
@@ -249,13 +249,13 @@ describe("extractUpdate", () => {
|
|
|
249
249
|
"# ADR 002\n"
|
|
250
250
|
);
|
|
251
251
|
|
|
252
|
-
// hooks/
|
|
252
|
+
// hooks/gia/internal files must be extracted
|
|
253
253
|
assert.equal(
|
|
254
|
-
fs.readFileSync(path.join(destDir, ".kntic", "hooks", "
|
|
254
|
+
fs.readFileSync(path.join(destDir, ".kntic", "hooks", "gia", "internal", "check.sh"), "utf8"),
|
|
255
255
|
"#!/bin/sh\necho check\n"
|
|
256
256
|
);
|
|
257
257
|
|
|
258
|
-
// Files outside lib/adrs/hooks/
|
|
258
|
+
// Files outside lib/adrs/hooks/gia/internal must NOT be extracted
|
|
259
259
|
assert.ok(
|
|
260
260
|
!fs.existsSync(path.join(destDir, ".kntic", "MEMORY.MD")),
|
|
261
261
|
"MEMORY.MD must not be extracted"
|
|
@@ -296,47 +296,47 @@ describe("extractUpdate", () => {
|
|
|
296
296
|
);
|
|
297
297
|
});
|
|
298
298
|
|
|
299
|
-
it("updates .kntic/hooks/
|
|
300
|
-
const
|
|
301
|
-
fs.mkdirSync(
|
|
302
|
-
fs.writeFileSync(path.join(
|
|
303
|
-
fs.writeFileSync(path.join(
|
|
299
|
+
it("updates .kntic/hooks/gia/internal without clearing existing files (update semantics)", () => {
|
|
300
|
+
const giaInternalDir = path.join(destDir, ".kntic", "hooks", "gia", "internal");
|
|
301
|
+
fs.mkdirSync(giaInternalDir, { recursive: true });
|
|
302
|
+
fs.writeFileSync(path.join(giaInternalDir, "existing-hook.sh"), "#!/bin/sh\necho existing\n");
|
|
303
|
+
fs.writeFileSync(path.join(giaInternalDir, "shared-hook.sh"), "#!/bin/sh\necho old\n");
|
|
304
304
|
|
|
305
305
|
const tarball = createTarball(tmpDir, {
|
|
306
306
|
".kntic/lib/orchestrator.py": "# orchestrator\n",
|
|
307
307
|
".kntic/adrs/ADR-001.md": "# ADR 001\n",
|
|
308
|
-
".kntic/hooks/
|
|
309
|
-
".kntic/hooks/
|
|
308
|
+
".kntic/hooks/gia/internal/shared-hook.sh": "#!/bin/sh\necho new\n",
|
|
309
|
+
".kntic/hooks/gia/internal/new-hook.sh": "#!/bin/sh\necho added\n",
|
|
310
310
|
});
|
|
311
311
|
|
|
312
312
|
extractUpdate(tarball, destDir);
|
|
313
313
|
|
|
314
314
|
// Existing file NOT in archive must be preserved (update semantics, not replace)
|
|
315
315
|
assert.equal(
|
|
316
|
-
fs.readFileSync(path.join(
|
|
316
|
+
fs.readFileSync(path.join(giaInternalDir, "existing-hook.sh"), "utf8"),
|
|
317
317
|
"#!/bin/sh\necho existing\n",
|
|
318
318
|
"existing hook not in archive must be preserved"
|
|
319
319
|
);
|
|
320
320
|
|
|
321
321
|
// File in both archive and disk must be overwritten
|
|
322
322
|
assert.equal(
|
|
323
|
-
fs.readFileSync(path.join(
|
|
323
|
+
fs.readFileSync(path.join(giaInternalDir, "shared-hook.sh"), "utf8"),
|
|
324
324
|
"#!/bin/sh\necho new\n",
|
|
325
325
|
"shared hook must be overwritten with archive version"
|
|
326
326
|
);
|
|
327
327
|
|
|
328
328
|
// New file from archive must be added
|
|
329
329
|
assert.equal(
|
|
330
|
-
fs.readFileSync(path.join(
|
|
330
|
+
fs.readFileSync(path.join(giaInternalDir, "new-hook.sh"), "utf8"),
|
|
331
331
|
"#!/bin/sh\necho added\n",
|
|
332
332
|
"new hook from archive must be added"
|
|
333
333
|
);
|
|
334
334
|
});
|
|
335
335
|
|
|
336
|
-
it("works when archive has no .kntic/hooks/
|
|
337
|
-
const
|
|
338
|
-
fs.mkdirSync(
|
|
339
|
-
fs.writeFileSync(path.join(
|
|
336
|
+
it("works when archive has no .kntic/hooks/gia/internal directory", () => {
|
|
337
|
+
const giaInternalDir = path.join(destDir, ".kntic", "hooks", "gia", "internal");
|
|
338
|
+
fs.mkdirSync(giaInternalDir, { recursive: true });
|
|
339
|
+
fs.writeFileSync(path.join(giaInternalDir, "my-hook.sh"), "#!/bin/sh\necho mine\n");
|
|
340
340
|
|
|
341
341
|
const tarball = createTarball(tmpDir, {
|
|
342
342
|
".kntic/lib/orchestrator.py": "# orchestrator\n",
|
|
@@ -346,11 +346,11 @@ describe("extractUpdate", () => {
|
|
|
346
346
|
// Should not throw
|
|
347
347
|
extractUpdate(tarball, destDir);
|
|
348
348
|
|
|
349
|
-
// Existing
|
|
349
|
+
// Existing gia/internal hook must be preserved
|
|
350
350
|
assert.equal(
|
|
351
|
-
fs.readFileSync(path.join(
|
|
351
|
+
fs.readFileSync(path.join(giaInternalDir, "my-hook.sh"), "utf8"),
|
|
352
352
|
"#!/bin/sh\necho mine\n",
|
|
353
|
-
"existing
|
|
353
|
+
"existing gia/internal hook must be preserved when archive has no gia/internal"
|
|
354
354
|
);
|
|
355
355
|
|
|
356
356
|
// lib and adrs must still be extracted
|
|
@@ -408,7 +408,7 @@ describe("extractUpdate", () => {
|
|
|
408
408
|
);
|
|
409
409
|
});
|
|
410
410
|
|
|
411
|
-
it("preserves files outside .kntic/lib, .kntic/adrs, and .kntic/hooks/
|
|
411
|
+
it("preserves files outside .kntic/lib, .kntic/adrs, and .kntic/hooks/gia/internal", () => {
|
|
412
412
|
const knticDir = path.join(destDir, ".kntic");
|
|
413
413
|
fs.mkdirSync(knticDir, { recursive: true });
|
|
414
414
|
fs.writeFileSync(path.join(knticDir, "MEMORY.MD"), "# My memory\n");
|
|
@@ -417,7 +417,7 @@ describe("extractUpdate", () => {
|
|
|
417
417
|
const tarball = createTarball(tmpDir, {
|
|
418
418
|
".kntic/lib/orchestrator.py": "# orchestrator\n",
|
|
419
419
|
".kntic/adrs/ADR-001.md": "# ADR 001\n",
|
|
420
|
-
".kntic/hooks/
|
|
420
|
+
".kntic/hooks/gia/internal/check.sh": "#!/bin/sh\n",
|
|
421
421
|
".kntic/MEMORY.MD": "# Archive memory\n",
|
|
422
422
|
"README.md": "# Archive readme\n",
|
|
423
423
|
});
|
package/src/commands/usage.js
CHANGED
|
@@ -9,8 +9,8 @@ function usage() {
|
|
|
9
9
|
console.log(" start Build and start KNTIC services via docker compose (uses kntic.yml + .kntic.env)");
|
|
10
10
|
console.log(" --screen Run inside a GNU screen session");
|
|
11
11
|
console.log(" stop Stop KNTIC services via docker compose");
|
|
12
|
-
console.log(" update Download the latest KNTIC bootstrap and update .kntic/lib, .kntic/adrs, .kntic/hooks/
|
|
13
|
-
console.log(" --lib-only Update only .kntic/lib (skip .kntic/adrs, .kntic/hooks/
|
|
12
|
+
console.log(" update Download the latest KNTIC bootstrap and update .kntic/lib, .kntic/adrs, .kntic/hooks/gia/internal, and .kntic/gia/weights.json");
|
|
13
|
+
console.log(" --lib-only Update only .kntic/lib (skip .kntic/adrs, .kntic/hooks/gia/internal, and .kntic/gia/weights.json)");
|
|
14
14
|
console.log("");
|
|
15
15
|
}
|
|
16
16
|
|