@openscaffold/cli 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.
Files changed (2) hide show
  1. package/dist/index.js +10 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -28,6 +28,8 @@ const writeJson = (path, value, mode) => {
28
28
  chmodSync(path, mode);
29
29
  };
30
30
  const credentials = () => readJson(CREDENTIALS, null);
31
+ /** Which login a cached briefing came from: a different server or workspace never sees it. */
32
+ const loginKey = (c) => `${c.api_url}|${c.workspace.id}`;
31
33
  async function api(url, path, body, { token, timeoutMs = 15_000 } = {}) {
32
34
  const res = await fetch(new URL(path, url), {
33
35
  method: "POST",
@@ -79,6 +81,8 @@ async function login() {
79
81
  if (!creds)
80
82
  throw new Error("Timed out waiting for approval. Run `npx @openscaffold/cli login` again.");
81
83
  writeJson(CREDENTIALS, creds, 0o600);
84
+ // Offline fallback briefings belong to the previous login (maybe another server or workspace): start fresh.
85
+ rmSync(CACHE, { recursive: true, force: true });
82
86
  const written = [`${CREDENTIALS} (your login, readable only by you)`];
83
87
  // 1. MCP server at user scope (replace any earlier login's).
84
88
  const mcpUrl = `${creds.api_url}/api/mcp/mcp`;
@@ -101,7 +105,9 @@ async function login() {
101
105
  if (commands.length)
102
106
  written.push(`${SKILLS}/os-* (${commands.map((c) => `/os-${c.name}`).join(", ")})`);
103
107
  const self = hookCommand(process.argv[1], process.execPath).replace(/ session-start$/, "");
104
- console.log(`\nLogged in to ${creds.workspace.name}.\nWrote:\n${written.map((w) => ` - ${w}`).join("\n")}\nNothing was written into any repo.\n\nStart Claude Code in any repo; it loads the right customer automatically.\nTo undo everything: ${self} logout`);
108
+ console.log(`\nLogged in to ${creds.workspace.name}.\nWrote:\n${written.map((w) => ` - ${w}`).join("\n")}\nNothing was written into any repo.\n\nStart Claude Code in any repo; it loads the right customer automatically.\nTo undo everything: ${self} logout\n`);
109
+ // End on the status report, so a person or agent needn't run (and download) status separately.
110
+ await status();
105
111
  }
106
112
  // --- session-start (the SessionStart hook) ------------------------------------------------------
107
113
  const readStdin = async () => {
@@ -144,13 +150,13 @@ async function sessionStart() {
144
150
  if (dep) {
145
151
  mkdirSync(CACHE, { recursive: true });
146
152
  writeFileSync(join(CACHE, `${dep}.md`), briefing);
147
- writeJson(join(CACHE, "index.json"), { ...index, [cwd]: { deployment: dep, at: new Date().toISOString() } });
153
+ writeJson(join(CACHE, "index.json"), { ...index, [cwd]: { deployment: dep, at: new Date().toISOString(), login: loginKey(creds) } });
148
154
  }
149
155
  }
150
156
  catch {
151
- const last = index[cwd];
157
+ const last = index[cwd]?.login === loginKey(creds) ? index[cwd] : undefined; // a session started before a re-login may write late
152
158
  const cached = last && existsSync(join(CACHE, `${last.deployment}.md`)) ? readFileSync(join(CACHE, `${last.deployment}.md`), "utf8") : null;
153
- console.log(cached ? `${cached}\n\n(offline, from ${last.at})` : "OpenScaffold: offline");
159
+ console.log(cached ? `${cached}\n\n(offline, from ${last?.at})` : "OpenScaffold: offline");
154
160
  }
155
161
  }
156
162
  // --- status -------------------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openscaffold/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Connect Claude Code to your OpenScaffold workspace: each session loads the right customer deployment.",
5
5
  "type": "module",
6
6
  "bin": {