@newtype-ai/nit 0.2.0 → 0.2.1

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
@@ -49,13 +49,15 @@ nit push --all
49
49
  | Command | Description |
50
50
  |---------|-------------|
51
51
  | `nit init` | Create `.nit/`, generate Ed25519 keypair, initial commit |
52
- | `nit status` | Current branch, uncommitted changes, ahead/behind remote |
53
- | `nit commit -m "msg"` | Snapshot agent-card.json (auto-resolves SKILL.md pointers) |
52
+ | `nit status` | Identity info, current branch, uncommitted changes |
53
+ | `nit commit -m "msg"` | Snapshot agent-card.json |
54
54
  | `nit log` | Commit history for current branch |
55
55
  | `nit diff [target]` | JSON diff vs HEAD, branch, or commit |
56
56
  | `nit branch [name]` | List branches or create a new one |
57
57
  | `nit checkout <branch>` | Switch branch (overwrites agent-card.json) |
58
58
  | `nit push [--all]` | Push branch(es) to remote |
59
+ | `nit sign "msg"` | Sign a message with your Ed25519 key |
60
+ | `nit sign --login <domain>` | Generate login payload for an app |
59
61
  | `nit remote` | Show remote URL and credential status |
60
62
 
61
63
  ## How It Works
@@ -729,12 +729,15 @@ async function status(options) {
729
729
  const currentBranch = await getCurrentBranch(nitDir);
730
730
  const pubBase64 = await loadPublicKey(nitDir);
731
731
  const publicKey = formatPublicKeyField(pubBase64);
732
+ const agentId = await loadAgentId(nitDir);
733
+ const workingCard = await readWorkingCard(nitDir);
734
+ const cardUrl = workingCard.url || `https://agent-${agentId}.newtype-ai.org`;
732
735
  let uncommittedChanges = null;
733
736
  try {
734
737
  const headHash = await resolveHead(nitDir);
735
738
  const headCard = await getCardAtCommit(nitDir, headHash);
736
- const workingCard = await readWorkingCard(nitDir);
737
- const d = diffCards(headCard, workingCard);
739
+ const workingCard2 = await readWorkingCard(nitDir);
740
+ const d = diffCards(headCard, workingCard2);
738
741
  if (d.changed) {
739
742
  uncommittedChanges = d;
740
743
  }
@@ -773,12 +776,28 @@ async function status(options) {
773
776
  branchStatus.push({ name: b.name, ahead, behind: 0 });
774
777
  }
775
778
  return {
779
+ agentId,
780
+ cardUrl,
776
781
  branch: currentBranch,
777
782
  publicKey,
778
783
  uncommittedChanges,
779
784
  branches: branchStatus
780
785
  };
781
786
  }
787
+ async function sign2(message, options) {
788
+ const nitDir = findNitDir(options?.projectDir);
789
+ return signMessage(nitDir, message);
790
+ }
791
+ async function loginPayload(domain, options) {
792
+ const nitDir = findNitDir(options?.projectDir);
793
+ const agentId = await loadAgentId(nitDir);
794
+ const timestamp = Math.floor(Date.now() / 1e3);
795
+ const message = `${agentId}
796
+ ${domain}
797
+ ${timestamp}`;
798
+ const signature = await signMessage(nitDir, message);
799
+ return { agent_id: agentId, domain, timestamp, signature };
800
+ }
782
801
  async function commit(message, options) {
783
802
  const nitDir = findNitDir(options?.projectDir);
784
803
  const projDir = projectDir(nitDir);
@@ -944,6 +963,8 @@ export {
944
963
  findNitDir,
945
964
  init,
946
965
  status,
966
+ sign2 as sign,
967
+ loginPayload,
947
968
  commit,
948
969
  log,
949
970
  diff,
package/dist/cli.js CHANGED
@@ -8,10 +8,12 @@ import {
8
8
  formatDiff,
9
9
  init,
10
10
  log,
11
+ loginPayload,
11
12
  push,
12
13
  remote,
14
+ sign,
13
15
  status
14
- } from "./chunk-7KTMZ67T.js";
16
+ } from "./chunk-AEWDQDBM.js";
15
17
 
16
18
  // src/cli.ts
17
19
  var bold = (s) => `\x1B[1m${s}\x1B[0m`;
@@ -47,6 +49,9 @@ async function main() {
47
49
  case "push":
48
50
  await cmdPush(args);
49
51
  break;
52
+ case "sign":
53
+ await cmdSign(args);
54
+ break;
50
55
  case "remote":
51
56
  await cmdRemote(args);
52
57
  break;
@@ -80,11 +85,16 @@ async function cmdInit() {
80
85
  }
81
86
  console.log();
82
87
  console.log(dim("Created .nit/ with initial commit on main."));
88
+ console.log();
89
+ console.log(`Next: open ${bold("agent-card.json")} and set your name, description, and skills.`);
83
90
  }
84
91
  async function cmdStatus() {
85
92
  const s = await status();
86
93
  console.log(`On branch ${bold(s.branch)}`);
87
- console.log(`Public key: ${dim(s.publicKey)}`);
94
+ console.log();
95
+ console.log(` Agent ID: ${green(s.agentId)}`);
96
+ console.log(` Public key: ${dim(s.publicKey)}`);
97
+ console.log(` Card URL: ${s.cardUrl}`);
88
98
  console.log();
89
99
  if (s.uncommittedChanges) {
90
100
  console.log(yellow("Uncommitted changes:"));
@@ -181,6 +191,27 @@ async function cmdRemote(args) {
181
191
  console.log(` Agent ID: ${info.agentId}`);
182
192
  console.log(` Auth: ${green("Ed25519 keypair")}`);
183
193
  }
194
+ async function cmdSign(args) {
195
+ const loginIndex = args.indexOf("--login");
196
+ if (loginIndex !== -1) {
197
+ const domain = args[loginIndex + 1];
198
+ if (!domain) {
199
+ console.error("Usage: nit sign --login <domain>");
200
+ process.exit(1);
201
+ }
202
+ const payload = await loginPayload(domain);
203
+ console.log(JSON.stringify(payload, null, 2));
204
+ return;
205
+ }
206
+ const message = args[0];
207
+ if (!message) {
208
+ console.error('Usage: nit sign "message"');
209
+ console.error(" nit sign --login <domain>");
210
+ process.exit(1);
211
+ }
212
+ const signature = await sign(message);
213
+ console.log(signature);
214
+ }
184
215
  function printUsage() {
185
216
  console.log(`
186
217
  ${bold("nit")} \u2014 version control for agent cards
@@ -189,13 +220,15 @@ ${bold("Usage:")} nit <command> [options]
189
220
 
190
221
  ${bold("Commands:")}
191
222
  init Initialize .nit/ in current directory
192
- status Show current branch and uncommitted changes
223
+ status Show identity, branch, and uncommitted changes
193
224
  commit -m "msg" Snapshot agent-card.json
194
225
  log Show commit history
195
226
  diff [target] Compare card vs HEAD, branch, or commit
196
227
  branch [name] List branches or create a new one
197
228
  checkout <branch> Switch branch (overwrites agent-card.json)
198
229
  push [--all] Push branch(es) to remote
230
+ sign "message" Sign a message with your Ed25519 key
231
+ sign --login <dom> Generate login payload for an app
199
232
  remote Show remote info
200
233
 
201
234
  ${bold("Examples:")}
package/dist/index.d.ts CHANGED
@@ -101,6 +101,8 @@ interface PushResult {
101
101
  }
102
102
  /** Result returned by the status command. */
103
103
  interface StatusResult {
104
+ agentId: string;
105
+ cardUrl: string;
104
106
  branch: string;
105
107
  publicKey: string;
106
108
  uncommittedChanges: DiffResult | null;
@@ -110,6 +112,13 @@ interface StatusResult {
110
112
  behind: number;
111
113
  }>;
112
114
  }
115
+ /** Result of generating a login payload for app authentication. */
116
+ interface LoginPayload {
117
+ agent_id: string;
118
+ domain: string;
119
+ timestamp: number;
120
+ signature: string;
121
+ }
113
122
 
114
123
  /**
115
124
  * Compare two agent cards and return a structured diff.
@@ -207,6 +216,21 @@ declare function init(options?: {
207
216
  declare function status(options?: {
208
217
  projectDir?: string;
209
218
  }): Promise<StatusResult>;
219
+ /**
220
+ * Sign an arbitrary message with the agent's Ed25519 private key.
221
+ * Returns a base64-encoded signature.
222
+ */
223
+ declare function sign(message: string, options?: {
224
+ projectDir?: string;
225
+ }): Promise<string>;
226
+ /**
227
+ * Generate a login payload for app authentication.
228
+ * Constructs the canonical message ({agent_id}\n{domain}\n{timestamp}),
229
+ * signs it, and returns the full payload ready to send to an app.
230
+ */
231
+ declare function loginPayload(domain: string, options?: {
232
+ projectDir?: string;
233
+ }): Promise<LoginPayload>;
210
234
  /**
211
235
  * Snapshot the current agent-card.json as a new commit.
212
236
  * Resolves skill pointers from SKILL.md before committing.
@@ -264,4 +288,4 @@ declare function remote(options?: {
264
288
  projectDir?: string;
265
289
  }): Promise<RemoteInfo>;
266
290
 
267
- export { type AgentCard, type AgentCardSkill, type DiffResult, type FieldDiff, type InitResult, NIT_NAMESPACE, type NitBranch, type NitCommit, type NitConfig, type NitHead, type NitRemoteConfig, type PushResult, type RemoteInfo, type SkillMetadata, type StatusResult, branch, checkout, commit, deriveAgentId, diff, diffCards, fetchBranchCard, findNitDir, formatDiff, formatPublicKeyField, init, loadAgentId, log, parsePublicKeyField, push, remote, signChallenge, signMessage, status, verifySignature };
291
+ export { type AgentCard, type AgentCardSkill, type DiffResult, type FieldDiff, type InitResult, type LoginPayload, NIT_NAMESPACE, type NitBranch, type NitCommit, type NitConfig, type NitHead, type NitRemoteConfig, type PushResult, type RemoteInfo, type SkillMetadata, type StatusResult, branch, checkout, commit, deriveAgentId, diff, diffCards, fetchBranchCard, findNitDir, formatDiff, formatPublicKeyField, init, loadAgentId, log, loginPayload, parsePublicKeyField, push, remote, sign, signChallenge, signMessage, status, verifySignature };
package/dist/index.js CHANGED
@@ -14,14 +14,16 @@ import {
14
14
  init,
15
15
  loadAgentId,
16
16
  log,
17
+ loginPayload,
17
18
  parsePublicKeyField,
18
19
  push,
19
20
  remote,
21
+ sign,
20
22
  signChallenge,
21
23
  signMessage,
22
24
  status,
23
25
  verifySignature
24
- } from "./chunk-7KTMZ67T.js";
26
+ } from "./chunk-AEWDQDBM.js";
25
27
  export {
26
28
  NIT_NAMESPACE,
27
29
  branch,
@@ -37,9 +39,11 @@ export {
37
39
  init,
38
40
  loadAgentId,
39
41
  log,
42
+ loginPayload,
40
43
  parsePublicKeyField,
41
44
  push,
42
45
  remote,
46
+ sign,
43
47
  signChallenge,
44
48
  signMessage,
45
49
  status,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newtype-ai/nit",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Version control for agent cards",
5
5
  "type": "module",
6
6
  "bin": {