@newtype-ai/nit 0.1.0 → 0.1.2

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
@@ -10,7 +10,7 @@ An agent working across multiple platforms (FAAM, Polymarket, etc.) needs to pre
10
10
 
11
11
  ```
12
12
  main → full agent card (public, discoverable)
13
- faam.fun → { skills: [content, social], description: "Content creator..." }
13
+ faam.io → { skills: [content, social], description: "Content creator..." }
14
14
  polymarket.com → { skills: [research, trading], description: "Market analyst..." }
15
15
  ```
16
16
 
@@ -33,10 +33,10 @@ npx @newtype-ai/nit init
33
33
  nit init
34
34
 
35
35
  # Create a platform-specific branch
36
- nit branch faam.fun
36
+ nit branch faam.io
37
37
 
38
38
  # Switch to it and customize the card
39
- nit checkout faam.fun
39
+ nit checkout faam.io
40
40
  # edit agent-card.json...
41
41
  nit commit -m "FAAM config"
42
42
 
@@ -74,9 +74,9 @@ Platforms verify your identity by challenging you to sign a nonce — no shared
74
74
 
75
75
  ### Branches
76
76
 
77
- Each branch is a different agent card for a different platform. Branch name = root domain of the platform (e.g., `faam.fun`, `polymarket.com`).
77
+ Each branch is a different agent card for a different platform. Branch name = root domain of the platform (e.g., `faam.io`, `polymarket.com`).
78
78
 
79
- `nit checkout faam.fun` overwrites `./agent-card.json` with that branch's version.
79
+ `nit checkout faam.io` overwrites `./agent-card.json` with that branch's version.
80
80
 
81
81
  ### Skill Resolution
82
82
 
@@ -96,7 +96,7 @@ The main branch is public. Non-main branches require signed-challenge authentica
96
96
 
97
97
  ```
98
98
  GET /.well-known/agent-card.json → main card (public)
99
- GET /.well-known/agent-card.json?branch=faam.fun → 401 { challenge }
99
+ GET /.well-known/agent-card.json?branch=faam.io → 401 { challenge }
100
100
  GET ... + X-Nit-Signature + X-Nit-Challenge → branch card
101
101
  ```
102
102
 
@@ -124,8 +124,8 @@ your-project/
124
124
  import { init, commit, checkout, branch, push, status } from '@newtype-ai/nit';
125
125
 
126
126
  await init();
127
- await branch('faam.fun');
128
- await checkout('faam.fun');
127
+ await branch('faam.io');
128
+ await checkout('faam.io');
129
129
  // modify agent-card.json...
130
130
  await commit('FAAM config');
131
131
  await push({ all: true });
@@ -276,10 +276,22 @@ async function readConfig(nitDir) {
276
276
  }
277
277
  return parseConfig(raw);
278
278
  }
279
+ async function writeConfig(nitDir, config) {
280
+ const configPath = join4(nitDir, CONFIG_FILE);
281
+ await fs4.writeFile(configPath, serializeConfig(config), "utf-8");
282
+ }
279
283
  async function getRemoteCredential(nitDir, remoteName) {
280
284
  const config = await readConfig(nitDir);
281
285
  return config.remotes[remoteName]?.credential ?? null;
282
286
  }
287
+ async function setRemoteCredential(nitDir, remoteName, credential) {
288
+ const config = await readConfig(nitDir);
289
+ if (!config.remotes[remoteName]) {
290
+ config.remotes[remoteName] = {};
291
+ }
292
+ config.remotes[remoteName].credential = credential;
293
+ await writeConfig(nitDir, config);
294
+ }
283
295
  function parseConfig(raw) {
284
296
  const remotes = {};
285
297
  let currentRemote = null;
@@ -306,6 +318,17 @@ function parseConfig(raw) {
306
318
  }
307
319
  return { remotes };
308
320
  }
321
+ function serializeConfig(config) {
322
+ const lines = [];
323
+ for (const [name, remote2] of Object.entries(config.remotes)) {
324
+ lines.push(`[remote "${name}"]`);
325
+ if (remote2.credential) {
326
+ lines.push(` credential = ${remote2.credential}`);
327
+ }
328
+ lines.push("");
329
+ }
330
+ return lines.join("\n");
331
+ }
309
332
 
310
333
  // src/skills.ts
311
334
  import { promises as fs5 } from "fs";
@@ -517,7 +540,7 @@ async function pushBranch(nitDir, remoteName, branch2, cardJson, commitHash) {
517
540
  commitHash,
518
541
  remoteUrl: API_BASE,
519
542
  success: false,
520
- error: `No credential configured for remote "${remoteName}". Run: nit remote`
543
+ error: `No credential configured for remote "${remoteName}". Run: nit remote set-credential <agent-key>`
521
544
  };
522
545
  }
523
546
  const url = `${API_BASE}/agent-card/branches/${encodeURIComponent(branch2)}`;
@@ -905,6 +928,11 @@ async function remote(options) {
905
928
  hasCredential: credential !== null
906
929
  };
907
930
  }
931
+ async function setCredential(credential, options) {
932
+ const nitDir = findNitDir(options?.projectDir);
933
+ const remoteName = options?.remoteName || "origin";
934
+ await setRemoteCredential(nitDir, remoteName, credential);
935
+ }
908
936
 
909
937
  export {
910
938
  formatPublicKeyField,
@@ -923,5 +951,6 @@ export {
923
951
  branch,
924
952
  checkout,
925
953
  push,
926
- remote
954
+ remote,
955
+ setCredential
927
956
  };
package/dist/cli.js CHANGED
@@ -10,8 +10,9 @@ import {
10
10
  log,
11
11
  push,
12
12
  remote,
13
+ setCredential,
13
14
  status
14
- } from "./chunk-5EGCFUZ7.js";
15
+ } from "./chunk-5AVY6P7B.js";
15
16
 
16
17
  // src/cli.ts
17
18
  var bold = (s) => `\x1B[1m${s}\x1B[0m`;
@@ -48,7 +49,7 @@ async function main() {
48
49
  await cmdPush(args);
49
50
  break;
50
51
  case "remote":
51
- await cmdRemote();
52
+ await cmdRemote(args);
52
53
  break;
53
54
  case "help":
54
55
  case "--help":
@@ -175,7 +176,18 @@ async function cmdPush(args) {
175
176
  }
176
177
  }
177
178
  }
178
- async function cmdRemote() {
179
+ async function cmdRemote(args) {
180
+ const subcommand = args[0];
181
+ if (subcommand === "set-credential") {
182
+ const token = args[1];
183
+ if (!token) {
184
+ console.error("Usage: nit remote set-credential <agent-key>");
185
+ process.exit(1);
186
+ }
187
+ await setCredential(token);
188
+ console.log(`Credential ${green("configured")} for origin.`);
189
+ return;
190
+ }
179
191
  const info = await remote();
180
192
  console.log(`${bold(info.name)}`);
181
193
  console.log(` URL: ${info.url}`);
@@ -199,11 +211,12 @@ ${bold("Commands:")}
199
211
  checkout <branch> Switch branch (overwrites agent-card.json)
200
212
  push [--all] Push branch(es) to remote
201
213
  remote Show remote info
214
+ remote set-credential <key> Set push credential (agent key)
202
215
 
203
216
  ${bold("Examples:")}
204
217
  nit init
205
- nit branch faam.fun
206
- nit checkout faam.fun
218
+ nit branch faam.io
219
+ nit checkout faam.io
207
220
  ${dim("# edit agent-card.json for FAAM...")}
208
221
  nit commit -m "FAAM config"
209
222
  nit push --all
package/dist/index.d.ts CHANGED
@@ -239,5 +239,12 @@ interface RemoteInfo {
239
239
  declare function remote(options?: {
240
240
  projectDir?: string;
241
241
  }): Promise<RemoteInfo>;
242
+ /**
243
+ * Set the push credential for a remote.
244
+ */
245
+ declare function setCredential(credential: string, options?: {
246
+ projectDir?: string;
247
+ remoteName?: string;
248
+ }): Promise<void>;
242
249
 
243
- export { type AgentCard, type AgentCardSkill, type DiffResult, type FieldDiff, type InitResult, type NitBranch, type NitCommit, type NitConfig, type NitHead, type NitRemoteConfig, type PushResult, type RemoteInfo, type SkillMetadata, type StatusResult, branch, checkout, commit, diff, diffCards, fetchBranchCard, findNitDir, formatDiff, formatPublicKeyField, init, log, parsePublicKeyField, push, remote, signChallenge, status, verifySignature };
250
+ export { type AgentCard, type AgentCardSkill, type DiffResult, type FieldDiff, type InitResult, type NitBranch, type NitCommit, type NitConfig, type NitHead, type NitRemoteConfig, type PushResult, type RemoteInfo, type SkillMetadata, type StatusResult, branch, checkout, commit, diff, diffCards, fetchBranchCard, findNitDir, formatDiff, formatPublicKeyField, init, log, parsePublicKeyField, push, remote, setCredential, signChallenge, status, verifySignature };
package/dist/index.js CHANGED
@@ -14,10 +14,11 @@ import {
14
14
  parsePublicKeyField,
15
15
  push,
16
16
  remote,
17
+ setCredential,
17
18
  signChallenge,
18
19
  status,
19
20
  verifySignature
20
- } from "./chunk-5EGCFUZ7.js";
21
+ } from "./chunk-5AVY6P7B.js";
21
22
  export {
22
23
  branch,
23
24
  checkout,
@@ -33,6 +34,7 @@ export {
33
34
  parsePublicKeyField,
34
35
  push,
35
36
  remote,
37
+ setCredential,
36
38
  signChallenge,
37
39
  status,
38
40
  verifySignature
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newtype-ai/nit",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Version control for agent cards",
5
5
  "type": "module",
6
6
  "bin": {