@parall/cli 1.69.0 → 1.71.0

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 (68) hide show
  1. package/dist/commands/apps-action-local.d.ts +44 -0
  2. package/dist/commands/apps-action-local.d.ts.map +1 -0
  3. package/dist/commands/apps-action-local.js +153 -0
  4. package/dist/commands/apps-action-stack.d.ts +14 -0
  5. package/dist/commands/apps-action-stack.d.ts.map +1 -0
  6. package/dist/commands/apps-action-stack.js +63 -0
  7. package/dist/commands/apps-actions-sdk.generated.d.ts +2 -0
  8. package/dist/commands/apps-actions-sdk.generated.d.ts.map +1 -0
  9. package/dist/commands/apps-actions-sdk.generated.js +3 -0
  10. package/dist/commands/apps-actions.d.ts +20 -0
  11. package/dist/commands/apps-actions.d.ts.map +1 -0
  12. package/dist/commands/apps-actions.js +266 -0
  13. package/dist/commands/apps-check.d.ts +34 -0
  14. package/dist/commands/apps-check.d.ts.map +1 -0
  15. package/dist/commands/apps-check.js +155 -0
  16. package/dist/commands/apps-dev-page.d.ts +26 -0
  17. package/dist/commands/apps-dev-page.d.ts.map +1 -0
  18. package/dist/commands/apps-dev-page.js +259 -0
  19. package/dist/commands/apps-dev-server.d.ts +42 -0
  20. package/dist/commands/apps-dev-server.d.ts.map +1 -0
  21. package/dist/commands/apps-dev-server.js +328 -0
  22. package/dist/commands/apps-dev.d.ts +8 -0
  23. package/dist/commands/apps-dev.d.ts.map +1 -0
  24. package/dist/commands/apps-dev.js +126 -0
  25. package/dist/commands/apps-local-runner.generated.d.ts +3 -0
  26. package/dist/commands/apps-local-runner.generated.d.ts.map +1 -0
  27. package/dist/commands/apps-local-runner.generated.js +4 -0
  28. package/dist/commands/apps-page-sdk.generated.d.ts +2 -0
  29. package/dist/commands/apps-page-sdk.generated.d.ts.map +1 -0
  30. package/dist/commands/apps-page-sdk.generated.js +3 -0
  31. package/dist/commands/apps-publish.d.ts.map +1 -1
  32. package/dist/commands/apps-publish.js +6 -0
  33. package/dist/commands/apps-scaffold-actions.d.ts +11 -0
  34. package/dist/commands/apps-scaffold-actions.d.ts.map +1 -0
  35. package/dist/commands/apps-scaffold-actions.js +163 -0
  36. package/dist/commands/apps-scaffold.d.ts +4 -6
  37. package/dist/commands/apps-scaffold.d.ts.map +1 -1
  38. package/dist/commands/apps-scaffold.js +22 -222
  39. package/dist/commands/apps.d.ts +3 -2
  40. package/dist/commands/apps.d.ts.map +1 -1
  41. package/dist/commands/apps.js +9 -2
  42. package/dist/commands/db-plane.d.ts.map +1 -1
  43. package/dist/commands/db-plane.js +2 -0
  44. package/dist/commands/dbs.d.ts.map +1 -1
  45. package/dist/commands/dbs.js +1 -8
  46. package/dist/commands/messages.d.ts.map +1 -1
  47. package/dist/commands/messages.js +6 -11
  48. package/dist/commands/msteams.d.ts +10 -0
  49. package/dist/commands/msteams.d.ts.map +1 -0
  50. package/dist/commands/msteams.js +41 -0
  51. package/dist/commands/wiki.d.ts.map +1 -1
  52. package/dist/commands/wiki.js +20 -8
  53. package/dist/index.js +7 -5
  54. package/dist/lib/client.d.ts +2 -1
  55. package/dist/lib/client.d.ts.map +1 -1
  56. package/dist/lib/mini-app-discovery.d.ts +6 -0
  57. package/dist/lib/mini-app-discovery.d.ts.map +1 -0
  58. package/dist/lib/mini-app-discovery.js +32 -0
  59. package/dist/lib/output.d.ts +3 -1
  60. package/dist/lib/output.d.ts.map +1 -1
  61. package/dist/lib/output.js +5 -1
  62. package/dist/lib/wiki-index.d.ts +2 -0
  63. package/dist/lib/wiki-index.d.ts.map +1 -1
  64. package/dist/lib/wiki-index.js +28 -73
  65. package/dist/lib/wiki-search-text.d.ts +37 -0
  66. package/dist/lib/wiki-search-text.d.ts.map +1 -0
  67. package/dist/lib/wiki-search-text.js +170 -0
  68. package/package.json +9 -5
@@ -179,17 +179,12 @@ export function registerMessageCommands(program) {
179
179
  };
180
180
  if (attachmentIds)
181
181
  req.attachment_ids = attachmentIds;
182
- let threadRootId = opts.threadRootId !== undefined ? stripPrllScheme(opts.threadRootId) : undefined;
183
- // By-source turns (parel — PRLL_DISPATCH_SOURCE_* set): a bare send
184
- // back into the trigger chat defaults to the trigger's thread, so a
185
- // thread message is answered in its thread without the model having
186
- // to know the thread id. An explicit --thread-root-id always wins.
187
- if (threadRootId === undefined &&
188
- ctx.dispatchSourceId &&
189
- ctx.threadRootId &&
190
- chatId === ctx.chatId) {
191
- threadRootId = ctx.threadRootId;
192
- }
182
+ // Placement is the command alone: no --thread-root-id means top level,
183
+ // on every runtime. The dispatch context never picks the thread — a
184
+ // parel turn can fold a chat's top-level and thread messages while
185
+ // its env stays the turn-opening one, so a context default would
186
+ // misroute the folded ones (and leave no way to post top level).
187
+ const threadRootId = opts.threadRootId !== undefined ? stripPrllScheme(opts.threadRootId) : undefined;
193
188
  if (threadRootId !== undefined)
194
189
  req.thread_root_id = threadRootId;
195
190
  if (opts.reply === false)
@@ -0,0 +1,10 @@
1
+ import type { Command } from 'commander';
2
+ /**
3
+ * `parall msteams …` — the per-vendor platform verb for Microsoft Teams, a
4
+ * channel whose vendor ships no agent-grade CLI (tier B in the multi-channel
5
+ * architecture). The agent sends as its bound bot; the bot's Microsoft
6
+ * credentials never reach the runtime — api-server performs the call.
7
+ * Design: docs/engineering-design/teams-channel-design.md §4.
8
+ */
9
+ export declare function registerMSTeamsCommands(program: Command): void;
10
+ //# sourceMappingURL=msteams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"msteams.d.ts","sourceRoot":"","sources":["../../src/commands/msteams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,QA2CvD"}
@@ -0,0 +1,41 @@
1
+ import { resolveCredentials } from '../lib/client.js';
2
+ import { printError, printJson } from '../lib/output.js';
3
+ import { resolveMessageText, TEXT_FILE_OPTION_DESC, TEXT_OPTION_DESC } from '../lib/text-input.js';
4
+ /**
5
+ * `parall msteams …` — the per-vendor platform verb for Microsoft Teams, a
6
+ * channel whose vendor ships no agent-grade CLI (tier B in the multi-channel
7
+ * architecture). The agent sends as its bound bot; the bot's Microsoft
8
+ * credentials never reach the runtime — api-server performs the call.
9
+ * Design: docs/engineering-design/teams-channel-design.md §4.
10
+ */
11
+ export function registerMSTeamsCommands(program) {
12
+ const msteams = program
13
+ .command('msteams')
14
+ .description('Microsoft Teams channel platform verbs (agent-only; sends as the bound bot)');
15
+ msteams
16
+ .command('send')
17
+ .description('Send a Teams message, or reply inside a channel thread')
18
+ .requiredOption('--conversation <conversationId>', 'Teams conversation id from the inbound event (a chat, or a channel)')
19
+ .option('--text <text>', TEXT_OPTION_DESC)
20
+ .option('--text-file <path>', TEXT_FILE_OPTION_DESC)
21
+ .option('--reply-to <messageId>', "Message id from the inbound event: a channel reply lands in that message's thread (omit to start a new post); chats have no threads")
22
+ .action(async (opts) => {
23
+ try {
24
+ const text = resolveMessageText(opts);
25
+ if (text === undefined || text === '') {
26
+ throw new Error('Provide --text or --text-file');
27
+ }
28
+ const { client, orgId } = resolveCredentials();
29
+ const sent = await client.sendChannelMessage(orgId, {
30
+ channel_type: 'msteams',
31
+ conversation_id: opts.conversation,
32
+ text,
33
+ ...(opts.replyTo ? { reply_to: opts.replyTo } : {}),
34
+ });
35
+ printJson(sent);
36
+ }
37
+ catch (err) {
38
+ printError(err);
39
+ }
40
+ });
41
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"wiki.d.ts","sourceRoot":"","sources":["../../src/commands/wiki.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsBpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,QAssBpD"}
1
+ {"version":3,"file":"wiki.d.ts","sourceRoot":"","sources":["../../src/commands/wiki.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsBpC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,QA+sBpD"}
@@ -448,15 +448,27 @@ export function registerWikiCommands(program) {
448
448
  const { resolveWikiRefOrDefault, getWikiOutline } = await import('../lib/wiki.js');
449
449
  const wiki = await resolveWikiRefOrDefault(ctx, wikiRef);
450
450
  const outline = await getWikiOutline(ctx, wiki.slug, { pathPrefix: filePath });
451
- // Find section whose heading_path ends with the fragment parts
452
- const match = outline.nodes.find((node) => {
453
- if (node.path !== filePath ||
454
- !node.heading_path ||
455
- node.heading_path.length < fragParts.length)
451
+ // Find the section whose heading_path ends with the fragment parts.
452
+ // Unified search returns heading paths as reader text (character
453
+ // references decoded) while the outline keeps raw Markdown headings,
454
+ // so a raw match wins and a decoded match is the fallback; raw first
455
+ // keeps existing anchors resolving as before. When one heading's
456
+ // reader text equals another heading's raw text, the anchor resolves
457
+ // to the raw one: `x &#x26;amp; y` reads `x &amp; y`, so next to a
458
+ // heading written `x &amp; y` it cannot be located (its raw text has
459
+ // a `#`).
460
+ const endsWithFragment = (headings) => {
461
+ if (headings.length < fragParts.length)
456
462
  return false;
457
- const offset = node.heading_path.length - fragParts.length;
458
- return fragParts.every((part, i) => node.heading_path[offset + i].toLowerCase() === part);
459
- });
463
+ const offset = headings.length - fragParts.length;
464
+ return fragParts.every((part, i) => headings[offset + i].toLowerCase() === part);
465
+ };
466
+ const fileNodes = outline.nodes.filter((node) => node.path === filePath);
467
+ let match = fileNodes.find((node) => endsWithFragment(node.heading_path ?? []));
468
+ if (!match) {
469
+ const { decodeHeadingCharacterReferences } = await import('../lib/wiki-search-text.js');
470
+ match = fileNodes.find((node) => endsWithFragment((node.heading_path ?? []).map(decodeHeadingCharacterReferences)));
471
+ }
460
472
  if (!match) {
461
473
  process.stderr.write(`Section not found: ${anchor}\n`);
462
474
  process.stderr.write(`Available sections in ${filePath}:\n`);
package/dist/index.js CHANGED
@@ -3,8 +3,6 @@ import { Command } from 'commander';
3
3
  import { createRequire } from 'module';
4
4
  import { registerAgentCommands } from './commands/agents.js';
5
5
  import { registerApprovalCommands } from './commands/approvals.js';
6
- import { registerAppCommands } from './commands/apps.js';
7
- import { registerDbCommands } from './commands/dbs.js';
8
6
  import { registerBrowserCommands } from './commands/browser.js';
9
7
  import { registerChatCommands } from './commands/chats.js';
10
8
  import { registerClipCommands } from './commands/clip.js';
@@ -15,6 +13,7 @@ import { registerLabelCommands } from './commands/labels.js';
15
13
  import { registerMachineCommands } from './commands/machines.js';
16
14
  import { registerMcpCommands } from './commands/mcp.js';
17
15
  import { registerMessageCommands } from './commands/messages.js';
16
+ import { registerMSTeamsCommands } from './commands/msteams.js';
18
17
  import { registerNoReplyCommands } from './commands/no-reply.js';
19
18
  import { registerProfileCommands } from './commands/profile.js';
20
19
  import { registerProjectCommands } from './commands/projects.js';
@@ -29,6 +28,8 @@ import { registerUserCommands } from './commands/users.js';
29
28
  import { registerWatchCommands } from './commands/watch.js';
30
29
  import { registerWechatCommands } from './commands/wechat.js';
31
30
  import { registerWikiCommands } from './commands/wiki.js';
31
+ import { registerMiniAppCommands } from './lib/mini-app-discovery.js';
32
+ import { printError } from './lib/output.js';
32
33
  import { createUpdateNotifier } from './lib/update-check.js';
33
34
  const version = typeof __PARALL_CLI_VERSION__ === 'string'
34
35
  ? __PARALL_CLI_VERSION__
@@ -47,8 +48,6 @@ registerWatchCommands(program);
47
48
  registerTaskCommands(program);
48
49
  registerCommentCommands(program);
49
50
  registerLabelCommands(program);
50
- registerAppCommands(program);
51
- registerDbCommands(program);
52
51
  registerProjectCommands(program);
53
52
  registerProfileCommands(program);
54
53
  registerTeamCommands(program);
@@ -65,6 +64,7 @@ registerMachineCommands(program);
65
64
  registerClipCommands(program);
66
65
  registerBrowserCommands(program);
67
66
  registerSlackCommands(program);
67
+ registerMSTeamsCommands(program);
68
68
  registerWechatCommands(program);
69
69
  const updateNotifier = createUpdateNotifier(version);
70
70
  program.hook('postAction', () => {
@@ -72,4 +72,6 @@ program.hook('postAction', () => {
72
72
  updateNotifier.afterSuccessfulCommand();
73
73
  }
74
74
  });
75
- program.parse();
75
+ registerMiniAppCommands(program, process.argv.slice(2))
76
+ .then(() => program.parse())
77
+ .catch(printError);
@@ -26,7 +26,8 @@ export type RuntimeContext = {
26
26
  */
27
27
  dispatchSourceType?: string;
28
28
  dispatchSourceId?: string;
29
- /** Trigger thread root (parel invocation context) — the by-source send's default thread. */
29
+ /** Trigger thread root (parel invocation context) — only decides whether a send binds
30
+ * to the trigger (same chat and thread); it never chooses where a send goes. */
30
31
  threadRootId?: string;
31
32
  };
32
33
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,6DAA6D;AAC7D,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oGAAoG;IACpG,OAAO,EAAE,OAAO,CAAC;IACjB,8EAA8E;IAC9E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sFAAsF;IACtF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,4FAA4F;IAC5F,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,IAAI,cAAc,CA8DtD;AAED;;;;;;;GAOG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,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,GAAG,IAAI,CA0DvF;AAED,mFAAmF;AACnF,MAAM,MAAM,mBAAmB,GAAG;IAChC,cAAc,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,cAAc,EAAE,OAAO,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;GAIG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;CAAG;AAE9C;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,MAAM,GACpB,mBAAmB,GAAG,IAAI,CAgF5B;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAYzE;AAED,wBAAgB,kBAAkB,IAAI,mBAAmB,CA8BxD"}
@@ -0,0 +1,6 @@
1
+ import type { Command } from 'commander';
2
+ /** Mini App commands are discoverable only in an enabled organization.
3
+ * The API still authorizes every operation; this gate controls CLI discovery,
4
+ * including local authoring commands and explicit subcommand help. */
5
+ export declare function registerMiniAppCommands(program: Command, args: string[]): Promise<void>;
6
+ //# sourceMappingURL=mini-app-discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mini-app-discovery.d.ts","sourceRoot":"","sources":["../../src/lib/mini-app-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC;;sEAEsE;AACtE,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAwB7F"}
@@ -0,0 +1,32 @@
1
+ import { registerAppCommands } from '../commands/apps.js';
2
+ import { registerDbCommands } from '../commands/dbs.js';
3
+ import { resolveCredentials } from './client.js';
4
+ /** Mini App commands are discoverable only in an enabled organization.
5
+ * The API still authorizes every operation; this gate controls CLI discovery,
6
+ * including local authoring commands and explicit subcommand help. */
7
+ export async function registerMiniAppCommands(program, args) {
8
+ const command = args[0] === '--' ? args[1] : args[0];
9
+ const helpTarget = args[1];
10
+ const miniAppCommand = (name) => name === 'app' || name === 'db';
11
+ const rootHelp = !command || command === '-h' || command === '--help';
12
+ const helpCommand = command === 'help' && (!helpTarget || miniAppCommand(helpTarget));
13
+ // Ordinary commands, their help and --version remain usable without a
14
+ // feature-flags request. No cached decision can leak across organizations.
15
+ if (!rootHelp && !helpCommand && !miniAppCommand(command))
16
+ return;
17
+ if (!process.env.PRLL_API_URL || !process.env.PRLL_API_KEY || !process.env.PRLL_ORG_ID)
18
+ return;
19
+ try {
20
+ const { client, orgId } = resolveCredentials();
21
+ const { flags } = await client.getFeatureFlags(orgId);
22
+ if (flags['cap:mini-apps'] !== true || flags['mini-apps'] !== true)
23
+ return;
24
+ }
25
+ catch {
26
+ // Missing, invalid or unavailable capability information must not
27
+ // advertise commands. The rest of the CLI help remains available.
28
+ return;
29
+ }
30
+ registerAppCommands(program);
31
+ registerDbCommands(program);
32
+ }
@@ -32,5 +32,7 @@ export declare function parsePositiveInt(raw: string | undefined): number | unde
32
32
  * See docs/engineering-design/project-roster-denial-design.md §3.2 / §5
33
33
  */
34
34
  export declare function projectRosterNextStep(details: unknown): string | undefined;
35
- export declare function printError(err: unknown, attemptedPayload?: Record<string, unknown>): never;
35
+ /** Prints the error and exits 1. `nextStep` is plain-text guidance printed
36
+ * after the error line of an API error. */
37
+ export declare function printError(err: unknown, attemptedPayload?: Record<string, unknown>, nextStep?: string): never;
36
38
  //# sourceMappingURL=output.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/lib/output.ts"],"names":[],"mappings":"AAEA,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAE7C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAY,GAAG,IAAI,CAEvE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAW5E;AAmBD;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAe1E;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,EAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,KAAK,CAqD1F"}
1
+ {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/lib/output.ts"],"names":[],"mappings":"AAEA,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAE7C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAY,GAAG,IAAI,CAEvE;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAW5E;AAmBD;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAe1E;AAED;2CAC2C;AAC3C,wBAAgB,UAAU,CACxB,GAAG,EAAE,OAAO,EACZ,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,QAAQ,CAAC,EAAE,MAAM,GAChB,KAAK,CAsDP"}
@@ -83,7 +83,9 @@ export function projectRosterNextStep(details) {
83
83
  return undefined;
84
84
  }
85
85
  }
86
- export function printError(err, attemptedPayload) {
86
+ /** Prints the error and exits 1. `nextStep` is plain-text guidance printed
87
+ * after the error line of an API error. */
88
+ export function printError(err, attemptedPayload, nextStep) {
87
89
  if (err instanceof ApiError) {
88
90
  // Faithful, parseable line: the server's real message + machine anchors.
89
91
  console.error(JSON.stringify({
@@ -126,6 +128,8 @@ export function printError(err, attemptedPayload) {
126
128
  console.error(`${lead} Request approval:\n parall approvals request --action ${err.action} --resource ${err.resourceUri ?? '<resource>'}${payloadArg} --chat ${chat} --title "..." --reason "..."`);
127
129
  }
128
130
  }
131
+ if (nextStep)
132
+ console.error(nextStep);
129
133
  }
130
134
  else if (err instanceof Error) {
131
135
  console.error(JSON.stringify({ error: err.message }));
@@ -4,6 +4,8 @@ type CachedNodeSection = WikiNodeSection & {
4
4
  };
5
5
  type IndexedNode = {
6
6
  section: CachedNodeSection;
7
+ title: string;
8
+ headingPath: string[];
7
9
  content: string;
8
10
  lowerPath: string;
9
11
  lowerTitle: string;
@@ -1 +1 @@
1
- {"version":3,"file":"wiki-index.d.ts","sourceRoot":"","sources":["../../src/lib/wiki-index.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,KAAK,YAAY,EAEjB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB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AAC,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,aAAa,GAAG,KAAK,CAAA;CAAE,GACnF,gBAAgB,EAAE,CA2CpB;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,iBAAiB,CAAA;CAAE,GAC/E;IAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAAC,QAAQ,EAAE,sBAAsB,EAAE,CAAA;CAAE,CA8DxE;AAyRD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAmB5D;AASD,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,KAAK,GAAG,SAAS,GAAG,MAAM,CAAC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAiBA"}
@@ -1,9 +1,10 @@
1
- // Local wiki content index: node-section artifacts, search / query scoring,
2
- // markdown heading parsing and the CJK-aware tokenizer.
1
+ // Local wiki content index: node-section artifacts, search / query scoring
2
+ // and markdown heading parsing. Search text is tokenized by ./wiki-search-text.ts.
3
3
  // Entry point for consumers is ./wiki.ts, which re-exports the public surface.
4
4
  import { promises as fs } from 'node:fs';
5
5
  import path from 'node:path';
6
6
  import { hasFrontMatter, parseFrontMatter } from './wiki-frontmatter.js';
7
+ import { decodeCharacterReferences, decodeHeadingCharacterReferences, tokenize, } from './wiki-search-text.js';
7
8
  import { PRLL_WIKI_DIR, compactWhitespace, enforceAllowedPrefix, matchesAllowedPrefix, normalizeRef, normalizeRequiredWikiPath, normalizeWikiPath, resolveLocalWikiMount, resolvePathInsideRoot, truncateSnippet, walkLocalMarkdownFiles, } from './wiki-shared.js';
8
9
  /** Local wiki mount resolved from mount manifest V2 (REST-based). */
9
10
  const MARKDOWN_HEADING_RE = /^\s{0,3}(#{1,6})[ \t]+(.+?)\s*$/;
@@ -281,14 +282,17 @@ function buildNodeSection(wiki, input) {
281
282
  };
282
283
  }
283
284
  function buildIndexedNode(section, includeFrontmatter) {
285
+ const title = section.level > 0 ? decodeHeadingCharacterReferences(section.title) : section.title;
286
+ const headingPath = (section.heading_path ?? []).map(decodeHeadingCharacterReferences);
287
+ const content = decodeCharacterReferences(section.content);
284
288
  const searchText = [
285
289
  section.path,
286
- section.title,
287
- section.heading_path?.join(' ') ?? '',
290
+ title,
291
+ headingPath.join(' '),
288
292
  ...(includeFrontmatter
289
293
  ? [section.type ?? '', section.description ?? '', section.tags?.join(' ') ?? '']
290
294
  : []),
291
- section.content,
295
+ content,
292
296
  ]
293
297
  .join('\n')
294
298
  .trim();
@@ -299,11 +303,13 @@ function buildIndexedNode(section, includeFrontmatter) {
299
303
  }
300
304
  return {
301
305
  section,
302
- content: section.content,
306
+ title,
307
+ headingPath,
308
+ content,
303
309
  lowerPath: section.path.toLowerCase(),
304
- lowerTitle: section.title.toLowerCase(),
305
- lowerBody: section.content.toLowerCase(),
306
- lowerJoined: section.section_path.toLowerCase(),
310
+ lowerTitle: title.toLowerCase(),
311
+ lowerBody: content.toLowerCase(),
312
+ lowerJoined: [section.path, ...headingPath].join(' > ').toLowerCase(),
307
313
  termFreq,
308
314
  docLen: tokens.length,
309
315
  };
@@ -334,7 +340,7 @@ export function scoreNodes(nodes, query, options) {
334
340
  ...stripNodeSectionContent(node.section),
335
341
  score,
336
342
  snippet: buildSnippet(node, lowerQuery, queryTokens),
337
- content: options.includeContent ? node.content : undefined,
343
+ content: options.includeContent ? node.section.content : undefined,
338
344
  source: options.source,
339
345
  });
340
346
  }
@@ -380,7 +386,7 @@ export function planWikiQuery(sections, query, options) {
380
386
  score: plan.score,
381
387
  document_score: documentScore,
382
388
  snippet: buildSnippet(node, lowerQuery, queryTokens),
383
- content: options.includeContent ? node.content : undefined,
389
+ content: options.includeContent ? node.section.content : undefined,
384
390
  source: options.source,
385
391
  reasoning: plan.reasoning,
386
392
  });
@@ -419,7 +425,10 @@ function buildIndexedDocuments(sections) {
419
425
  const documents = [];
420
426
  for (const [filePath, fileSections] of byPath.entries()) {
421
427
  fileSections.sort((a, b) => a.start_line - b.start_line);
422
- const headings = Array.from(new Set(fileSections.flatMap((section) => section.heading_path ?? []).filter(Boolean)));
428
+ const headings = Array.from(new Set(fileSections
429
+ .flatMap((section) => section.heading_path ?? [])
430
+ .filter(Boolean)
431
+ .map(decodeHeadingCharacterReferences)));
423
432
  const title = fileSections.find((section) => section.level === 0)?.title ?? defaultFileTitle(filePath);
424
433
  const searchText = [filePath, title, headings.join(' ')].join('\n').trim();
425
434
  const tokens = tokenize(searchText);
@@ -468,6 +477,8 @@ function scoreDocuments(documents, queryTokens, lowerQuery) {
468
477
  end_line: 1,
469
478
  content: '',
470
479
  },
480
+ title: document.title,
481
+ headingPath: document.headings,
471
482
  content: '',
472
483
  lowerPath: document.lowerPath,
473
484
  lowerTitle: document.lowerTitle,
@@ -502,7 +513,7 @@ function scoreTreeAwareNode(node, queryTokens, lowerQuery, documentScore, scope)
502
513
  score += 2.5;
503
514
  reasoning.push('section title directly matches the query');
504
515
  }
505
- const matchedAncestors = (node.section.heading_path ?? [])
516
+ const matchedAncestors = node.headingPath
506
517
  .slice(0, -1)
507
518
  .filter((heading) => heading.toLowerCase().includes(lowerQuery) ||
508
519
  queryTokens.some((token) => heading.toLowerCase().includes(token)));
@@ -510,7 +521,7 @@ function scoreTreeAwareNode(node, queryTokens, lowerQuery, documentScore, scope)
510
521
  score += matchedAncestors.length * 1.25;
511
522
  reasoning.push('ancestor headings match the query context');
512
523
  }
513
- const headingTokenHits = queryTokens.filter((token) => (node.section.heading_path ?? []).some((heading) => heading.toLowerCase().includes(token))).length;
524
+ const headingTokenHits = queryTokens.filter((token) => node.headingPath.some((heading) => heading.toLowerCase().includes(token))).length;
514
525
  if (headingTokenHits > 0) {
515
526
  score += headingTokenHits * 0.6;
516
527
  reasoning.push('heading path overlaps with query terms');
@@ -563,7 +574,7 @@ function scoreNode(node, queryTokens, lowerQuery, docFreq, totalDocs, avgDocLen)
563
574
  return score;
564
575
  }
565
576
  function buildSnippet(node, lowerQuery, queryTokens) {
566
- const lines = [node.section.title, ...node.content.split('\n')];
577
+ const lines = [node.title, ...node.content.split('\n')];
567
578
  for (const line of lines) {
568
579
  const compact = compactWhitespace(line);
569
580
  if (!compact) {
@@ -584,7 +595,8 @@ function buildSnippet(node, lowerQuery, queryTokens) {
584
595
  return truncateSnippet(compact, 220);
585
596
  }
586
597
  }
587
- return truncateSnippet(compactWhitespace(node.content || node.section.section_path), 220);
598
+ const sectionPath = [node.section.path, ...node.headingPath].join(' > ');
599
+ return truncateSnippet(compactWhitespace(node.content || sectionPath), 220);
588
600
  }
589
601
  // ---------------------------------------------------------------------------
590
602
  // Markdown parsing helpers
@@ -699,60 +711,3 @@ function findFirstNonEmptyLine(lines, startLine, endLine) {
699
711
  }
700
712
  return start;
701
713
  }
702
- // ---------------------------------------------------------------------------
703
- // Tokenizer (CJK-aware, for search/query)
704
- // ---------------------------------------------------------------------------
705
- function tokenize(text) {
706
- const trimmed = text.trim();
707
- if (!trimmed) {
708
- return [];
709
- }
710
- const tokens = [];
711
- let word = '';
712
- let cjkRun = '';
713
- const flushWord = () => {
714
- if (!word) {
715
- return;
716
- }
717
- tokens.push(word.toLowerCase());
718
- word = '';
719
- };
720
- const flushCjk = () => {
721
- if (!cjkRun) {
722
- return;
723
- }
724
- const chars = Array.from(cjkRun.toLowerCase());
725
- tokens.push(...chars);
726
- if (chars.length > 1) {
727
- for (let i = 0; i < chars.length - 1; i += 1) {
728
- tokens.push(chars[i] + chars[i + 1]);
729
- }
730
- }
731
- cjkRun = '';
732
- };
733
- for (const char of Array.from(trimmed)) {
734
- if (isCjkChar(char)) {
735
- flushWord();
736
- cjkRun += char;
737
- continue;
738
- }
739
- if (/[0-9\p{L}]/u.test(char)) {
740
- flushCjk();
741
- word += char.toLowerCase();
742
- continue;
743
- }
744
- flushWord();
745
- flushCjk();
746
- }
747
- flushWord();
748
- flushCjk();
749
- return tokens;
750
- }
751
- function isCjkChar(char) {
752
- const codePoint = char.codePointAt(0) ?? 0;
753
- return ((codePoint >= 0x4e00 && codePoint <= 0x9fff) ||
754
- (codePoint >= 0x3400 && codePoint <= 0x4dbf) ||
755
- (codePoint >= 0x3040 && codePoint <= 0x309f) ||
756
- (codePoint >= 0x30a0 && codePoint <= 0x30ff) ||
757
- (codePoint >= 0xac00 && codePoint <= 0xd7af));
758
- }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Longer text is returned raw. micromark's inline resolution is quadratic on
3
+ * adversarial input (a 30 KB run of `_a*` takes over a second), and local
4
+ * search decodes every section on every query. Real sections are far smaller:
5
+ * when this cap was set, 1 of the 6,181 sections in the repository's docs/
6
+ * exceeded it.
7
+ */
8
+ export declare const MAX_DECODED_LENGTH: number;
9
+ /**
10
+ * Markdown with every CommonMark character reference in reader text (`&amp;`,
11
+ * `&#24352;`, `&#x5F20;`) replaced by the character(s) it denotes. The Web
12
+ * editor writes such references next to emphasis delimiters, e.g.
13
+ * `**负责人:**&#x5F20;三`, and every Wiki reader shows 张三.
14
+ *
15
+ * micromark (the Web reader's parser) recognizes the references, so code,
16
+ * raw HTML, autolinks and backslash-escaped ampersands are never touched; all
17
+ * other Markdown syntax is kept byte-for-byte. Text longer than
18
+ * {@link MAX_DECODED_LENGTH} is returned as is.
19
+ *
20
+ * Section content arrives trimmed by the section parser, so a body that opens
21
+ * with an indented code block parses as a paragraph here and its references
22
+ * decode; headings lose code context too (see
23
+ * {@link decodeHeadingCharacterReferences}).
24
+ */
25
+ export declare function decodeCharacterReferences(markdown: string): string;
26
+ /**
27
+ * Decodes one heading title (inline heading content) as {@link decodeCharacterReferences}.
28
+ * The heading parser trims leading and trailing backticks from titles, which
29
+ * loses code context whenever a heading starts or ends with a code span:
30
+ * "`A&amp;B`", "`A&amp;B` notes" and "notes `A&amp;B`" decode the reference
31
+ * inside the code, while "`a` &amp; `b`" now reads as one code span and keeps
32
+ * the text reference literal. Only a reader title computed at parse time can
33
+ * tell these shapes apart.
34
+ */
35
+ export declare function decodeHeadingCharacterReferences(title: string): string;
36
+ export declare function tokenize(text: string): string[];
37
+ //# sourceMappingURL=wiki-search-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wiki-search-text.d.ts","sourceRoot":"","sources":["../../src/lib/wiki-search-text.ts"],"names":[],"mappings":"AAiCA;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,QAAY,CAAC;AAK5C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAiDlE;AAED;;;;;;;;GAQG;AACH,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAKtE;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAiD/C"}