@newlandnpt/pep-cli 0.9.0-rc.1 → 0.9.0-rc.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.
Files changed (3) hide show
  1. package/README.md +12 -0
  2. package/dist/pep.cjs +56 -9
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -77,6 +77,18 @@ pep setup --skip-skills # only sign in and configure Maven
77
77
  pep setup group/sub -p # a different group, into THIS project
78
78
  ```
79
79
 
80
+ `--issuer`, `--client-id` and `--resource` work here exactly as on `pep auth login`, for pointing a
81
+ run at another deployment:
82
+
83
+ ```powershell
84
+ pep setup --issuer https://pep-dev.example --client-id <that deployment's id>
85
+ ```
86
+
87
+ ⚠ Both are needed for a non-production deployment: the client ID is baked in for production and does
88
+ not fork per environment, so production's ID gets `unauthorized_client` elsewhere. If you are already
89
+ signed in to a different deployment, `pep setup` signs in again rather than silently using the one
90
+ you are signed in to — and since there is a single stored sign-in, that replaces it.
91
+
80
92
  The integration guide **group** is baked in at build time (currently `distribution/skills`). Passing
81
93
  one overrides it **for that run only** — it is deliberately not remembered, unlike `--docs-url`.
82
94
  Where each repository installs *is* remembered, in the local ledger, so `pep skills update` later
package/dist/pep.cjs CHANGED
@@ -1174,17 +1174,27 @@ Repositories you installed earlier that have since left the group are reported,
1174
1174
  never deleted. \`pep skills remove <repo>\` drops one for good.
1175
1175
 
1176
1176
  The group is baked into this build and is not remembered between runs: pass one
1177
- to install from a different group, just for this run.`,
1177
+ to install from a different group, just for this run.
1178
+
1179
+ --issuer, --client-id and --resource are passed to step 1, exactly as on
1180
+ \`pep auth login\`, and are not remembered either. If you are already signed in to
1181
+ a different deployment, setup signs in again rather than silently using the one
1182
+ you are signed in to. There is a single stored sign-in, so signing in elsewhere
1183
+ replaces it \u2014 run \`pep auth login\` to go back.`,
1178
1184
  flags: [
1179
- "--skip-skills Skip the integration guide step",
1180
- "--skip-nexus Skip the Maven credential step (not needed outside Android)",
1185
+ "--skip-skills Skip the integration guide step",
1186
+ "--skip-nexus Skip the Maven credential step (not needed outside Android)",
1181
1187
  PROJECT_FLAG,
1182
- "--dir <path> Install skills into this directory instead"
1188
+ "--dir <path> Install skills into this directory instead",
1189
+ `--issuer <url> PEP server for this run (default: ${DEFAULT_ISSUER})`,
1190
+ "--client-id <id> Registered OAuth client for this run",
1191
+ "--resource <uri> Token audience; repeat for multiple resources"
1183
1192
  ],
1184
1193
  examples: [
1185
1194
  "pep setup",
1186
1195
  "pep setup --skip-nexus",
1187
- `pep setup ${DEFAULT_SKILLS_GROUP} -p`
1196
+ `pep setup ${DEFAULT_SKILLS_GROUP} -p`,
1197
+ "pep setup --issuer https://pep-dev.example --client-id <that deployment's id>"
1188
1198
  ]
1189
1199
  }
1190
1200
  };
@@ -1800,6 +1810,10 @@ function accountOf(user) {
1800
1810
  function messageOf(error) {
1801
1811
  return error instanceof Error ? error.message : String(error);
1802
1812
  }
1813
+ function sameIssuer(a, b) {
1814
+ const trim = (one) => one.trim().replace(/\/+$/, "").toLowerCase();
1815
+ return trim(a) === trim(b);
1816
+ }
1803
1817
  function driftedFromGroup(installedSources, groupRepos, group) {
1804
1818
  const present = new Set(groupRepos.map((one) => one.trim().toLowerCase()));
1805
1819
  return installedSources.filter((key) => {
@@ -1845,10 +1859,25 @@ async function runSetup(dependencies) {
1845
1859
  let login;
1846
1860
  let signedIn;
1847
1861
  try {
1848
- signedIn = await dependencies.auth.status();
1862
+ const current = await dependencies.auth.status();
1863
+ if (dependencies.requestedIssuer === void 0 || sameIssuer(current.authorization.issuer, dependencies.requestedIssuer)) {
1864
+ signedIn = current;
1865
+ } else {
1866
+ dependencies.onProgress(
1867
+ ` Signed in to ${current.authorization.issuer}, but --issuer names ${dependencies.requestedIssuer} \u2014 signing in again.`
1868
+ );
1869
+ }
1870
+ } catch {
1871
+ }
1872
+ if (signedIn !== void 0) {
1849
1873
  login = { alreadySignedIn: true, account: accountOf(signedIn.user) };
1850
1874
  dependencies.onProgress(` Already signed in as ${login.account} \u2014 skipped.`);
1851
- } catch {
1875
+ if (dependencies.loginOptionsGiven) {
1876
+ dependencies.onProgress(
1877
+ " (reused the stored sign-in; --client-id / --resource apply only to a fresh one)"
1878
+ );
1879
+ }
1880
+ } else {
1852
1881
  const config = await dependencies.loginConfig();
1853
1882
  dependencies.onProgress(" Opening your browser to sign in\u2026");
1854
1883
  await dependencies.auth.login(config, dependencies.onAuthorizationUrl);
@@ -1895,7 +1924,7 @@ function setupFailureSummary(report) {
1895
1924
  }
1896
1925
 
1897
1926
  // src/cli.ts
1898
- var VERSION = false ? "0.0.0-dev" : "0.9.0-rc.1";
1927
+ var VERSION = false ? "0.0.0-dev" : "0.9.0-rc.2";
1899
1928
  var SKILLS_ADD_DEPRECATION = "\u26A0 `pep skills add` will be removed in a future release.";
1900
1929
  function reportUpdate(result) {
1901
1930
  const conflicts = () => {
@@ -1975,6 +2004,19 @@ async function loginConfig(args, store = fileConfigStore()) {
1975
2004
  ...saved?.docsUrl !== void 0 ? { docsUrl: saved.docsUrl } : {}
1976
2005
  };
1977
2006
  }
2007
+ function takeLoginOptions(args) {
2008
+ const out = [];
2009
+ const issuer = option(args, "--issuer");
2010
+ if (issuer !== void 0) out.push("--issuer", normalizeIssuer(issuer));
2011
+ const clientId = option(args, "--client-id");
2012
+ if (clientId !== void 0) out.push("--client-id", clientId);
2013
+ for (const resource of repeatedOption(args, "--resource")) out.push("--resource", resource);
2014
+ return out;
2015
+ }
2016
+ function issuerOf(loginOptions) {
2017
+ const at = loginOptions.indexOf("--issuer");
2018
+ return at === -1 ? void 0 : loginOptions[at + 1];
2019
+ }
1978
2020
  function parseSkillsArgs(command, args, cwd) {
1979
2021
  const local = command === "list" || command === "remove";
1980
2022
  const explicitDirectory = local ? void 0 : option(args, "--dir");
@@ -2098,6 +2140,7 @@ async function main() {
2098
2140
  if (group === "setup") {
2099
2141
  const skipNexus = flag(args, "--skip-nexus");
2100
2142
  const skipSkills = flag(args, "--skip-skills");
2143
+ const loginOptions = takeLoginOptions(args);
2101
2144
  const { requested, chosenTarget } = parseSkillsArgs("setup", args);
2102
2145
  const skillsGroup = requested ?? DEFAULT_SKILLS_GROUP;
2103
2146
  const { configStore: configStore2, auth: auth2 } = createCliServices();
@@ -2105,7 +2148,11 @@ async function main() {
2105
2148
  const state = await stateStore.read();
2106
2149
  const report = await runSetup({
2107
2150
  auth: auth2,
2108
- loginConfig: () => loginConfig(args, configStore2),
2151
+ // ⚠ 传 `loginOptions` 而不是 `args`:后者到这里**恒为空**(`parseSkillsArgs` 要么抛、
2152
+ // 要么把剩下的吃干净),传它等于永远只用构建期默认值。
2153
+ loginConfig: () => loginConfig([...loginOptions], configStore2),
2154
+ ...issuerOf(loginOptions) !== void 0 ? { requestedIssuer: issuerOf(loginOptions) } : {},
2155
+ loginOptionsGiven: loginOptions.length > 0,
2109
2156
  group: skillsGroup,
2110
2157
  skipSkills,
2111
2158
  listGroupRepos: (remote) => listGroupRepos({ ...remote, group: skillsGroup }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newlandnpt/pep-cli",
3
- "version": "0.9.0-rc.1",
3
+ "version": "0.9.0-rc.2",
4
4
  "description": "PEP CLI —— 凭 PEP 身份读取 Newland 开发者文档与 agent skills",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",