@docyrus/docyrus 0.0.76 → 0.0.77

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/main.js CHANGED
@@ -139349,7 +139349,7 @@ function buildInputSchema(args2, env2, options2) {
139349
139349
  // package.json
139350
139350
  var package_default = {
139351
139351
  name: "@docyrus/docyrus",
139352
- version: "0.0.76",
139352
+ version: "0.0.77",
139353
139353
  private: false,
139354
139354
  description: "Docyrus API CLI",
139355
139355
  main: "./main.js",
@@ -140200,7 +140200,7 @@ function createAppsCli(dependencies) {
140200
140200
  }
140201
140201
 
140202
140202
  // src/commands/authCommands.ts
140203
- var import_node_child_process2 = require("node:child_process");
140203
+ var import_node_child_process3 = require("node:child_process");
140204
140204
  var import_node_util = require("node:util");
140205
140205
 
140206
140206
  // src/constants.ts
@@ -140362,8 +140362,22 @@ async function sleep(milliseconds) {
140362
140362
  });
140363
140363
  }
140364
140364
 
140365
+ // src/services/openBrowser.ts
140366
+ var import_node_child_process2 = require("node:child_process");
140367
+ function openBrowser(url2) {
140368
+ if (process.platform === "darwin") {
140369
+ (0, import_node_child_process2.spawn)("open", [url2], { stdio: "ignore", detached: true }).unref();
140370
+ return;
140371
+ }
140372
+ if (process.platform === "win32") {
140373
+ (0, import_node_child_process2.spawn)("cmd", ["/c", "start", "", url2], { stdio: "ignore", detached: true, windowsHide: true }).unref();
140374
+ return;
140375
+ }
140376
+ (0, import_node_child_process2.spawn)("xdg-open", [url2], { stdio: "ignore", detached: true }).unref();
140377
+ }
140378
+
140365
140379
  // src/commands/authCommands.ts
140366
- var execFile2 = (0, import_node_util.promisify)(import_node_child_process2.execFile);
140380
+ var execFile2 = (0, import_node_util.promisify)(import_node_child_process3.execFile);
140367
140381
  async function updateGitRemoteToken(cwd, githubToken) {
140368
140382
  try {
140369
140383
  const { stdout } = await execFile2("git", ["remote", "get-url", "origin"], { cwd });
@@ -140400,6 +140414,54 @@ function logVerificationHint(verification, agentMode, onMessage) {
140400
140414
  console.log(line);
140401
140415
  }
140402
140416
  }
140417
+ function listenForEnterToOpenBrowser(url2, agentMode) {
140418
+ if (agentMode) {
140419
+ return () => {
140420
+ };
140421
+ }
140422
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
140423
+ return () => {
140424
+ };
140425
+ }
140426
+ const stdin = process.stdin;
140427
+ const wasRaw = stdin.isRaw === true;
140428
+ let opened = false;
140429
+ let cleaned = false;
140430
+ const cleanup = () => {
140431
+ if (cleaned) {
140432
+ return;
140433
+ }
140434
+ cleaned = true;
140435
+ stdin.off("data", onData);
140436
+ if (!wasRaw && typeof stdin.setRawMode === "function") {
140437
+ stdin.setRawMode(false);
140438
+ }
140439
+ stdin.pause();
140440
+ };
140441
+ const onData = (data) => {
140442
+ const key = typeof data === "string" ? data : data.toString("utf8");
140443
+ if (key === "\r" || key === "\n" || key === "\r\n") {
140444
+ if (!opened) {
140445
+ opened = true;
140446
+ console.log("Opening link in browser...");
140447
+ openBrowser(url2);
140448
+ }
140449
+ cleanup();
140450
+ return;
140451
+ }
140452
+ if (key === "") {
140453
+ cleanup();
140454
+ process.kill(process.pid, "SIGINT");
140455
+ }
140456
+ };
140457
+ if (typeof stdin.setRawMode === "function") {
140458
+ stdin.setRawMode(true);
140459
+ }
140460
+ stdin.resume();
140461
+ stdin.on("data", onData);
140462
+ console.log("Press ENTER to open link in browser");
140463
+ return cleanup;
140464
+ }
140403
140465
  async function resolveTenantIdSelector(params) {
140404
140466
  const selector = params.selector.trim();
140405
140467
  if (/^\d+$/.test(selector)) {
@@ -140498,40 +140560,50 @@ function createAuthCli(dependencies) {
140498
140560
  "Client ID is required. Pass --clientId, set DOCYRUS_API_CLIENT_ID, or login once with --clientId to save it."
140499
140561
  );
140500
140562
  }
140501
- const profile = manualAccessToken ? await loginWithManualTokens({
140502
- apiBaseUrl,
140503
- accessToken: manualAccessToken,
140504
- refreshToken: manualRefreshToken,
140505
- clientId: context.options.clientId,
140506
- scope: context.options.scope,
140507
- dependencies,
140508
- env: context.env
140509
- }) : await dependencies.createAuthSessionService(apiBaseUrl).loginWithDeviceFlow({
140510
- clientId,
140511
- scope: context.options.scope,
140512
- onVerification: (verification) => {
140513
- logVerificationHint(verification, context.agent, dependencies.onMessage);
140514
- }
140515
- });
140516
- if (!manualAccessToken && resolvedClient.resolvedClientId) {
140517
- await dependencies.environmentConfigService.setDefaultClientId(resolvedClient.resolvedClientId);
140518
- }
140519
- return await injectContext({
140520
- apiBaseUrl,
140521
- authStore: dependencies.authStore,
140522
- payload: {
140523
- authenticated: true,
140563
+ let cleanupOpenInBrowserListener = () => {
140564
+ };
140565
+ try {
140566
+ const profile = manualAccessToken ? await loginWithManualTokens({
140524
140567
  apiBaseUrl,
140525
- userId: profile.userId,
140526
- email: profile.email,
140527
- tenantId: profile.tenantId,
140528
- tenantName: profile.tenantName,
140529
- tenantNo: profile.tenantNo,
140530
- clientId: profile.clientId,
140531
- scope: profile.scope,
140532
- expiresAt: profile.expiresAt
140568
+ accessToken: manualAccessToken,
140569
+ refreshToken: manualRefreshToken,
140570
+ clientId: context.options.clientId,
140571
+ scope: context.options.scope,
140572
+ dependencies,
140573
+ env: context.env
140574
+ }) : await dependencies.createAuthSessionService(apiBaseUrl).loginWithDeviceFlow({
140575
+ clientId,
140576
+ scope: context.options.scope,
140577
+ onVerification: (verification) => {
140578
+ logVerificationHint(verification, context.agent, dependencies.onMessage);
140579
+ cleanupOpenInBrowserListener = listenForEnterToOpenBrowser(
140580
+ verification.verificationUriComplete,
140581
+ context.agent
140582
+ );
140583
+ }
140584
+ });
140585
+ if (!manualAccessToken && resolvedClient.resolvedClientId) {
140586
+ await dependencies.environmentConfigService.setDefaultClientId(resolvedClient.resolvedClientId);
140533
140587
  }
140534
- });
140588
+ return await injectContext({
140589
+ apiBaseUrl,
140590
+ authStore: dependencies.authStore,
140591
+ payload: {
140592
+ authenticated: true,
140593
+ apiBaseUrl,
140594
+ userId: profile.userId,
140595
+ email: profile.email,
140596
+ tenantId: profile.tenantId,
140597
+ tenantName: profile.tenantName,
140598
+ tenantNo: profile.tenantNo,
140599
+ clientId: profile.clientId,
140600
+ scope: profile.scope,
140601
+ expiresAt: profile.expiresAt
140602
+ }
140603
+ });
140604
+ } finally {
140605
+ cleanupOpenInBrowserListener();
140606
+ }
140535
140607
  }
140536
140608
  });
140537
140609
  authCli.command("set-tokens", {
@@ -140649,22 +140721,32 @@ function createAuthCli(dependencies) {
140649
140721
  selector: context.args.tenantSelector,
140650
140722
  userId: context.options.userId
140651
140723
  });
140652
- const switched = await authSessionService.switchTenant({
140653
- tenantId,
140654
- userId: context.options.userId,
140655
- scope: context.options.scope,
140656
- onVerification: (verification) => {
140657
- logVerificationHint(verification, context.agent, dependencies.onMessage);
140658
- }
140659
- });
140660
- return await injectContext({
140661
- apiBaseUrl,
140662
- authStore: dependencies.authStore,
140663
- payload: {
140664
- switched: true,
140665
- ...switched
140666
- }
140667
- });
140724
+ let cleanupOpenInBrowserListener = () => {
140725
+ };
140726
+ try {
140727
+ const switched = await authSessionService.switchTenant({
140728
+ tenantId,
140729
+ userId: context.options.userId,
140730
+ scope: context.options.scope,
140731
+ onVerification: (verification) => {
140732
+ logVerificationHint(verification, context.agent, dependencies.onMessage);
140733
+ cleanupOpenInBrowserListener = listenForEnterToOpenBrowser(
140734
+ verification.verificationUriComplete,
140735
+ context.agent
140736
+ );
140737
+ }
140738
+ });
140739
+ return await injectContext({
140740
+ apiBaseUrl,
140741
+ authStore: dependencies.authStore,
140742
+ payload: {
140743
+ switched: true,
140744
+ ...switched
140745
+ }
140746
+ });
140747
+ } finally {
140748
+ cleanupOpenInBrowserListener();
140749
+ }
140668
140750
  }
140669
140751
  });
140670
140752
  authCli.command(tenantsCli);
@@ -140794,7 +140876,7 @@ function createAuthCli(dependencies) {
140794
140876
  }
140795
140877
 
140796
140878
  // src/commands/browserCommands.ts
140797
- var import_node_child_process3 = require("node:child_process");
140879
+ var import_node_child_process4 = require("node:child_process");
140798
140880
  var import_node_fs3 = require("node:fs");
140799
140881
  var import_node_path4 = require("node:path");
140800
140882
  function summarizeFailure(result) {
@@ -140859,7 +140941,7 @@ function executeBrowserTool(params) {
140859
140941
  resourceRoot,
140860
140942
  scriptName: params.scriptName
140861
140943
  });
140862
- const spawnCommand = params.spawnSyncFn ?? import_node_child_process3.spawnSync;
140944
+ const spawnCommand = params.spawnSyncFn ?? import_node_child_process4.spawnSync;
140863
140945
  const processExecPath = params.processExecPath ?? process.execPath;
140864
140946
  const result = spawnCommand(processExecPath, [scriptPath, ...params.args], {
140865
140947
  encoding: "utf8",
@@ -142500,7 +142582,7 @@ ${hints}`;
142500
142582
  }
142501
142583
 
142502
142584
  // src/knowledge/codeRefs.ts
142503
- var import_node_child_process4 = require("node:child_process");
142585
+ var import_node_child_process5 = require("node:child_process");
142504
142586
  var import_promises6 = require("node:fs/promises");
142505
142587
  var import_node_path10 = require("node:path");
142506
142588
  init_graph();
@@ -142509,7 +142591,7 @@ var EXCLUDE_GLOBS = ["*.md"];
142509
142591
  var DOCYRUS_REF_RE = /(?:\/\/|#)\s*@docyrus:\s*\[\[([^\]]+)\]\]/gu;
142510
142592
  function tryExec(command, args2, cwd) {
142511
142593
  return new Promise((resolve2) => {
142512
- (0, import_node_child_process4.execFile)(command, args2, { cwd, maxBuffer: 50 * 1024 * 1024 }, (error48, stdout) => {
142594
+ (0, import_node_child_process5.execFile)(command, args2, { cwd, maxBuffer: 50 * 1024 * 1024 }, (error48, stdout) => {
142513
142595
  if (error48) {
142514
142596
  const exitCode = error48.code;
142515
142597
  const status = error48.status;
@@ -149189,12 +149271,12 @@ function formatKnowledgeIndexErrors(errors, styler) {
149189
149271
  }
149190
149272
 
149191
149273
  // src/knowledge/audit.ts
149192
- var import_node_child_process5 = require("node:child_process");
149274
+ var import_node_child_process6 = require("node:child_process");
149193
149275
  var import_node_fs10 = require("node:fs");
149194
149276
  init_graph();
149195
149277
  function runGit(projectRoot, args2) {
149196
149278
  return new Promise((resolve2) => {
149197
- (0, import_node_child_process5.execFile)("git", args2, {
149279
+ (0, import_node_child_process6.execFile)("git", args2, {
149198
149280
  cwd: projectRoot,
149199
149281
  encoding: "utf8",
149200
149282
  maxBuffer: 20 * 1024 * 1024
@@ -151041,12 +151123,12 @@ function createProjectPlanCli(dependencies) {
151041
151123
  }
151042
151124
 
151043
151125
  // src/services/releaseService.ts
151044
- var import_node_child_process6 = require("node:child_process");
151126
+ var import_node_child_process7 = require("node:child_process");
151045
151127
  var import_node_fs15 = require("node:fs");
151046
151128
  var import_promises18 = __toESM(require("node:fs/promises"));
151047
151129
  var import_node_path23 = __toESM(require("node:path"));
151048
151130
  function git(args2, cwd, timeout = 15e3) {
151049
- return (0, import_node_child_process6.execFileSync)("git", args2, { cwd, encoding: "utf8", timeout, stdio: ["pipe", "pipe", "pipe"] }).trim();
151131
+ return (0, import_node_child_process7.execFileSync)("git", args2, { cwd, encoding: "utf8", timeout, stdio: ["pipe", "pipe", "pipe"] }).trim();
151050
151132
  }
151051
151133
  function gitSafe(args2, cwd, timeout) {
151052
151134
  try {
@@ -151357,7 +151439,7 @@ async function executeRelease(params) {
151357
151439
  try {
151358
151440
  const changelogFile = import_node_path23.default.join(root, ".release-notes.tmp.md");
151359
151441
  await import_promises18.default.writeFile(changelogFile, changelogEntry, "utf8");
151360
- (0, import_node_child_process6.execFileSync)("gh", [
151442
+ (0, import_node_child_process7.execFileSync)("gh", [
151361
151443
  "release",
151362
151444
  "create",
151363
151445
  `v${nextVersion}`,
@@ -152528,11 +152610,80 @@ function createStudioCli(dependencies) {
152528
152610
  return await wrapStudioPayload(studio.apiBaseUrl, dependencies, response.data);
152529
152611
  }
152530
152612
  });
152613
+ studioCli.command("search-fields", {
152614
+ description: "Search fields across all data sources, with filters and paging",
152615
+ options: external_exports.object({
152616
+ dataSourceId: external_exports.string().optional().describe("Comma separated data source IDs"),
152617
+ type: external_exports.string().optional().describe("Comma separated field types"),
152618
+ keyword: external_exports.string().optional().describe("Substring match against field name and slug"),
152619
+ limit: external_exports.coerce.number().int().min(1).max(1e3).optional().describe("Page size (default 100)"),
152620
+ offset: external_exports.coerce.number().int().min(0).optional().describe("Page offset (default 0)")
152621
+ }),
152622
+ run: async (context) => {
152623
+ const studio = await getStudioRunContext(dependencies);
152624
+ const response = await studio.apiClient.request({
152625
+ method: "GET",
152626
+ path: "/dev/data-sources/fields",
152627
+ query: {
152628
+ dataSourceId: context.options.dataSourceId,
152629
+ type: context.options.type,
152630
+ keyword: context.options.keyword,
152631
+ limit: context.options.limit,
152632
+ offset: context.options.offset
152633
+ }
152634
+ });
152635
+ return await wrapStudioPayload(studio.apiBaseUrl, dependencies, response.data);
152636
+ }
152637
+ });
152638
+ studioCli.command("search-enums", {
152639
+ description: "Search enums across all data sources, fields, and enum sets, with paging",
152640
+ options: external_exports.object({
152641
+ dataSourceId: external_exports.string().optional().describe("Filter by data source ID"),
152642
+ enumSetId: external_exports.string().optional().describe("Filter by enum set ID"),
152643
+ fieldId: external_exports.string().optional().describe("Filter by field ID"),
152644
+ limit: external_exports.coerce.number().int().min(1).max(1e3).optional().describe("Page size (default 100)"),
152645
+ offset: external_exports.coerce.number().int().min(0).optional().describe("Page offset (default 0)")
152646
+ }),
152647
+ run: async (context) => {
152648
+ const studio = await getStudioRunContext(dependencies);
152649
+ const response = await studio.apiClient.request({
152650
+ method: "GET",
152651
+ path: "/dev/data-sources/enums",
152652
+ query: {
152653
+ dataSourceId: context.options.dataSourceId,
152654
+ enumSetId: context.options.enumSetId,
152655
+ fieldId: context.options.fieldId,
152656
+ limit: context.options.limit,
152657
+ offset: context.options.offset
152658
+ }
152659
+ });
152660
+ return await wrapStudioPayload(studio.apiBaseUrl, dependencies, response.data);
152661
+ }
152662
+ });
152663
+ studioCli.command("search-enum-sets", {
152664
+ description: "Search enum sets, with paging",
152665
+ options: external_exports.object({
152666
+ limit: external_exports.coerce.number().int().min(1).max(1e3).optional().describe("Page size (default 100)"),
152667
+ offset: external_exports.coerce.number().int().min(0).optional().describe("Page offset (default 0)")
152668
+ }),
152669
+ run: async (context) => {
152670
+ const studio = await getStudioRunContext(dependencies);
152671
+ const response = await studio.apiClient.request({
152672
+ method: "GET",
152673
+ path: "/dev/data-sources/enum-sets",
152674
+ query: {
152675
+ limit: context.options.limit,
152676
+ offset: context.options.offset
152677
+ }
152678
+ });
152679
+ return await wrapStudioPayload(studio.apiBaseUrl, dependencies, response.data);
152680
+ }
152681
+ });
152531
152682
  return studioCli;
152532
152683
  }
152533
152684
 
152534
152685
  // src/commands/tuiCommand.ts
152535
- var import_node_child_process7 = require("node:child_process");
152686
+ var import_node_child_process8 = require("node:child_process");
152536
152687
  var import_node_fs16 = require("node:fs");
152537
152688
  var import_node_path25 = require("node:path");
152538
152689
  function summarizeFailure2(result) {
@@ -152578,7 +152729,7 @@ function resolveOpenTuiEntryPath(options2 = {}) {
152578
152729
  return resolved;
152579
152730
  }
152580
152731
  function ensureBunAvailable(options2 = {}) {
152581
- const spawnCommand = options2.spawnSyncFn ?? import_node_child_process7.spawnSync;
152732
+ const spawnCommand = options2.spawnSyncFn ?? import_node_child_process8.spawnSync;
152582
152733
  const result = spawnCommand("bun", ["--version"], {
152583
152734
  encoding: "utf8"
152584
152735
  });
@@ -152592,7 +152743,7 @@ function ensureBunAvailable(options2 = {}) {
152592
152743
  }
152593
152744
  }
152594
152745
  function launchOpenTuiProcess(options2) {
152595
- const spawnCommand = options2.spawnSyncFn ?? import_node_child_process7.spawnSync;
152746
+ const spawnCommand = options2.spawnSyncFn ?? import_node_child_process8.spawnSync;
152596
152747
  const result = spawnCommand("bun", [options2.entryPath], {
152597
152748
  stdio: ["inherit", "inherit", "pipe"],
152598
152749
  encoding: "utf8",
@@ -153958,7 +154109,7 @@ var EnvironmentConfigService = class {
153958
154109
  };
153959
154110
 
153960
154111
  // src/services/piAgentLauncher.ts
153961
- var import_node_child_process8 = require("node:child_process");
154112
+ var import_node_child_process9 = require("node:child_process");
153962
154113
  var import_node_fs17 = require("node:fs");
153963
154114
  var import_promises24 = require("node:fs/promises");
153964
154115
  var import_node_path30 = require("node:path");
@@ -154825,7 +154976,7 @@ function validatePiAgentLaunchRequest(params) {
154825
154976
  function createPiAgentLauncher(options2) {
154826
154977
  const cwd = options2.cwd ?? process.cwd();
154827
154978
  const stdinIsTTY = options2.stdinIsTTY ?? process.stdin.isTTY ?? false;
154828
- const spawnCommand = options2.spawnSyncFn ?? import_node_child_process8.spawnSync;
154979
+ const spawnCommand = options2.spawnSyncFn ?? import_node_child_process9.spawnSync;
154829
154980
  const processExecPath = options2.processExecPath ?? process.execPath;
154830
154981
  const resolveResourceRoot = options2.resolvePackagedPiResourceRootFn ?? resolvePackagedPiResourceRoot;
154831
154982
  const resolveLoaderPath = options2.resolveDocyrusPiLoaderEntryPathFn ?? resolveDocyrusPiLoaderEntryPath;
@@ -154958,7 +155109,7 @@ function createPiAgentLauncher(options2) {
154958
155109
  }
154959
155110
 
154960
155111
  // src/services/piAgentServerLauncher.ts
154961
- var import_node_child_process9 = require("node:child_process");
155112
+ var import_node_child_process10 = require("node:child_process");
154962
155113
  var import_node_fs18 = require("node:fs");
154963
155114
  var import_node_path31 = require("node:path");
154964
155115
  function serializePiAgentServerRequest(request) {
@@ -155049,20 +155200,20 @@ function createPiAgentServerLauncher(options2) {
155049
155200
  agentRootPath,
155050
155201
  cwd,
155051
155202
  scope: options2.settingsPaths.scope,
155052
- spawnCommand: import_node_child_process9.spawnSync
155203
+ spawnCommand: import_node_child_process10.spawnSync
155053
155204
  });
155054
155205
  installPackagedDocyrusPlatformSkill({
155055
155206
  resourceRoot,
155056
155207
  cwd,
155057
155208
  scope: options2.settingsPaths.scope,
155058
- spawnCommand: import_node_child_process9.spawnSync
155209
+ spawnCommand: import_node_child_process10.spawnSync
155059
155210
  });
155060
155211
  spinner.update("Installing tools...");
155061
155212
  const officeCli = await ensureManagedOfficeCliInstalled({
155062
155213
  agentRootPath,
155063
155214
  resourceRoot,
155064
155215
  cwd,
155065
- spawnCommand: import_node_child_process9.spawnSync
155216
+ spawnCommand: import_node_child_process10.spawnSync
155066
155217
  });
155067
155218
  if (request.sandbox) {
155068
155219
  const browserConfigDir = settingsRootPath;
@@ -155086,7 +155237,7 @@ function createPiAgentServerLauncher(options2) {
155086
155237
  const piPackageRoot = resolveInstalledPiPackageRootPath({ cwd });
155087
155238
  const cliEntryPath = resolveDocyrusCliEntryPath({ cwd });
155088
155239
  const runtimePath = officeCli.available ? prependPathEntry(officeCli.binDir, process.env.PATH) : process.env.PATH;
155089
- const child = (0, import_node_child_process9.spawn)(process.execPath, [loaderEntryPath], {
155240
+ const child = (0, import_node_child_process10.spawn)(process.execPath, [loaderEntryPath], {
155090
155241
  stdio: "inherit",
155091
155242
  cwd,
155092
155243
  env: {