bpmax-cli 0.1.44-beta.0 → 0.1.44-beta.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.
package/dist/bin.js CHANGED
@@ -206,7 +206,10 @@ var CLI_GOVERNANCE_PATHS = [
206
206
  "/api/cli/audit/start",
207
207
  "/api/cli/audit/finish",
208
208
  "/api/cli/bbs_invocations/start",
209
- "/api/cli/bbs_invocations/finish"
209
+ "/api/cli/bbs_invocations/finish",
210
+ "/api/cli/memory/status",
211
+ "/api/cli/memory/search",
212
+ "/api/cli/memory"
210
213
  ];
211
214
  var CLI_GOVERNANCE_UNSUPPORTED_MESSAGE = "\u5F53\u524D BPMAX \u5E73\u53F0\u7248\u672C\u4E0D\u652F\u6301 CLI \u6CBB\u7406\u80FD\u529B\uFF0C\u8BF7\u5347\u7EA7 huanpingtong-server \u540E\u518D\u4F7F\u7528 bpmax-cli 0.1.42+ \u7684\u8FDC\u7AEF\u4E1A\u52A1\u547D\u4EE4\u3002";
212
215
  function toCliGovernanceUnsupportedError(error, fallbackPath) {
@@ -268,6 +271,13 @@ function capabilityForRequest(method, path9) {
268
271
  if (normalizedPath.startsWith("/cli/bbs_invocations/")) {
269
272
  return void 0;
270
273
  }
274
+ if (normalizedMethod === "GET" && normalizedPath === "/cli/memory/status") return "memory.status";
275
+ if (normalizedMethod === "POST" && normalizedPath === "/cli/memory/search") return "memory.search";
276
+ if (normalizedMethod === "GET" && normalizedPath === "/cli/memory") return "memory.list";
277
+ if (normalizedMethod === "POST" && normalizedPath === "/cli/memory") return "memory.add";
278
+ if (normalizedMethod === "GET" && /^\/cli\/memory\/[^/]+$/.test(normalizedPath)) return "memory.get";
279
+ if (normalizedMethod === "PUT" && /^\/cli\/memory\/[^/]+$/.test(normalizedPath)) return "memory.update";
280
+ if (normalizedMethod === "DELETE" && /^\/cli\/memory\/[^/]+$/.test(normalizedPath)) return "memory.delete";
271
281
  if (normalizedMethod === "GET" && normalizedPath === "/user/current") return "user.current";
272
282
  if (normalizedMethod === "GET" && normalizedPath === "/workspace/by_key") return "flow.list";
273
283
  if (normalizedMethod === "GET" && normalizedPath === "/flow/flow_type") return "flow.list";
@@ -372,7 +382,7 @@ function normalizePath2(path9) {
372
382
  // package.json
373
383
  var package_default = {
374
384
  name: "bpmax-cli",
375
- version: "0.1.44-beta.0",
385
+ version: "0.1.44-beta.2",
376
386
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
377
387
  type: "module",
378
388
  bin: {
@@ -4459,6 +4469,7 @@ ${configEnabled ? "" : "> \u5F53\u524D profile \u7684 API Key \u5C1A\u672A\u5F00
4459
4469
  | --- | --- | --- |
4460
4470
  ${rows}
4461
4471
  | \u6700\u65B0\u914D\u7F6E\u540C\u6B65 | \`bpmax-config-latest\` | \`${commandPrefix3} config latest pull ${options.env}\` |
4472
+ | \u957F\u671F\u8BB0\u5FC6 | \`bpmax-memory-protocol\` | \`${commandPrefix3} memory search --scope all --query "<workspace> <flow_type> <task>"\` |
4462
4473
  | \u5B8C\u6574\u914D\u7F6E\u7F16\u6392 | \`bpmax-e2e-flow-config-orchestrator\` | \u6309\u7F16\u6392 Skill \u6267\u884C |
4463
4474
  | \u7AEF\u5230\u7AEF\u56DE\u5F52 | \`bpmax-e2e-flow-test-operator\` | \u6309\u56DE\u5F52 Skill \u6267\u884C |
4464
4475
 
@@ -4487,6 +4498,20 @@ ${commandPrefix3} config <domain> verify --id <id> --expect <work-file> --profil
4487
4498
  ${commandPrefix3} config workspace init ${envArg} --profile ${profileArg} --workspace-dir ${shellQuote3(options.environment.sysconfig_repo_path)} --format json
4488
4499
  ${commandPrefix3} config latest pull ${envArg} --profile ${profileArg} --format json
4489
4500
  \`\`\`
4501
+
4502
+ ## Memory \u4F7F\u7528\u89C4\u5219
4503
+ \u5F00\u59CB\u914D\u7F6E\u3001\u6392\u67E5\u6216\u6D4B\u8BD5\u524D\uFF0C\u5148\u8C03\u7528 \`bpmax-memory-protocol\` \u6216\u76F4\u63A5\u641C\u7D22 BPMAX memory\u3002\u67E5\u8BE2\u8BCD\u81F3\u5C11\u5305\u542B\u4E1A\u52A1\u540D\u3001workspace\u3001flow_type\u3001\u6A21\u677F/\u6570\u636E\u96C6/\u5BF9\u8C61 id \u548C\u76EE\u6807\u52A8\u4F5C\u3002
4504
+
4505
+ \`\`\`bash
4506
+ ${commandPrefix3} memory status --profile ${profileArg} --format json
4507
+ ${commandPrefix3} memory search --profile ${profileArg} --scope all --query "${display(options.environment.workspace || options.profile.workspace)} <flow_type> <task>" --format json
4508
+ \`\`\`
4509
+
4510
+ \u9A8C\u8BC1\u901A\u8FC7\u540E\uFF0C\u53EA\u5199\u53EF\u590D\u7528\u7ED3\u8BBA\uFF1A\`decision\`\u3001\`task_learning\`\u3001\`anti_pattern\`\u3001\`environmental\` \u6216 \`convention\`\u3002\u672A\u5B8C\u6210\u6216\u4E2D\u65AD\u6001\u53EA\u5199 \`session_state\`\u3002\u7981\u6B62\u5199\u5165 API Key\u3001Authorization\u3001token\u3001password\u3001\u9A8C\u8BC1\u7801\u3001\u624B\u673A\u53F7\u3001\u5B8C\u6574 payload \u6216\u5927\u6BB5\u63A5\u53E3\u54CD\u5E94\u3002
4511
+
4512
+ \`\`\`bash
4513
+ ${commandPrefix3} memory add --profile ${profileArg} --scope user --text "<learning>" --metadata '{"type":"task_learning","project_id":"bpmax","workspace":"${display(options.environment.workspace || options.profile.workspace)}"}' --format json
4514
+ \`\`\`
4490
4515
  ${end}
4491
4516
  `;
4492
4517
  }
@@ -4556,6 +4581,7 @@ import { promisify } from "util";
4556
4581
  import { password, text } from "@clack/prompts";
4557
4582
  import axios5 from "axios";
4558
4583
  var execFileAsync = promisify(execFile);
4584
+ var PLATFORM_SYSCONFIG_BRANCH = "master";
4559
4585
  async function ensureConfigCapability2(profile, capability) {
4560
4586
  if (capabilityEnabled(profile.config.capabilities_cache, capability)) {
4561
4587
  return;
@@ -4749,6 +4775,44 @@ async function withTransientGitCredentials(credentials, operation) {
4749
4775
  await rm2(askpassPath, { force: true });
4750
4776
  }
4751
4777
  }
4778
+ async function runGitWithTransientCredentials(args, workspaceDir, credentials) {
4779
+ await withTransientGitCredentials(
4780
+ credentials,
4781
+ (envVars) => execFileAsync("git", args, {
4782
+ cwd: workspaceDir,
4783
+ ...envVars ? { env: envVars } : {}
4784
+ })
4785
+ );
4786
+ }
4787
+ async function gitRefExists(workspaceDir, ref) {
4788
+ try {
4789
+ await execFileAsync("git", ["rev-parse", "--verify", ref], { cwd: workspaceDir });
4790
+ return true;
4791
+ } catch {
4792
+ return false;
4793
+ }
4794
+ }
4795
+ async function ensurePlatformSysconfigBranch(workspaceDir, credentials, remote = "origin", branch = PLATFORM_SYSCONFIG_BRANCH) {
4796
+ try {
4797
+ await runGitWithTransientCredentials(["fetch", remote, branch], workspaceDir, credentials);
4798
+ } catch {
4799
+ }
4800
+ if (await gitRefExists(workspaceDir, `${remote}/${branch}`)) {
4801
+ if (await gitRefExists(workspaceDir, branch)) {
4802
+ await execFileAsync("git", ["switch", branch], { cwd: workspaceDir });
4803
+ } else {
4804
+ await execFileAsync("git", ["switch", "--track", "-c", branch, `${remote}/${branch}`], { cwd: workspaceDir });
4805
+ }
4806
+ await execFileAsync("git", ["branch", "--set-upstream-to", `${remote}/${branch}`, branch], { cwd: workspaceDir });
4807
+ return;
4808
+ }
4809
+ if (await gitRefExists(workspaceDir, branch)) {
4810
+ await execFileAsync("git", ["switch", branch], { cwd: workspaceDir });
4811
+ } else {
4812
+ await execFileAsync("git", ["switch", "-C", branch], { cwd: workspaceDir });
4813
+ }
4814
+ await runGitWithTransientCredentials(["push", "-u", remote, branch], workspaceDir, credentials);
4815
+ }
4752
4816
  function sanitizeConfigRepositoryValue(value) {
4753
4817
  const redacted = redactAuditValue(value);
4754
4818
  return sanitizeGitUrls(redacted);
@@ -4824,6 +4888,7 @@ async function collectEnvironment(env, profile, existed, options = {}) {
4824
4888
  `/Users/you/sysconfig-${env}`
4825
4889
  ),
4826
4890
  git_remote: options.gitRemote || existed?.git_remote || "origin",
4891
+ git_branch: options.gitBranch || existed?.git_branch || PLATFORM_SYSCONFIG_BRANCH,
4827
4892
  username: await promptValue(options.username || existed?.username, "sysconfigdiff username"),
4828
4893
  password: await promptSecret(options.password || existed?.password, "sysconfigdiff password or token"),
4829
4894
  extra_headers: existed?.extra_headers || {}
@@ -5009,6 +5074,7 @@ async function initConfigWorkspaceFromPlatform(env, options) {
5009
5074
  } else {
5010
5075
  await assertExistingGitWorkspace(workspaceDir, gitUrl, options.force);
5011
5076
  }
5077
+ await ensurePlatformSysconfigBranch(workspaceDir, credentials);
5012
5078
  const latestConfig = await loadConfig();
5013
5079
  latestConfig.profiles[profile.name].config_environments = {
5014
5080
  ...latestConfig.profiles[profile.name].config_environments || {},
@@ -5019,6 +5085,7 @@ async function initConfigWorkspaceFromPlatform(env, options) {
5019
5085
  sysconfigdiff_base_url: sysconfigdiffBaseUrlFromEnvironment(platformEnv),
5020
5086
  sysconfig_repo_path: workspaceDir,
5021
5087
  git_remote: "origin",
5088
+ git_branch: PLATFORM_SYSCONFIG_BRANCH,
5022
5089
  extra_headers: {}
5023
5090
  }
5024
5091
  };
@@ -5036,6 +5103,7 @@ async function initConfigWorkspaceFromPlatform(env, options) {
5036
5103
  workspace_dir: workspaceDir,
5037
5104
  cloned: !existed,
5038
5105
  profile_saved: true,
5106
+ git_branch: PLATFORM_SYSCONFIG_BRANCH,
5039
5107
  agents_file: guide.path,
5040
5108
  next_commands: {
5041
5109
  latest_pull: `${commandPrefix2()} config latest pull ${env} --profile ${profile.name} --format json`
@@ -5061,9 +5129,11 @@ async function pullLatestConfigEnvironment(env, options) {
5061
5129
  for (const step of ["pullcommit", "extract", "pushcommit"]) {
5062
5130
  steps[step] = String(redactAuditValue(await callPlatformSysconfigStep(platformEnvironment, env, step)));
5063
5131
  }
5132
+ const gitRemote = environment.git_remote || "origin";
5133
+ const gitBranch = environment.git_branch || PLATFORM_SYSCONFIG_BRANCH;
5064
5134
  const pull = await withTransientGitCredentials(
5065
5135
  gitCredentials,
5066
- (envVars) => execFileAsync("git", ["pull", "--ff-only", environment.git_remote || "origin"], {
5136
+ (envVars) => execFileAsync("git", ["pull", "--ff-only", gitRemote, gitBranch], {
5067
5137
  cwd: repo,
5068
5138
  ...envVars ? { env: envVars } : {}
5069
5139
  })
@@ -5739,6 +5809,85 @@ function registerInitCommand(program2, deps = {}) {
5739
5809
  });
5740
5810
  }
5741
5811
 
5812
+ // src/commands/memory.ts
5813
+ function parseLimit(input, fallback) {
5814
+ const value = Number(input ?? fallback);
5815
+ if (!Number.isInteger(value) || value <= 0 || value > 100) {
5816
+ throw new Error("limit must be an integer between 1 and 100.");
5817
+ }
5818
+ return value;
5819
+ }
5820
+ function normalizeScope(scope, allowAll) {
5821
+ const value = scope || "user";
5822
+ const allowed = allowAll ? ["user", "organization", "all"] : ["user", "organization"];
5823
+ if (!allowed.includes(value)) {
5824
+ throw new Error(`scope must be one of: ${allowed.join(", ")}.`);
5825
+ }
5826
+ return value;
5827
+ }
5828
+ async function parseOptionalJson(input, label) {
5829
+ if (!input) {
5830
+ return void 0;
5831
+ }
5832
+ return parseJsonInput(input, label);
5833
+ }
5834
+ async function memoryRequest(options, method, path9, capability, data, params) {
5835
+ const profile = resolveProfile(await loadConfig(), options.profile);
5836
+ const client = createApiClient(profile);
5837
+ return apiRequest(client, method, path9, {
5838
+ capability,
5839
+ data: redactAuditValue(data),
5840
+ params: params ? redactAuditValue(params) : void 0
5841
+ });
5842
+ }
5843
+ function registerMemoryCommands(program2) {
5844
+ const memory = program2.command("memory").description("Search and write BPMAX agent-scoped memory through the platform proxy");
5845
+ memory.command("status").description("Check BPMAX memory proxy and backend status").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (options) => {
5846
+ const result = await memoryRequest(options, "GET", "/cli/memory/status", "memory.status");
5847
+ printResult(options.format, result);
5848
+ });
5849
+ memory.command("search").description("Search BPMAX memory for the current API-key agent").requiredOption("--query <text>", "Search query").option("--scope <scope>", "Memory scope: user, organization, or all", "user").option("--limit <limit>", "Maximum result count", "10").option("--filters <json>", "Optional JSON filters or @file").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (options) => {
5850
+ const result = await memoryRequest(options, "POST", "/cli/memory/search", "memory.search", {
5851
+ query: options.query,
5852
+ scope: normalizeScope(options.scope, true),
5853
+ limit: parseLimit(options.limit, 10),
5854
+ filters: await parseOptionalJson(options.filters, "--filters")
5855
+ });
5856
+ printResult(options.format, result);
5857
+ });
5858
+ memory.command("add").description("Add BPMAX memory for the current API-key agent").requiredOption("--text <text>", "Memory text").option("--scope <scope>", "Memory scope: user or organization", "user").option("--metadata <json>", "Optional JSON metadata or @file").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (options) => {
5859
+ const result = await memoryRequest(options, "POST", "/cli/memory", "memory.add", {
5860
+ text: options.text,
5861
+ scope: normalizeScope(options.scope, false),
5862
+ metadata: await parseOptionalJson(options.metadata, "--metadata")
5863
+ });
5864
+ printResult(options.format, result);
5865
+ });
5866
+ memory.command("list").description("List BPMAX memory when supported by the platform proxy").option("--scope <scope>", "Memory scope: user, organization, or all", "user").option("--limit <limit>", "Maximum result count", "20").option("--filters <json>", "Optional JSON filters or @file").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (options) => {
5867
+ const result = await memoryRequest(options, "GET", "/cli/memory", "memory.list", void 0, {
5868
+ scope: normalizeScope(options.scope, true),
5869
+ limit: parseLimit(options.limit, 20),
5870
+ filters: options.filters ? JSON.stringify(await parseOptionalJson(options.filters, "--filters")) : void 0
5871
+ });
5872
+ printResult(options.format, result);
5873
+ });
5874
+ memory.command("get <id>").description("Get one BPMAX memory item when supported by the platform proxy").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (id, options) => {
5875
+ const result = await memoryRequest(options, "GET", `/cli/memory/${encodeURIComponent(id)}`, "memory.get");
5876
+ printResult(options.format, result);
5877
+ });
5878
+ memory.command("update <id>").description("Update one BPMAX memory item when supported by the platform proxy").requiredOption("--text <text>", "Replacement memory text").option("--metadata <json>", "Optional JSON metadata or @file").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (id, options) => {
5879
+ const result = await memoryRequest(options, "PUT", `/cli/memory/${encodeURIComponent(id)}`, "memory.update", {
5880
+ text: options.text,
5881
+ metadata: await parseOptionalJson(options.metadata, "--metadata")
5882
+ });
5883
+ printResult(options.format, result);
5884
+ });
5885
+ memory.command("delete <id>").description("Delete one BPMAX memory item when supported by the platform proxy").option("--profile <profile>", "Profile name").option("--format <format>", "Output format", "json").action(async (id, options) => {
5886
+ const result = await memoryRequest(options, "DELETE", `/cli/memory/${encodeURIComponent(id)}`, "memory.delete");
5887
+ printResult(options.format, result);
5888
+ });
5889
+ }
5890
+
5742
5891
  // src/core/form-schema.ts
5743
5892
  var FIELD_KEY_NAMES = [
5744
5893
  "key",
@@ -7379,6 +7528,13 @@ var schemaEntries = [
7379
7528
  { name: "config.repository.sync", description: "Run platform sysconfigdiff pullcommit/extract/pushcommit steps.", method: "POST", path: "/api/config_repository/:env?action=sync" },
7380
7529
  { name: "config.latest.pull", description: "Sync latest BPMAX sysconfig repositories for a configured environment.", method: "external", path: "external:sysconfigdiff + git" },
7381
7530
  { name: "config.e2e.run", description: "Run BPMAX config end-to-end validation orchestration.", method: "local+remote", path: "cli:e2e" },
7531
+ { name: "memory.status", description: "Check BPMAX memory backend status.", method: "GET", path: "/api/cli/memory/status" },
7532
+ { name: "memory.search", description: "Search BPMAX memory for the current API-key agent.", method: "POST", path: "/api/cli/memory/search" },
7533
+ { name: "memory.add", description: "Add BPMAX memory for the current API-key agent.", method: "POST", path: "/api/cli/memory" },
7534
+ { name: "memory.list", description: "List BPMAX memory when supported by the platform proxy.", method: "GET", path: "/api/cli/memory" },
7535
+ { name: "memory.get", description: "Get a BPMAX memory item when supported by the platform proxy.", method: "GET", path: "/api/cli/memory/:id" },
7536
+ { name: "memory.update", description: "Update a BPMAX memory item when supported by the platform proxy.", method: "PUT", path: "/api/cli/memory/:id" },
7537
+ { name: "memory.delete", description: "Delete a BPMAX memory item when supported by the platform proxy.", method: "DELETE", path: "/api/cli/memory/:id" },
7382
7538
  { name: "api.raw", description: "Call raw BPMAX API paths allowed by server capability whitelist.", method: "*", path: "/api/*" }
7383
7539
  ];
7384
7540
 
@@ -8588,6 +8744,7 @@ registerSchemaCommands(program);
8588
8744
  registerUserCommands(program);
8589
8745
  registerEsCommands(program);
8590
8746
  registerFlowCommands(program);
8747
+ registerMemoryCommands(program);
8591
8748
  registerProjectCommands(program);
8592
8749
  registerStepCommands(program);
8593
8750
  registerRecipeCommands(program);