@newtype-ai/nit 0.4.3 → 0.4.5

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 CHANGED
@@ -37,7 +37,7 @@ nit branch faam.io
37
37
 
38
38
  # Switch to it and customize the card
39
39
  nit checkout faam.io
40
- # edit agent-card.json...
40
+ # Edit agent-card.json directly — set name, description, skills
41
41
  nit commit -m "FAAM config"
42
42
 
43
43
  # Push all branches to remote
@@ -76,6 +76,8 @@ nit push --all
76
76
 
77
77
  Platforms verify your identity by challenging you to sign a nonce — no shared secrets, no bearer tokens.
78
78
 
79
+ `publicKey` is managed by nit automatically — injected from your keypair at every commit. You don't need to set or modify it.
80
+
79
81
  nit also derives blockchain wallet addresses from your keypair — Solana (Ed25519 native) and EVM chains (Ethereum, BSC, Polygon, etc.) via a deterministic secp256k1 derivation. Run `nit status` to see your addresses.
80
82
 
81
83
  ### Branches
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/index.ts
4
4
  import { promises as fs7, statSync } from "fs";
5
- import { join as join7, basename as basename2, resolve as resolve2 } from "path";
5
+ import { join as join7, basename as basename2, dirname as dirname2, resolve as resolve2 } from "path";
6
6
 
7
7
  // src/objects.ts
8
8
  import { createHash } from "crypto";
@@ -363,13 +363,61 @@ async function createSkillTemplate(skillsDir, domain) {
363
363
  const skillId = domain.replace(/\./g, "-");
364
364
  const skillDir = join4(skillsDir, skillId);
365
365
  const skillPath = join4(skillDir, "SKILL.md");
366
+ let localVersion;
366
367
  try {
367
- await fs4.access(skillPath);
368
- return skillId;
368
+ const existing = await fs4.readFile(skillPath, "utf-8");
369
+ localVersion = parseVersion(existing);
369
370
  } catch {
370
371
  }
372
+ let remoteContent = null;
373
+ let remoteVersion;
374
+ try {
375
+ const res = await fetch(`https://${domain}/skill.md`, {
376
+ headers: { "Accept": "text/markdown, text/plain" },
377
+ signal: AbortSignal.timeout(5e3)
378
+ });
379
+ if (res.ok) {
380
+ const text = await res.text();
381
+ if (text.startsWith("---")) {
382
+ remoteContent = text;
383
+ remoteVersion = parseVersion(text);
384
+ }
385
+ }
386
+ } catch {
387
+ }
388
+ if (localVersion !== void 0) {
389
+ if (!remoteVersion || !isNewerVersion(remoteVersion, localVersion)) {
390
+ return skillId;
391
+ }
392
+ }
371
393
  await fs4.mkdir(skillDir, { recursive: true });
372
- const template = `---
394
+ await fs4.writeFile(
395
+ skillPath,
396
+ remoteContent ?? fallbackTemplate(skillId, domain),
397
+ "utf-8"
398
+ );
399
+ return skillId;
400
+ }
401
+ function parseVersion(content) {
402
+ const fmMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
403
+ if (!fmMatch) return void 0;
404
+ const versionMatch = fmMatch[1].match(/^version:\s*(.+)$/m);
405
+ return versionMatch ? versionMatch[1].trim() : void 0;
406
+ }
407
+ function isNewerVersion(remote2, local) {
408
+ const r = remote2.split(".").map(Number);
409
+ const l = local.split(".").map(Number);
410
+ const len = Math.max(r.length, l.length);
411
+ for (let i = 0; i < len; i++) {
412
+ const rv = r[i] ?? 0;
413
+ const lv = l[i] ?? 0;
414
+ if (rv > lv) return true;
415
+ if (rv < lv) return false;
416
+ }
417
+ return false;
418
+ }
419
+ function fallbackTemplate(skillId, domain) {
420
+ return `---
373
421
  name: ${skillId}
374
422
  description: Skills and context for ${domain}
375
423
  ---
@@ -378,8 +426,6 @@ description: Skills and context for ${domain}
378
426
 
379
427
  Configure your skills and context for ${domain} here.
380
428
  `;
381
- await fs4.writeFile(skillPath, template, "utf-8");
382
- return skillId;
383
429
  }
384
430
  async function discoverSkills(projectDir2) {
385
431
  const home = homedir();
@@ -1319,18 +1365,16 @@ async function loginPayload(domain, options) {
1319
1365
  }
1320
1366
  await checkout(domain, options);
1321
1367
  switchedBranch = domain;
1322
- if (isNew) {
1323
- const skillsDir = await getSkillsDir(nitDir);
1324
- if (skillsDir) {
1325
- const skillId = await createSkillTemplate(skillsDir, domain);
1326
- const card = await readWorkingCard(nitDir);
1327
- const hasSkill = card.skills.some((s) => s.id === skillId);
1328
- if (!hasSkill) {
1329
- card.skills.push({ id: skillId });
1330
- await writeWorkingCard(nitDir, card);
1331
- createdSkill = skillId;
1332
- }
1333
- }
1368
+ }
1369
+ const projectDir2 = dirname2(nitDir);
1370
+ const skillsDir = await getSkillsDir(nitDir) ?? await discoverSkillsDir(projectDir2);
1371
+ if (skillsDir) {
1372
+ const skillId = await createSkillTemplate(skillsDir, domain);
1373
+ const card = await readWorkingCard(nitDir);
1374
+ if (!card.skills.some((s) => s.id === skillId)) {
1375
+ card.skills.push({ id: skillId });
1376
+ await writeWorkingCard(nitDir, card);
1377
+ createdSkill = skillId;
1334
1378
  }
1335
1379
  }
1336
1380
  const agentId = await loadAgentId(nitDir);
@@ -1346,6 +1390,8 @@ async function commit(message, options) {
1346
1390
  const projDir = projectDir(nitDir);
1347
1391
  let card = await readWorkingCard(nitDir);
1348
1392
  card = await resolveSkillPointers(card, projDir);
1393
+ const pubBase64 = await loadPublicKey(nitDir);
1394
+ card.publicKey = formatPublicKeyField(pubBase64);
1349
1395
  await writeWorkingCard(nitDir, card);
1350
1396
  const cardJson = JSON.stringify(card, null, 2);
1351
1397
  const cardHash = await writeObject(nitDir, "card", cardJson);
package/dist/cli.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  remoteSetUrl,
16
16
  sign,
17
17
  status
18
- } from "./chunk-CPNPQQOU.js";
18
+ } from "./chunk-535YI4CD.js";
19
19
 
20
20
  // src/update-check.ts
21
21
  import { homedir } from "os";
@@ -27,7 +27,7 @@ var FETCH_TIMEOUT_MS = 3e3;
27
27
  var REGISTRY_URL = "https://registry.npmjs.org/@newtype-ai/nit/latest";
28
28
  function getCurrentVersion() {
29
29
  try {
30
- return "0.4.3";
30
+ return "0.4.5";
31
31
  } catch {
32
32
  return "0.0.0";
33
33
  }
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ import {
30
30
  signChallenge,
31
31
  signMessage,
32
32
  status
33
- } from "./chunk-CPNPQQOU.js";
33
+ } from "./chunk-535YI4CD.js";
34
34
  export {
35
35
  NIT_NAMESPACE,
36
36
  base58Encode,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newtype-ai/nit",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Version control for agent cards",
5
5
  "type": "module",
6
6
  "bin": {