@newtype-ai/nit 0.4.9 → 0.4.10

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/dist/cli.js CHANGED
@@ -1,6 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  // nit — version control for agent cards
3
3
  import {
4
+ authSet,
5
+ authShow,
4
6
  branch,
5
7
  broadcast,
6
8
  checkout,
@@ -10,16 +12,20 @@ import {
10
12
  init,
11
13
  log,
12
14
  loginPayload,
15
+ pull,
13
16
  push,
14
17
  remote,
15
18
  remoteAdd,
16
19
  remoteSetUrl,
20
+ reset,
17
21
  rpcInfo,
18
22
  rpcSetUrl,
23
+ show,
19
24
  sign,
20
25
  signTx,
21
26
  status
22
- } from "./chunk-Q5GX7ZXR.js";
27
+ } from "./chunk-WHSQICPU.js";
28
+ import "./chunk-M6SR6QMR.js";
23
29
 
24
30
  // src/update-check.ts
25
31
  import { execSync } from "child_process";
@@ -32,7 +38,7 @@ var FETCH_TIMEOUT_MS = 3e3;
32
38
  var REGISTRY_URL = "https://registry.npmjs.org/@newtype-ai/nit/latest";
33
39
  function getCurrentVersion() {
34
40
  try {
35
- return "0.4.9";
41
+ return "0.4.10";
36
42
  } catch {
37
43
  return "0.0.0";
38
44
  }
@@ -162,6 +168,18 @@ async function main() {
162
168
  case "rpc":
163
169
  await cmdRpc(args);
164
170
  break;
171
+ case "auth":
172
+ await cmdAuth(args);
173
+ break;
174
+ case "reset":
175
+ await cmdReset(args);
176
+ break;
177
+ case "show":
178
+ await cmdShow(args);
179
+ break;
180
+ case "pull":
181
+ await cmdPull(args);
182
+ break;
165
183
  case "help":
166
184
  case "--help":
167
185
  case "-h":
@@ -439,6 +457,100 @@ async function cmdRpc(args) {
439
457
  console.log(` ${bold(chain)}: ${config.url}`);
440
458
  }
441
459
  }
460
+ async function cmdReset(args) {
461
+ const target = args[0];
462
+ const result = await reset(target);
463
+ console.log(`Reset to ${dim(result.hash.slice(0, 8))}`);
464
+ }
465
+ async function cmdShow(args) {
466
+ const target = args[0];
467
+ const s = await show(target);
468
+ const date = new Date(s.timestamp * 1e3).toISOString().slice(0, 19);
469
+ console.log(`${bold("commit")} ${yellow(s.hash.slice(0, 8))}`);
470
+ console.log(`Author: ${s.author}`);
471
+ console.log(`Date: ${date}`);
472
+ if (s.parent) {
473
+ console.log(`Parent: ${dim(s.parent.slice(0, 8))}`);
474
+ }
475
+ console.log();
476
+ console.log(` ${s.message}`);
477
+ console.log();
478
+ console.log(JSON.stringify(s.cardJson, null, 2));
479
+ }
480
+ async function cmdPull(args) {
481
+ const all = args.includes("--all");
482
+ const results = await pull({ all });
483
+ for (const r of results) {
484
+ if (r.updated) {
485
+ console.log(`${green("\u2713")} ${r.branch} \u2190 ${dim(r.commitHash.slice(0, 8))}`);
486
+ } else {
487
+ console.log(`${dim("\u2014")} ${r.branch} ${dim("(up to date)")}`);
488
+ }
489
+ }
490
+ }
491
+ async function cmdAuth(args) {
492
+ const subcommand = args[0];
493
+ if (subcommand === "set") {
494
+ const domain = args[1];
495
+ if (!domain) {
496
+ console.error("Usage: nit auth set <domain> --provider <google|github|x> --account <email>");
497
+ process.exit(1);
498
+ }
499
+ const providerIndex = args.indexOf("--provider");
500
+ if (providerIndex === -1 || !args[providerIndex + 1]) {
501
+ console.error("Missing --provider. Usage: nit auth set <domain> --provider <google|github|x> --account <email>");
502
+ process.exit(1);
503
+ }
504
+ const provider = args[providerIndex + 1];
505
+ const validProviders = ["google", "github", "x"];
506
+ if (!validProviders.includes(provider)) {
507
+ console.error(`Unknown provider: ${provider}. Use: google, github, x`);
508
+ process.exit(1);
509
+ }
510
+ const accountIndex = args.indexOf("--account");
511
+ if (accountIndex === -1 || !args[accountIndex + 1]) {
512
+ console.error("Missing --account. Usage: nit auth set <domain> --provider <google|github|x> --account <email>");
513
+ process.exit(1);
514
+ }
515
+ const account = args[accountIndex + 1];
516
+ const result = await authSet(domain, provider, account);
517
+ if (result.createdBranch) {
518
+ console.log(`Created branch '${green(result.branch)}'`);
519
+ }
520
+ if (result.switchedBranch) {
521
+ console.log(`Switched to branch '${green(result.switchedBranch)}'`);
522
+ }
523
+ console.log(`${green("\u2713")} Auth configured for ${bold(domain)}: ${result.provider} (${result.account})`);
524
+ console.log(dim(` Updated SKILL.md: ${result.skillId}/SKILL.md`));
525
+ return;
526
+ }
527
+ if (subcommand === "show") {
528
+ const domain = args[1];
529
+ const results = await authShow(domain);
530
+ if (results.length === 0) {
531
+ if (domain) {
532
+ console.log(dim(`No auth configured for '${domain}'.`));
533
+ } else {
534
+ console.log(dim("No branches with auth configured."));
535
+ }
536
+ return;
537
+ }
538
+ for (const r of results) {
539
+ if (r.auth) {
540
+ console.log(` ${bold(r.branch)}: ${r.auth.provider} (${r.auth.account})`);
541
+ } else {
542
+ console.log(` ${bold(r.branch)}: ${dim("(no auth)")}`);
543
+ }
544
+ }
545
+ return;
546
+ }
547
+ if (subcommand) {
548
+ console.error(`nit auth: unknown subcommand '${subcommand}'`);
549
+ }
550
+ console.error("Usage: nit auth set <domain> --provider <google|github|x> --account <email>");
551
+ console.error(" nit auth show [domain]");
552
+ process.exit(1);
553
+ }
442
554
  function printUsage() {
443
555
  console.log(`
444
556
  ${bold("nit")} \u2014 version control for agent cards
@@ -454,6 +566,9 @@ ${bold("Commands:")}
454
566
  branch [name] List branches or create a new one
455
567
  checkout <branch> Switch branch (overwrites agent-card.json)
456
568
  push [--all] Push branch(es) to remote
569
+ pull [--all] Pull branch(es) from remote
570
+ reset [target] Restore agent-card.json from HEAD or target
571
+ show [target] Show commit metadata and card content
457
572
  sign "message" Sign a message with your Ed25519 key
458
573
  sign --login <dom> Switch to domain branch + generate login payload
459
574
  remote Show remote info
@@ -463,6 +578,9 @@ ${bold("Commands:")}
463
578
  broadcast --chain <c> <tx> Send signed tx to RPC endpoint
464
579
  rpc Show configured RPC endpoints
465
580
  rpc set-url <c> <url> Set RPC endpoint for a chain
581
+ auth set <dom> --provider <p> --account <a>
582
+ Configure OAuth auth for a branch
583
+ auth show [dom] Show auth config for branch(es)
466
584
 
467
585
  ${bold("Examples:")}
468
586
  nit init
package/dist/index.d.ts CHANGED
@@ -151,6 +151,13 @@ interface BroadcastResult {
151
151
  /** RPC endpoint used */
152
152
  rpcUrl: string;
153
153
  }
154
+ /** OAuth provider for per-branch authentication config. */
155
+ type AuthProvider = 'google' | 'github' | 'x';
156
+ /** Per-branch authentication configuration stored in SKILL.md frontmatter. */
157
+ interface AuthConfig {
158
+ provider: AuthProvider;
159
+ account: string;
160
+ }
154
161
  /** Result of generating a login payload for app authentication. */
155
162
  interface LoginPayload {
156
163
  agent_id: string;
@@ -420,5 +427,88 @@ declare function rpcSetUrl(chain: string, url: string, options?: {
420
427
  declare function rpcInfo(options?: {
421
428
  projectDir?: string;
422
429
  }): Promise<Record<string, NitRpcConfig>>;
430
+ /**
431
+ * Restore agent-card.json from a commit, discarding uncommitted changes.
432
+ *
433
+ * - No target: restore from HEAD (discard all uncommitted changes)
434
+ * - Commit hash or branch name: restore card from that commit
435
+ *
436
+ * Does NOT move the branch pointer — only overwrites the working card.
437
+ */
438
+ declare function reset(target?: string, options?: {
439
+ projectDir?: string;
440
+ }): Promise<{
441
+ hash: string;
442
+ }>;
443
+ interface ShowResult {
444
+ hash: string;
445
+ card: string;
446
+ parent: string | null;
447
+ author: string;
448
+ timestamp: number;
449
+ message: string;
450
+ cardJson: AgentCard;
451
+ }
452
+ /**
453
+ * Show a commit's metadata and card content.
454
+ *
455
+ * - No target: show HEAD
456
+ * - Commit hash or branch name: show that commit
457
+ */
458
+ declare function show(target?: string, options?: {
459
+ projectDir?: string;
460
+ }): Promise<ShowResult>;
461
+ interface PullResult {
462
+ branch: string;
463
+ commitHash: string;
464
+ updated: boolean;
465
+ }
466
+ /**
467
+ * Fetch current branch (or all branches) from the remote and update local state.
468
+ *
469
+ * 1. Fetch card JSON from remote
470
+ * 2. Write card to object store
471
+ * 3. Create a commit object
472
+ * 4. Update branch ref + remote-tracking ref
473
+ * 5. Write card to working copy (current branch only)
474
+ */
475
+ declare function pull(options?: {
476
+ projectDir?: string;
477
+ remoteName?: string;
478
+ all?: boolean;
479
+ }): Promise<PullResult[]>;
480
+ interface AuthSetResult {
481
+ branch: string;
482
+ skillId: string;
483
+ provider: AuthProvider;
484
+ account: string;
485
+ switchedBranch?: string;
486
+ createdBranch?: boolean;
487
+ }
488
+ interface AuthShowResult {
489
+ branch: string;
490
+ auth: AuthConfig | null;
491
+ }
492
+ /**
493
+ * Configure OAuth authentication for a branch.
494
+ *
495
+ * 1. Switches to the target branch (creates if needed)
496
+ * 2. Updates the branch's SKILL.md with auth frontmatter + consent instructions
497
+ * 3. Adds skill pointer to agent-card.json if not present
498
+ *
499
+ * The SKILL.md tells OpenClaw which OAuth provider and account to use when
500
+ * the agent encounters a login page. The agent reuses the human's existing
501
+ * Chrome session (browser-profile = user) and only handles OAuth consent
502
+ * flows — never enters credentials.
503
+ */
504
+ declare function authSet(domain: string, provider: AuthProvider, account: string, options?: {
505
+ projectDir?: string;
506
+ }): Promise<AuthSetResult>;
507
+ /**
508
+ * Show auth config for a specific branch, or all branches with auth configured.
509
+ */
510
+ declare function authShow(domain?: string, options?: {
511
+ projectDir?: string;
512
+ }): Promise<AuthShowResult[]>;
423
513
 
424
- export { type AgentCard, type AgentCardSkill, type BroadcastResult, type DiffResult, type FieldDiff, type InitResult, type LoginPayload, NIT_NAMESPACE, type NitBranch, type NitCommit, type NitConfig, type NitHead, type NitRemoteConfig, type NitRpcConfig, type PushResult, type RemoteInfo, type SignTxResult, type SkillMetadata, type StatusResult, type WalletAddresses$1 as WalletAddresses, base58Encode, branch, broadcast, checkout, commit, deriveAgentId, diff, diffCards, fetchBranchCard, findNitDir, formatDiff, formatPublicKeyField, getEvmAddress, getSolanaAddress, getWalletAddresses, init, loadAgentId, loadRawKeyPair, loadSecp256k1RawKeyPair, log, loginPayload, parsePublicKeyField, push, remote, remoteAdd, remoteSetUrl, rpcInfo, rpcSetUrl, sign, signChallenge, signEvmHash, signMessage, signSolanaBytes, signTx, status };
514
+ export { type AgentCard, type AgentCardSkill, type AuthConfig, type AuthProvider, type AuthSetResult, type AuthShowResult, type BroadcastResult, type DiffResult, type FieldDiff, type InitResult, type LoginPayload, NIT_NAMESPACE, type NitBranch, type NitCommit, type NitConfig, type NitHead, type NitRemoteConfig, type NitRpcConfig, type PullResult, type PushResult, type RemoteInfo, type ShowResult, type SignTxResult, type SkillMetadata, type StatusResult, type WalletAddresses$1 as WalletAddresses, authSet, authShow, base58Encode, branch, broadcast, checkout, commit, deriveAgentId, diff, diffCards, fetchBranchCard, findNitDir, formatDiff, formatPublicKeyField, getEvmAddress, getSolanaAddress, getWalletAddresses, init, loadAgentId, loadRawKeyPair, loadSecp256k1RawKeyPair, log, loginPayload, parsePublicKeyField, pull, push, remote, remoteAdd, remoteSetUrl, reset, rpcInfo, rpcSetUrl, show, sign, signChallenge, signEvmHash, signMessage, signSolanaBytes, signTx, status };
package/dist/index.js CHANGED
@@ -1,44 +1,53 @@
1
1
  // nit — version control for agent cards
2
2
  import {
3
- NIT_NAMESPACE,
3
+ authSet,
4
+ authShow,
4
5
  base58Encode,
5
6
  branch,
6
7
  broadcast,
7
8
  checkout,
8
9
  commit,
9
- deriveAgentId,
10
10
  diff,
11
11
  diffCards,
12
- fetchBranchCard,
13
12
  findNitDir,
14
13
  formatDiff,
15
- formatPublicKeyField,
16
14
  getEvmAddress,
17
15
  getSolanaAddress,
18
16
  getWalletAddresses,
19
17
  init,
20
- loadAgentId,
21
- loadRawKeyPair,
22
18
  loadSecp256k1RawKeyPair,
23
19
  log,
24
20
  loginPayload,
25
- parsePublicKeyField,
21
+ pull,
26
22
  push,
27
23
  remote,
28
24
  remoteAdd,
29
25
  remoteSetUrl,
26
+ reset,
30
27
  rpcInfo,
31
28
  rpcSetUrl,
29
+ show,
32
30
  sign,
33
- signChallenge,
34
31
  signEvmHash,
35
- signMessage,
36
32
  signSolanaBytes,
37
33
  signTx,
38
34
  status
39
- } from "./chunk-Q5GX7ZXR.js";
35
+ } from "./chunk-WHSQICPU.js";
36
+ import {
37
+ NIT_NAMESPACE,
38
+ deriveAgentId,
39
+ fetchBranchCard,
40
+ formatPublicKeyField,
41
+ loadAgentId,
42
+ loadRawKeyPair,
43
+ parsePublicKeyField,
44
+ signChallenge,
45
+ signMessage
46
+ } from "./chunk-M6SR6QMR.js";
40
47
  export {
41
48
  NIT_NAMESPACE,
49
+ authSet,
50
+ authShow,
42
51
  base58Encode,
43
52
  branch,
44
53
  broadcast,
@@ -61,12 +70,15 @@ export {
61
70
  log,
62
71
  loginPayload,
63
72
  parsePublicKeyField,
73
+ pull,
64
74
  push,
65
75
  remote,
66
76
  remoteAdd,
67
77
  remoteSetUrl,
78
+ reset,
68
79
  rpcInfo,
69
80
  rpcSetUrl,
81
+ show,
70
82
  sign,
71
83
  signChallenge,
72
84
  signEvmHash,
@@ -0,0 +1,15 @@
1
+ // nit — version control for agent cards
2
+ import {
3
+ deleteRemoteBranch,
4
+ fetchBranchCard,
5
+ listRemoteBranches,
6
+ pushAll,
7
+ pushBranch
8
+ } from "./chunk-M6SR6QMR.js";
9
+ export {
10
+ deleteRemoteBranch,
11
+ fetchBranchCard,
12
+ listRemoteBranches,
13
+ pushAll,
14
+ pushBranch
15
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newtype-ai/nit",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
4
4
  "description": "Version control for agent cards",
5
5
  "type": "module",
6
6
  "bin": {