@lotics/cli 0.96.3 → 0.96.5
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 +2 -0
- package/dist/src/cli.js +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,6 +72,8 @@ lotics org use acme # switch active org by name (or org id)
|
|
|
72
72
|
lotics org use "Acme Corp" # names are case-insensitive
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
+
The org **id** is the identity; the name is a label cached when the key was saved. Rename an org in the app and the cached label goes stale — the old name still works, the new one matches nothing — until `lotics auth whoami` refreshes it. A name matching two saved orgs is refused rather than guessed; use the id.
|
|
76
|
+
|
|
75
77
|
### Working in parallel (worktrees)
|
|
76
78
|
|
|
77
79
|
Pin a directory to its own org/workspace so a global `org use` elsewhere never disturbs it. The pin is a pointer — the key still comes from the global store, so there's nothing to paste:
|
package/dist/src/cli.js
CHANGED
|
@@ -70166,6 +70166,16 @@ function runNpm(args, cwd) {
|
|
|
70166
70166
|
});
|
|
70167
70167
|
});
|
|
70168
70168
|
}
|
|
70169
|
+
function readAppWorkspaceId(projectDir) {
|
|
70170
|
+
try {
|
|
70171
|
+
const pkgPath2 = path5.join(projectDir, "package.json");
|
|
70172
|
+
if (!fs4.existsSync(pkgPath2)) return null;
|
|
70173
|
+
const pkg2 = JSON.parse(fs4.readFileSync(pkgPath2, "utf-8"));
|
|
70174
|
+
return pkg2.lotics?.workspace_id ?? null;
|
|
70175
|
+
} catch {
|
|
70176
|
+
return null;
|
|
70177
|
+
}
|
|
70178
|
+
}
|
|
70169
70179
|
function readAppMeta(projectDir) {
|
|
70170
70180
|
const pkgPath2 = path5.join(projectDir, "package.json");
|
|
70171
70181
|
if (!fs4.existsSync(pkgPath2)) {
|
|
@@ -91542,6 +91552,14 @@ function announceTarget(ctx, workspaceId) {
|
|
|
91542
91552
|
}
|
|
91543
91553
|
console.error(`lotics \u2192 ${org} / ${workspaceId}`);
|
|
91544
91554
|
}
|
|
91555
|
+
function applyAppManifestWorkspace(ctx, command, subcommand, pathArg, flags) {
|
|
91556
|
+
if (command !== "app") return;
|
|
91557
|
+
if (flags.workspace || process.env.LOTICS_WORKSPACE) return;
|
|
91558
|
+
if (subcommand === "create" || subcommand === "pull") return;
|
|
91559
|
+
const dir = pathArg && !pathArg.startsWith("-") ? pathArg : process.cwd();
|
|
91560
|
+
const workspaceId = readAppWorkspaceId(dir);
|
|
91561
|
+
if (workspaceId) ctx.workspaceId = workspaceId;
|
|
91562
|
+
}
|
|
91545
91563
|
async function resolveWorkspace(client, ctx) {
|
|
91546
91564
|
if (ctx.workspaceId) {
|
|
91547
91565
|
announceTarget(ctx, ctx.workspaceId);
|
|
@@ -91630,6 +91648,11 @@ async function main() {
|
|
|
91630
91648
|
const info = await client2.whoami();
|
|
91631
91649
|
const existing = loadGlobalConfig() ?? {};
|
|
91632
91650
|
saveGlobalConfig({ ...existing, email: info.email });
|
|
91651
|
+
const cached2 = existing.profiles?.[info.organization_id];
|
|
91652
|
+
if (cached2 && cached2.org_name !== info.organization_name) {
|
|
91653
|
+
upsertProfile(info.organization_id, { api_key: cached2.api_key, org_name: info.organization_name });
|
|
91654
|
+
console.error(`Renamed since this key was saved: "${cached2.org_name}" \u2192 "${info.organization_name}" (updated locally)`);
|
|
91655
|
+
}
|
|
91633
91656
|
const viewAs = flags.viewAs ?? process.env.LOTICS_VIEW_AS;
|
|
91634
91657
|
if (flags.json) {
|
|
91635
91658
|
console.log(JSON.stringify({ ...info, workspace_id: ctx2.workspaceId ?? null, source: ctx2.source, view_as: viewAs ?? null }, null, 2));
|
|
@@ -91739,6 +91762,7 @@ async function main() {
|
|
|
91739
91762
|
await appCodegen({ projectDir });
|
|
91740
91763
|
return;
|
|
91741
91764
|
}
|
|
91765
|
+
applyAppManifestWorkspace(ctx2, command, subcommand, projectDir, flags);
|
|
91742
91766
|
const viewAsMemberId = flags.viewAs ?? process.env.LOTICS_VIEW_AS;
|
|
91743
91767
|
const client2 = new LoticsClient({ apiKey: ctx2.apiKey, workspaceId: ctx2.workspaceId, viewAsMemberId });
|
|
91744
91768
|
await resolveWorkspace(client2, ctx2);
|
|
@@ -91964,6 +91988,7 @@ Available workspaces:`);
|
|
|
91964
91988
|
if (ctx.orgName) console.error(`Org: ${ctx.orgName}`);
|
|
91965
91989
|
return;
|
|
91966
91990
|
}
|
|
91991
|
+
applyAppManifestWorkspace(ctx, command, subcommand, subcommand === "dev" ? toolArgs : void 0, flags);
|
|
91967
91992
|
await resolveWorkspace(client, ctx);
|
|
91968
91993
|
if (command === "knowledge") {
|
|
91969
91994
|
await runKnowledgeCommand(client, subcommand, toolArgs, flags);
|