@figs-so/cli 0.1.5 → 0.1.6
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 +1 -0
- package/figs.mjs +32 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ The full, always-current guide + `agent.json` schema is served at **`<endpoint>/
|
|
|
25
25
|
|---|---|
|
|
26
26
|
| `figs status [--json]` | login / workspace / agent state |
|
|
27
27
|
| `figs login` | device-flow browser approve (or `figs login <token>`) |
|
|
28
|
+
| `figs logout` | remove the locally-saved token (`~/.figs/credentials.json`) |
|
|
28
29
|
| `figs workspaces [--json]` | list your workspaces (read-only; create one in the web app) |
|
|
29
30
|
| `figs init --workspace <slug-or-id>` | resolve the workspace, generate identity UUID + config + pointer GUIDE.md |
|
|
30
31
|
| `figs doctor` | validate `.figs/` against the contract |
|
package/figs.mjs
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* figs status show login / workspace / agent state [--json]
|
|
6
6
|
* figs login browser approve (device flow) — agent never sees the token
|
|
7
7
|
* figs login <token> fallback: save a token you pasted (~/.figs/credentials.json)
|
|
8
|
+
* figs logout remove the locally-saved token (~/.figs/credentials.json)
|
|
8
9
|
* figs workspaces list the user's workspaces [--json]
|
|
9
10
|
* figs init --workspace <slug-or-id> [--endpoint <url>]
|
|
10
11
|
* create .figs/config.json + GUIDE.md (generates a stable agent id)
|
|
@@ -25,13 +26,14 @@ import {
|
|
|
25
26
|
existsSync,
|
|
26
27
|
mkdirSync,
|
|
27
28
|
readFileSync,
|
|
29
|
+
rmSync,
|
|
28
30
|
writeFileSync,
|
|
29
31
|
} from "node:fs"
|
|
30
32
|
import { homedir } from "node:os"
|
|
31
33
|
import { join } from "node:path"
|
|
32
34
|
import { randomUUID } from "node:crypto"
|
|
33
35
|
|
|
34
|
-
const VERSION = "0.1.
|
|
36
|
+
const VERSION = "0.1.6"
|
|
35
37
|
// Going-forward default; override with FIGS_ENDPOINT or .figs/config.json endpoint
|
|
36
38
|
// (e.g. FIGS_ENDPOINT=http://localhost:3000 for local dev).
|
|
37
39
|
const DEFAULT_ENDPOINT = "https://app.figs.so"
|
|
@@ -143,6 +145,7 @@ async function checkVersion({ force = false, hardFail = false } = {}) {
|
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
if (cmd === "login") await login(process.argv[3])
|
|
148
|
+
else if (cmd === "logout") logout()
|
|
146
149
|
else if (cmd === "status") await status()
|
|
147
150
|
else if (cmd === "workspaces") await workspaces()
|
|
148
151
|
else if (cmd === "init") await init()
|
|
@@ -153,7 +156,7 @@ else if (cmd === "version" || cmd === "--version") {
|
|
|
153
156
|
await checkVersion({ force: true })
|
|
154
157
|
} else {
|
|
155
158
|
die(
|
|
156
|
-
`unknown command "${cmd}" — try: status, login, workspaces, init, doctor, push`,
|
|
159
|
+
`unknown command "${cmd}" — try: status, login, logout, workspaces, init, doctor, push`,
|
|
157
160
|
)
|
|
158
161
|
}
|
|
159
162
|
|
|
@@ -206,6 +209,33 @@ async function login(token) {
|
|
|
206
209
|
die("timed out waiting for approval — run `figs login` again")
|
|
207
210
|
}
|
|
208
211
|
|
|
212
|
+
/**
|
|
213
|
+
* `figs logout` — remove the locally-saved token (`~/.figs/credentials.json`).
|
|
214
|
+
* This only clears *this machine's* copy; the token still exists server-side
|
|
215
|
+
* until you revoke it in Settings. A token supplied via the FIGS_TOKEN env var
|
|
216
|
+
* can't be removed here (unset the env var to fully log out).
|
|
217
|
+
*/
|
|
218
|
+
function logout() {
|
|
219
|
+
if (existsSync(globalCreds)) {
|
|
220
|
+
try {
|
|
221
|
+
rmSync(globalCreds)
|
|
222
|
+
} catch (e) {
|
|
223
|
+
die(`could not remove ${globalCreds}: ${e?.message || e}`)
|
|
224
|
+
}
|
|
225
|
+
console.log("figs: ✓ logged out — removed ~/.figs/credentials.json")
|
|
226
|
+
} else {
|
|
227
|
+
console.log("figs: not logged in — no ~/.figs/credentials.json to remove")
|
|
228
|
+
}
|
|
229
|
+
if (process.env.FIGS_TOKEN) {
|
|
230
|
+
console.warn(
|
|
231
|
+
"figs: ! FIGS_TOKEN is still set in your environment — `unset FIGS_TOKEN` to fully log out",
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
console.log(
|
|
235
|
+
` the token still exists server-side — revoke it at ${resolveEndpoint()}/settings`,
|
|
236
|
+
)
|
|
237
|
+
}
|
|
238
|
+
|
|
209
239
|
/** Show where setup stands — login, workspace, charter. Drives the agent's next step. */
|
|
210
240
|
async function status() {
|
|
211
241
|
const token = getToken()
|