unfairly 0.1.0 → 0.1.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/dist/cmd/init.js +30 -14
- package/dist/index.js +15 -2
- package/package.json +1 -1
package/dist/cmd/init.js
CHANGED
|
@@ -7,36 +7,52 @@ import { emptyManifest, writeManifest } from "../sync/manifest.js";
|
|
|
7
7
|
import { getToken, setToken } from "../sync/credentials.js";
|
|
8
8
|
import { runPull } from "./pull.js";
|
|
9
9
|
const DEFAULT_API = "https://app.unfairly.ai";
|
|
10
|
-
|
|
10
|
+
function isTty() {
|
|
11
|
+
return Boolean(process.stdin.isTTY);
|
|
12
|
+
}
|
|
13
|
+
export async function runInit(opts = {}) {
|
|
11
14
|
const cwd = process.cwd();
|
|
12
15
|
const target = path.join(cwd, ".unfairly");
|
|
13
16
|
// Confirm overwrite if .unfairly/ already exists
|
|
14
17
|
try {
|
|
15
18
|
await fs.access(target);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (
|
|
20
|
-
console.
|
|
21
|
-
|
|
19
|
+
if (opts.yes) {
|
|
20
|
+
// skip prompt
|
|
21
|
+
}
|
|
22
|
+
else if (!isTty()) {
|
|
23
|
+
console.error(".unfairly/ already exists. Re-run with --yes to overwrite (non-interactive shell detected — can't prompt).");
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
const rl = readline.createInterface({ input, output });
|
|
28
|
+
const ans = await rl.question(`.unfairly/ already exists. Re-initialize? [y/N] `);
|
|
29
|
+
rl.close();
|
|
30
|
+
if (ans.trim().toLowerCase() !== "y") {
|
|
31
|
+
console.log("aborted");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
22
34
|
}
|
|
23
35
|
}
|
|
24
36
|
catch {
|
|
25
37
|
// didn't exist; fine
|
|
26
38
|
}
|
|
27
|
-
// Token
|
|
28
|
-
let token = await getToken();
|
|
39
|
+
// Token resolution order: --token flag → UNFAIRLY_TOKEN env → keychain/file → prompt.
|
|
40
|
+
let token = opts.token ?? process.env.UNFAIRLY_TOKEN ?? (await getToken());
|
|
29
41
|
if (!token) {
|
|
42
|
+
if (!isTty()) {
|
|
43
|
+
console.error("No token. Pass --token mcp_... or set UNFAIRLY_TOKEN env (non-interactive shell — can't prompt). Get one at https://app.unfairly.ai/dashboard/setup.");
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
30
46
|
const rl = readline.createInterface({ input, output });
|
|
31
47
|
console.log("Get a token at https://app.unfairly.ai/dashboard/setup (click 'Issue token').");
|
|
32
48
|
token = (await rl.question("Paste mcp_* token: ")).trim();
|
|
33
49
|
rl.close();
|
|
34
|
-
if (!token.startsWith("mcp_")) {
|
|
35
|
-
console.error("Token must start with mcp_");
|
|
36
|
-
process.exit(1);
|
|
37
|
-
}
|
|
38
|
-
await setToken(token);
|
|
39
50
|
}
|
|
51
|
+
if (!token.startsWith("mcp_")) {
|
|
52
|
+
console.error("Token must start with mcp_");
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
await setToken(token);
|
|
40
56
|
// Verify token + list vaults
|
|
41
57
|
const apiUrl = process.env.UNFAIRLY_API_URL ?? DEFAULT_API;
|
|
42
58
|
const client = new SyncClient(apiUrl, token);
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,22 @@ import { hideBin } from "yargs/helpers";
|
|
|
4
4
|
await yargs(hideBin(process.argv))
|
|
5
5
|
.scriptName("unfairly")
|
|
6
6
|
.usage("$0 <cmd> [args]")
|
|
7
|
-
.command("init", "Initialize .unfairly/ in cwd and pull all accessible vaults", () =>
|
|
7
|
+
.command("init", "Initialize .unfairly/ in cwd and pull all accessible vaults", (y) => y
|
|
8
|
+
.option("token", {
|
|
9
|
+
type: "string",
|
|
10
|
+
describe: "mcp_* token for non-interactive runs. Or set UNFAIRLY_TOKEN env.",
|
|
11
|
+
})
|
|
12
|
+
.option("yes", {
|
|
13
|
+
type: "boolean",
|
|
14
|
+
alias: "y",
|
|
15
|
+
default: false,
|
|
16
|
+
describe: "Skip the .unfairly/ overwrite confirmation",
|
|
17
|
+
}), async (argv) => {
|
|
8
18
|
const { runInit } = await import("./cmd/init.js");
|
|
9
|
-
await runInit(
|
|
19
|
+
await runInit({
|
|
20
|
+
token: argv.token,
|
|
21
|
+
yes: argv.yes,
|
|
22
|
+
});
|
|
10
23
|
})
|
|
11
24
|
.command("pull [vault]", "Pull markdown from cloud", (y) => y.positional("vault", { type: "string" }), async (argv) => {
|
|
12
25
|
const { runPull } = await import("./cmd/pull.js");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unfairly",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "CLI + stdio MCP for syncing Unfairly vaults to local markdown — the multiplayer context layer for AI agents",
|
|
5
5
|
"keywords": ["unfairly", "mcp", "ai", "context", "agents", "knowledge-base", "claude", "codex"],
|
|
6
6
|
"homepage": "https://unfairly.ai",
|