@agimon-ai/po-help 0.0.0-alpha.3 → 0.0.0-alpha.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 -2
- package/dist/extensions/server.cjs +9 -9
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts +1 -1
- package/dist/extensions/server.mjs +10 -10
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +11 -11
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/llms.txt +2 -2
- package/package.json +10 -10
- package/src/prompts/po-use-help/SKILL.md +2 -2
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Requires Node.js 24 or newer and the Pi version declared in this package's peer
|
|
|
12
12
|
|
|
13
13
|
## Activate and diagnose
|
|
14
14
|
|
|
15
|
-
Use the minor-mode menu, `/minor help`, or `/
|
|
15
|
+
Use the minor-mode menu, `/minor help`, or `/po-help`. Help is additive: unrelated tools, skills, and modes retain their existing activation and permission rules.
|
|
16
16
|
|
|
17
17
|
The mode detail reports applied Help skill and diagnostic-tool counts. Pending discovery is not presented as a successful skill count. A failed contributor can leave Help degraded while healthy contributions remain usable.
|
|
18
18
|
|
|
@@ -41,7 +41,7 @@ Publish `llms.txt` and `src/prompts` in the package files allowlist. Relative li
|
|
|
41
41
|
### Tools
|
|
42
42
|
|
|
43
43
|
```ts
|
|
44
|
-
import {
|
|
44
|
+
import { PO_HELP_WHEN as HELP_WHEN } from '@agimon-ai/po-core/help';
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
Contributor packages import the shared contract from Core, not the optional Help package, so the distribution does not acquire an unconditional minor-mode dependency.
|
|
@@ -8,7 +8,7 @@ let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile
|
|
|
8
8
|
let _agimon_ai_po_minor_mode = require("@agimon-ai/po-minor-mode");
|
|
9
9
|
let typebox = require("typebox");
|
|
10
10
|
//#region src/constants/help.ts
|
|
11
|
-
const HELP_COMMAND_NAME = "
|
|
11
|
+
const HELP_COMMAND_NAME = "po-help";
|
|
12
12
|
const HELP_COMMAND_DESCRIPTION = "Toggle Help guidance and read-only support diagnostics";
|
|
13
13
|
const HELP_MODE_ID = "help";
|
|
14
14
|
const HELP_PACKAGE_SOURCE = "@agimon-ai/po-help";
|
|
@@ -73,7 +73,7 @@ function createHelpStatusTool(inspect, authorize) {
|
|
|
73
73
|
name: HELP_STATUS_TOOL_NAME,
|
|
74
74
|
description: HELP_STATUS_TOOL_DESCRIPTION,
|
|
75
75
|
parameters: helpStatusParameters,
|
|
76
|
-
when: _agimon_ai_po_core_help.
|
|
76
|
+
when: _agimon_ai_po_core_help.PO_HELP_WHEN,
|
|
77
77
|
promptGuidelines: [HELP_GUIDANCE],
|
|
78
78
|
async execute(_input, execution) {
|
|
79
79
|
const signal = authorize(execution.signal);
|
|
@@ -119,13 +119,13 @@ function createHelpServerSession(host) {
|
|
|
119
119
|
};
|
|
120
120
|
const resources = [
|
|
121
121
|
{
|
|
122
|
-
when: _agimon_ai_po_core_help.
|
|
122
|
+
when: _agimon_ai_po_core_help.PO_HELP_WHEN,
|
|
123
123
|
name: "po-help",
|
|
124
124
|
kind: "context",
|
|
125
125
|
read: () => HELP_GUIDANCE
|
|
126
126
|
},
|
|
127
127
|
{
|
|
128
|
-
when: _agimon_ai_po_core_help.
|
|
128
|
+
when: _agimon_ai_po_core_help.PO_HELP_WHEN,
|
|
129
129
|
...HELP_SKILL,
|
|
130
130
|
kind: "skill",
|
|
131
131
|
path: (0, _agimon_ai_po_core_serverFacet.packageResourcePath)(require("url").pathToFileURL(__filename).href, "src/prompts/po-use-help/SKILL.md"),
|
|
@@ -136,7 +136,7 @@ function createHelpServerSession(host) {
|
|
|
136
136
|
}
|
|
137
137
|
},
|
|
138
138
|
{
|
|
139
|
-
when: _agimon_ai_po_core_help.
|
|
139
|
+
when: _agimon_ai_po_core_help.PO_HELP_WHEN,
|
|
140
140
|
...HELP_CHATGPT_SKILL,
|
|
141
141
|
kind: "skill",
|
|
142
142
|
path: (0, _agimon_ai_po_core_serverFacet.packageResourcePath)(require("url").pathToFileURL(__filename).href, "src/prompts/po-use-chatgpt-instructions/SKILL.md"),
|
|
@@ -147,7 +147,7 @@ function createHelpServerSession(host) {
|
|
|
147
147
|
}
|
|
148
148
|
},
|
|
149
149
|
{
|
|
150
|
-
when: _agimon_ai_po_core_help.
|
|
150
|
+
when: _agimon_ai_po_core_help.PO_HELP_WHEN,
|
|
151
151
|
...HELP_NATIVE_SKILL,
|
|
152
152
|
kind: "skill",
|
|
153
153
|
path: (0, _agimon_ai_po_core_serverFacet.packageResourcePath)(require("url").pathToFileURL(__filename).href, "src/prompts/po-develop-native-extension/SKILL.md"),
|
|
@@ -258,8 +258,8 @@ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)((cont
|
|
|
258
258
|
};
|
|
259
259
|
});
|
|
260
260
|
//#endregion
|
|
261
|
-
//#region src/extensions/workspaces/sessions/(backend)/command/
|
|
262
|
-
var
|
|
261
|
+
//#region src/extensions/workspaces/sessions/(backend)/command/po-help.server.ts
|
|
262
|
+
var po_help_server_default$1 = (0, _agimon_ai_po_core_extensionFile.defineRoutedContribution)((context) => context.root.commands?.[0], { cardinality: "optional" });
|
|
263
263
|
//#endregion
|
|
264
264
|
//#region src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server.ts
|
|
265
265
|
var po_develop_native_extension_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoutedContribution)((context) => context.root.resources?.[3], { cardinality: "optional" });
|
|
@@ -296,7 +296,7 @@ const facet = (0, _agimon_ai_po_core_serverFacet.defineServerPlugin)({
|
|
|
296
296
|
return {
|
|
297
297
|
...(0, _agimon_ai_po_core_extensionFile.composeRootHooks)(scopeSession),
|
|
298
298
|
get commands() {
|
|
299
|
-
return defined([via({ name: "
|
|
299
|
+
return defined([via({ name: "po-help" }, at(po_help_server_default$1, contextSession))]);
|
|
300
300
|
},
|
|
301
301
|
get resources() {
|
|
302
302
|
return defined([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.cjs","names":["Type","defineTool","HELP_WHEN","HELP_WHEN","packageResourcePath","readPackageResource","defineMinorMode","serverMinorModes","defineRoot","runtime","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineServerPlugin","composeServerProviderOverrides","rootSession","composeRootHooks","commandDoomHelp","resourcePoDevelopNativeExtension","resourcePoHelp","resourcePoUseChatgptInstructions","resourcePoUseHelp","toolHelpStatus"],"sources":["../../src/constants/help.ts","../../src/schemas/diagnostics.ts","../../src/services/helpStatus/index.ts","../../src/services/helpServerSession/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/runtime.server.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/command/doom-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-chatgpt-instructions.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/help_status.server.ts","../../generated/server.ts"],"sourcesContent":["export const HELP_COMMAND_NAME = 'doom-help';\nexport const HELP_COMMAND_DESCRIPTION = 'Toggle Help guidance and read-only support diagnostics';\nexport const HELP_MODE_ID = 'help';\nexport const HELP_PACKAGE_SOURCE = '@agimon-ai/po-help';\nexport const HELP_SKILL = {\n name: 'po-use-help',\n description:\n 'Set up and debug Po agents using installed package guidance and scoped, read-only diagnostics. Diagnose missing capabilities before proposing authorized repairs.',\n} as const;\nexport const HELP_GUIDANCE =\n 'Help mode is active. Read po-use-help, inspect the available diagnostics, and use the narrowest package guidance for the task. Diagnose before proposing changes. Help does not grant additional permissions.';\nexport const HELP_STATUS_TOOL_NAME = 'help_status';\nexport const HELP_STATUS_TOOL_DESCRIPTION =\n 'Inspect active Help skills, diagnostic tools, contributor ownership, and unavailable contributions in this session. Read-only; does not change selection or permissions.';\nexport const HELP_STATUS_LIMIT = 128;\n\nexport const HELP_CHATGPT_SKILL = {\n name: 'po-use-chatgpt-instructions',\n description:\n \"Print a paste-ready ChatGPT project instruction (at most 8,000 characters) that routes code-mode work through this session's MCP tools and condenses every AGENTS.md rule. Writes no files.\",\n} as const;\n\nexport const HELP_NATIVE_SKILL = {\n name: 'po-develop-native-extension',\n description:\n \"Add or change a Po package's phone UI (.native files, native templates) so it mirrors the cockpit, passes the native build, and is approved and verified before it ships.\",\n} as const;\n","import { Type } from 'typebox';\n\nexport const helpStatusParameters = Type.Object({}, { additionalProperties: false });\n","import type { DoomHeadlessCapabilitySnapshot } from '@agimon-ai/po-core/headless';\nimport { DOOM_HELP_WHEN as HELP_WHEN } from '@agimon-ai/po-core/help';\nimport { defineTool } from '@agimon-ai/po-core/serverFacet';\n\nimport {\n HELP_GUIDANCE,\n HELP_MODE_ID,\n HELP_STATUS_LIMIT,\n HELP_STATUS_TOOL_DESCRIPTION,\n HELP_STATUS_TOOL_NAME,\n} from '../../constants/help';\nimport { helpStatusParameters } from '../../schemas/diagnostics';\nimport type { HelpStatusReport } from './type';\n\nexport function serverHelpStatus(snapshot: DoomHeadlessCapabilitySnapshot, enabled: boolean): HelpStatusReport {\n const entries = snapshot.capabilities.filter((entry) => entry.when?.state?.['minor-mode'] === HELP_MODE_ID);\n const skills = entries.filter((entry) => entry.kind === 'skill');\n const tools = entries.filter((entry) => entry.kind === 'tool');\n const diagnostics = entries\n .filter((entry) => enabled && entry.reason && entry.reason !== 'inactive')\n .map((entry) => ({ source: entry.source, code: `HELP_${entry.reason!.replaceAll('-', '_').toUpperCase()}` }));\n const ready = snapshot.ready;\n return {\n activation: !enabled ? 'inactive' : !ready ? 'activating' : diagnostics.length ? 'degraded' : 'active',\n ready,\n revision: snapshot.revision,\n counts: {\n skills: ready ? skills.filter((entry) => entry.active && entry.discoverable).length : null,\n tools: tools.filter((entry) => entry.active).length,\n },\n skills: skills.slice(0, HELP_STATUS_LIMIT).map(({ name, source, active, discoverable, reason }) => ({\n name,\n source,\n active: active && discoverable,\n ...(reason ? { reason } : {}),\n })),\n tools: tools\n .slice(0, HELP_STATUS_LIMIT)\n .map(({ name, source, active, reason }) => ({ name, source, active, ...(reason ? { reason } : {}) })),\n diagnostics: diagnostics.slice(0, HELP_STATUS_LIMIT),\n truncated:\n skills.length > HELP_STATUS_LIMIT || tools.length > HELP_STATUS_LIMIT || diagnostics.length > HELP_STATUS_LIMIT,\n };\n}\n\nexport function helpStatusDetail(report: HelpStatusReport): string {\n return `${report.counts.skills ?? 'pending'} Help skills, ${report.counts.tools} diagnostic tools${report.diagnostics.length ? ' (diagnostics available)' : ''}`;\n}\n\nexport function createHelpStatusTool(\n inspect: () => HelpStatusReport | Promise<HelpStatusReport>,\n authorize: (signal?: AbortSignal) => AbortSignal,\n) {\n return defineTool({\n name: HELP_STATUS_TOOL_NAME,\n description: HELP_STATUS_TOOL_DESCRIPTION,\n parameters: helpStatusParameters,\n when: HELP_WHEN,\n promptGuidelines: [HELP_GUIDANCE],\n async execute(_input, execution) {\n const signal = authorize(execution.signal);\n const report = await inspect();\n signal.throwIfAborted();\n authorize(execution.signal);\n return { content: [{ type: 'text', text: JSON.stringify(report, null, 2) }], details: report };\n },\n });\n}\n","import type { DoomHeadlessCommand, DoomHeadlessHostService, DoomHeadlessResource } from '@agimon-ai/po-core/headless';\nimport { DOOM_HELP_WHEN as HELP_WHEN } from '@agimon-ai/po-core/help';\nimport { type DoomServerSessionPlugin, packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverFacet';\nimport { defineMinorMode, serverMinorModes, type MinorModeOwner, type MinorModeState } from '@agimon-ai/po-minor-mode';\n\nimport {\n HELP_COMMAND_DESCRIPTION,\n HELP_COMMAND_NAME,\n HELP_GUIDANCE,\n HELP_MODE_ID,\n HELP_PACKAGE_SOURCE,\n HELP_CHATGPT_SKILL,\n HELP_NATIVE_SKILL,\n HELP_SKILL,\n} from '../../constants/help';\nimport { createHelpStatusTool, helpStatusDetail, serverHelpStatus } from '../helpStatus';\nexport function createHelpServerSession(host: DoomHeadlessHostService): DoomServerSessionPlugin {\n let modeOwner: MinorModeOwner | undefined;\n let pending: boolean | undefined;\n let failure: string | undefined;\n let generation = 0;\n let disposed = false;\n const active = () => (host.context.selection.state?.['minor-mode'] ?? []).includes(HELP_MODE_ID);\n const inspect = () => serverHelpStatus(host.inspectCapabilities(), active());\n const modeState = (): MinorModeState => {\n const report = inspect();\n return {\n activation: pending === true ? 'activating' : active() ? 'active' : 'inactive',\n condition:\n pending !== undefined || !report.ready\n ? 'queued'\n : failure\n ? 'failed'\n : report.activation === 'degraded'\n ? 'degraded'\n : 'ready',\n ...(pending !== undefined\n ? { detail: 'applying Help capabilities' }\n : failure\n ? { detail: failure }\n : active()\n ? { detail: helpStatusDetail(report) }\n : {}),\n actions: [\n {\n id: 'activate',\n enabled: !active() && pending === undefined,\n ...(!active() && pending === undefined ? {} : { disabledReason: 'Help is active or changing.' }),\n },\n {\n id: 'deactivate',\n enabled: active() || pending === true,\n ...(active() || pending === true ? {} : { disabledReason: 'Help mode is not active.' }),\n },\n ],\n };\n };\n const resources: DoomHeadlessResource[] = [\n { when: HELP_WHEN, name: 'po-help', kind: 'context', read: () => HELP_GUIDANCE },\n {\n when: HELP_WHEN,\n ...HELP_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/po-use-help/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/po-use-help/SKILL.md');\n if (!text.trim()) throw new Error('The installed Help skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_CHATGPT_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/po-use-chatgpt-instructions/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/po-use-chatgpt-instructions/SKILL.md');\n if (!text.trim()) throw new Error('The installed ChatGPT instruction skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_NATIVE_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/po-develop-native-extension/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/po-develop-native-extension/SKILL.md');\n if (!text.trim()) throw new Error('The installed native extension skill is missing or unreadable.');\n return text;\n },\n },\n ];\n const selectMode = async (enabled: boolean, signal?: AbortSignal): Promise<void> => {\n if (disposed) throw new Error('Help runtime is disposed.');\n signal?.throwIfAborted();\n const operation = ++generation;\n pending = enabled;\n failure = undefined;\n modeOwner?.publish();\n try {\n if (enabled) await resources[1]!.read(host.context);\n signal?.throwIfAborted();\n if (operation !== generation || disposed) throw new Error('Help activation was cancelled.');\n const modes = (host.context.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== HELP_MODE_ID);\n await host.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: enabled ? [...modes, HELP_MODE_ID] : modes,\n });\n } catch (error) {\n if (operation === generation) failure = (error instanceof Error ? error.message : String(error)).slice(0, 160);\n throw error;\n } finally {\n if (operation === generation) {\n pending = undefined;\n modeOwner?.publish();\n }\n }\n };\n const command: DoomHeadlessCommand = {\n name: HELP_COMMAND_NAME,\n description: HELP_COMMAND_DESCRIPTION,\n async execute(_args, execution) {\n await selectMode(!(pending ?? active()));\n await execution.client.notify({\n title: 'Po Help',\n body: active() ? 'Help mode activated.' : 'Help mode deactivated.',\n level: 'info',\n });\n },\n };\n modeOwner = defineMinorMode({\n descriptor: {\n source: HELP_PACKAGE_SOURCE,\n id: HELP_MODE_ID,\n label: 'Help',\n description: 'Package guidance and read-only diagnostics for agent setup and debugging.',\n order: 50,\n actions: [\n {\n id: 'activate',\n label: 'Activate',\n description: 'Expose Help guidance and diagnostic tools.',\n contexts: ['headless'],\n parameters: [],\n },\n {\n id: 'deactivate',\n label: 'Deactivate',\n description: 'Withdraw Help-only guidance and diagnostic tools.',\n contexts: ['headless'],\n parameters: [],\n },\n ],\n },\n state: modeState,\n async handleAction(_runtime, actionId, _argumentsValue, { signal }) {\n if (actionId !== 'activate' && actionId !== 'deactivate')\n throw new Error(`Unknown Help mode action: ${actionId}`);\n await selectMode(actionId === 'activate', signal);\n return { message: active() ? 'Help mode activated.' : 'Help mode deactivated.' };\n },\n }).createOwner(undefined);\n return {\n services: [serverMinorModes([modeOwner])],\n resources,\n commands: [command],\n tools: [\n createHelpStatusTool(inspect, (signal) => {\n signal?.throwIfAborted();\n host.assertActive(HELP_PACKAGE_SOURCE);\n if (disposed || !active()) throw new Error('Help mode is not active.');\n return signal ?? new AbortController().signal;\n }),\n ],\n onDispose() {\n disposed = true;\n generation += 1;\n },\n };\n}\n","import type { DoomServerPluginDefinition, DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nimport { createHelpServerSession } from '../../../../../services/helpServerSession';\n\nexport default (({ agent }): Partial<DoomServerSessionPlugin> =>\n agent ? createHelpServerSession(agent) : {}) satisfies NonNullable<DoomServerPluginDefinition['session']>;\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/po-core/serverFacet';\n\nimport runtime from './_lib/runtime.server';\n\nexport default defineRoot((context: DoomServerPluginContext) => {\n const value = runtime(context);\n return {\n value,\n services: value.services,\n activities: value.activities,\n onStart: value.onStart,\n onStop: value.onStop,\n onDispose: value.onDispose,\n };\n});\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { DoomServerPluginContext, DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<DoomServerPluginContext, Partial<DoomServerSessionPlugin>>) => context.root.commands?.[0],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { DoomServerPluginContext, DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<DoomServerPluginContext, Partial<DoomServerSessionPlugin>>) => context.root.resources?.[3],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { DoomServerPluginContext, DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<DoomServerPluginContext, Partial<DoomServerSessionPlugin>>) => context.root.resources?.[0],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { DoomServerPluginContext, DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<DoomServerPluginContext, Partial<DoomServerSessionPlugin>>) => context.root.resources?.[2],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { DoomServerPluginContext, DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<DoomServerPluginContext, Partial<DoomServerSessionPlugin>>) => context.root.resources?.[1],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { DoomServerPluginContext, DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<DoomServerPluginContext, Partial<DoomServerSessionPlugin>>) => context.root.tools?.[0],\n { cardinality: 'optional' },\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverFacet';\nimport { composeRootHooks } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport commandDoomHelp from '../src/extensions/workspaces/sessions/(backend)/command/doom-help.server';\nimport resourcePoDevelopNativeExtension from '../src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server';\nimport resourcePoHelp from '../src/extensions/workspaces/sessions/(backend)/resource/po-help.server';\nimport resourcePoUseChatgptInstructions from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-chatgpt-instructions.server';\nimport resourcePoUseHelp from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-help.server';\nimport toolHelpStatus from '../src/extensions/workspaces/sessions/(backend)/tool/help_status.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n/* v8 ignore next -- generated normalization branch */\nconst defined = <T>(values: readonly (T | undefined)[]): T[] =>\n values.filter((value): value is T => value !== undefined);\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const facet = defineServerPlugin({\n name: '@agimon-ai/po-help',\n providerOverrides: composeServerProviderOverrides(rootSession),\n session: async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get commands(): DoomServerSessionPlugin['commands'] { return defined([via({ name: 'doom-help' }, at(commandDoomHelp, contextSession))]); },\n get resources(): DoomServerSessionPlugin['resources'] { return defined([at(resourcePoDevelopNativeExtension, contextSession), at(resourcePoHelp, contextSession), at(resourcePoUseChatgptInstructions, contextSession), at(resourcePoUseHelp, contextSession)]); },\n get tools(): DoomServerSessionPlugin['tools'] { return defined([via({ name: 'help_status' }, at(toolHelpStatus, contextSession))]); },\n services: [...(scopeSession.services ?? [])],\n get activities(): DoomServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n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;AAEzE,MAAa,SAAA,GAAQC,+BAAAA,mBAAAA,CAAmB;CACtC,MAAM;CACN,oBAAA,GAAmBC,+BAAAA,+BAAAA,CAA+BC,mBAAW;CAC7D,SAAS,OAAO,YAAY;EAC1B,MAAM,eAAe,MAAMA,oBAAY,OAAO;EAC9C,MAAM,iBAAiB;GAAE,GAAG;GAAS,MAAM,aAAa;EAAM;EAC9D,OAAO;GACL,IAAA,GAAGC,iCAAAA,iBAAAA,CAAiB,YAAY;GAChC,IAAI,WAAgD;IAAE,OAAO,QAAQ,CAAC,IAAI,EAAE,MAAM,YAAY,GAAG,GAAGC,0BAAiB,cAAc,CAAC,CAAC,CAAC;GAAG;GACzI,IAAI,YAAkD;IAAE,OAAO,QAAQ;KAAC,GAAGC,4CAAkC,cAAc;KAAG,GAAGC,wBAAgB,cAAc;KAAG,GAAGC,4CAAkC,cAAc;KAAG,GAAGC,4BAAmB,cAAc;IAAC,CAAC;GAAG;GACjQ,IAAI,QAA0C;IAAE,OAAO,QAAQ,CAAC,IAAI,EAAE,MAAM,cAAc,GAAG,GAAGC,4BAAgB,cAAc,CAAC,CAAC,CAAC;GAAG;GACpI,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAoD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACzG;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"server.cjs","names":["Type","defineTool","HELP_WHEN","HELP_WHEN","packageResourcePath","readPackageResource","defineMinorMode","serverMinorModes","defineRoot","runtime","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineRoutedContribution","defineServerPlugin","composeServerProviderOverrides","rootSession","composeRootHooks","commandPoHelp","resourcePoDevelopNativeExtension","resourcePoHelp","resourcePoUseChatgptInstructions","resourcePoUseHelp","toolHelpStatus"],"sources":["../../src/constants/help.ts","../../src/schemas/diagnostics.ts","../../src/services/helpStatus/index.ts","../../src/services/helpServerSession/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/runtime.server.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/command/po-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-chatgpt-instructions.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/help_status.server.ts","../../generated/server.ts"],"sourcesContent":["export const HELP_COMMAND_NAME = 'po-help';\nexport const HELP_COMMAND_DESCRIPTION = 'Toggle Help guidance and read-only support diagnostics';\nexport const HELP_MODE_ID = 'help';\nexport const HELP_PACKAGE_SOURCE = '@agimon-ai/po-help';\nexport const HELP_SKILL = {\n name: 'po-use-help',\n description:\n 'Set up and debug Po agents using installed package guidance and scoped, read-only diagnostics. Diagnose missing capabilities before proposing authorized repairs.',\n} as const;\nexport const HELP_GUIDANCE =\n 'Help mode is active. Read po-use-help, inspect the available diagnostics, and use the narrowest package guidance for the task. Diagnose before proposing changes. Help does not grant additional permissions.';\nexport const HELP_STATUS_TOOL_NAME = 'help_status';\nexport const HELP_STATUS_TOOL_DESCRIPTION =\n 'Inspect active Help skills, diagnostic tools, contributor ownership, and unavailable contributions in this session. Read-only; does not change selection or permissions.';\nexport const HELP_STATUS_LIMIT = 128;\n\nexport const HELP_CHATGPT_SKILL = {\n name: 'po-use-chatgpt-instructions',\n description:\n \"Print a paste-ready ChatGPT project instruction (at most 8,000 characters) that routes code-mode work through this session's MCP tools and condenses every AGENTS.md rule. Writes no files.\",\n} as const;\n\nexport const HELP_NATIVE_SKILL = {\n name: 'po-develop-native-extension',\n description:\n \"Add or change a Po package's phone UI (.native files, native templates) so it mirrors the cockpit, passes the native build, and is approved and verified before it ships.\",\n} as const;\n","import { Type } from 'typebox';\n\nexport const helpStatusParameters = Type.Object({}, { additionalProperties: false });\n","import type { PoHeadlessCapabilitySnapshot } from '@agimon-ai/po-core/headless';\nimport { PO_HELP_WHEN as HELP_WHEN } from '@agimon-ai/po-core/help';\nimport { defineTool } from '@agimon-ai/po-core/serverFacet';\n\nimport {\n HELP_GUIDANCE,\n HELP_MODE_ID,\n HELP_STATUS_LIMIT,\n HELP_STATUS_TOOL_DESCRIPTION,\n HELP_STATUS_TOOL_NAME,\n} from '../../constants/help';\nimport { helpStatusParameters } from '../../schemas/diagnostics';\nimport type { HelpStatusReport } from './type';\n\nexport function serverHelpStatus(snapshot: PoHeadlessCapabilitySnapshot, enabled: boolean): HelpStatusReport {\n const entries = snapshot.capabilities.filter((entry) => entry.when?.state?.['minor-mode'] === HELP_MODE_ID);\n const skills = entries.filter((entry) => entry.kind === 'skill');\n const tools = entries.filter((entry) => entry.kind === 'tool');\n const diagnostics = entries\n .filter((entry) => enabled && entry.reason && entry.reason !== 'inactive')\n .map((entry) => ({ source: entry.source, code: `HELP_${entry.reason!.replaceAll('-', '_').toUpperCase()}` }));\n const ready = snapshot.ready;\n return {\n activation: !enabled ? 'inactive' : !ready ? 'activating' : diagnostics.length ? 'degraded' : 'active',\n ready,\n revision: snapshot.revision,\n counts: {\n skills: ready ? skills.filter((entry) => entry.active && entry.discoverable).length : null,\n tools: tools.filter((entry) => entry.active).length,\n },\n skills: skills.slice(0, HELP_STATUS_LIMIT).map(({ name, source, active, discoverable, reason }) => ({\n name,\n source,\n active: active && discoverable,\n ...(reason ? { reason } : {}),\n })),\n tools: tools\n .slice(0, HELP_STATUS_LIMIT)\n .map(({ name, source, active, reason }) => ({ name, source, active, ...(reason ? { reason } : {}) })),\n diagnostics: diagnostics.slice(0, HELP_STATUS_LIMIT),\n truncated:\n skills.length > HELP_STATUS_LIMIT || tools.length > HELP_STATUS_LIMIT || diagnostics.length > HELP_STATUS_LIMIT,\n };\n}\n\nexport function helpStatusDetail(report: HelpStatusReport): string {\n return `${report.counts.skills ?? 'pending'} Help skills, ${report.counts.tools} diagnostic tools${report.diagnostics.length ? ' (diagnostics available)' : ''}`;\n}\n\nexport function createHelpStatusTool(\n inspect: () => HelpStatusReport | Promise<HelpStatusReport>,\n authorize: (signal?: AbortSignal) => AbortSignal,\n) {\n return defineTool({\n name: HELP_STATUS_TOOL_NAME,\n description: HELP_STATUS_TOOL_DESCRIPTION,\n parameters: helpStatusParameters,\n when: HELP_WHEN,\n promptGuidelines: [HELP_GUIDANCE],\n async execute(_input, execution) {\n const signal = authorize(execution.signal);\n const report = await inspect();\n signal.throwIfAborted();\n authorize(execution.signal);\n return { content: [{ type: 'text', text: JSON.stringify(report, null, 2) }], details: report };\n },\n });\n}\n","import type { PoHeadlessCommand, PoHeadlessHostService, PoHeadlessResource } from '@agimon-ai/po-core/headless';\nimport { PO_HELP_WHEN as HELP_WHEN } from '@agimon-ai/po-core/help';\nimport { type PoServerSessionPlugin, packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverFacet';\nimport { defineMinorMode, serverMinorModes, type MinorModeOwner, type MinorModeState } from '@agimon-ai/po-minor-mode';\n\nimport {\n HELP_COMMAND_DESCRIPTION,\n HELP_COMMAND_NAME,\n HELP_GUIDANCE,\n HELP_MODE_ID,\n HELP_PACKAGE_SOURCE,\n HELP_CHATGPT_SKILL,\n HELP_NATIVE_SKILL,\n HELP_SKILL,\n} from '../../constants/help';\nimport { createHelpStatusTool, helpStatusDetail, serverHelpStatus } from '../helpStatus';\nexport function createHelpServerSession(host: PoHeadlessHostService): PoServerSessionPlugin {\n let modeOwner: MinorModeOwner | undefined;\n let pending: boolean | undefined;\n let failure: string | undefined;\n let generation = 0;\n let disposed = false;\n const active = () => (host.context.selection.state?.['minor-mode'] ?? []).includes(HELP_MODE_ID);\n const inspect = () => serverHelpStatus(host.inspectCapabilities(), active());\n const modeState = (): MinorModeState => {\n const report = inspect();\n return {\n activation: pending === true ? 'activating' : active() ? 'active' : 'inactive',\n condition:\n pending !== undefined || !report.ready\n ? 'queued'\n : failure\n ? 'failed'\n : report.activation === 'degraded'\n ? 'degraded'\n : 'ready',\n ...(pending !== undefined\n ? { detail: 'applying Help capabilities' }\n : failure\n ? { detail: failure }\n : active()\n ? { detail: helpStatusDetail(report) }\n : {}),\n actions: [\n {\n id: 'activate',\n enabled: !active() && pending === undefined,\n ...(!active() && pending === undefined ? {} : { disabledReason: 'Help is active or changing.' }),\n },\n {\n id: 'deactivate',\n enabled: active() || pending === true,\n ...(active() || pending === true ? {} : { disabledReason: 'Help mode is not active.' }),\n },\n ],\n };\n };\n const resources: PoHeadlessResource[] = [\n { when: HELP_WHEN, name: 'po-help', kind: 'context', read: () => HELP_GUIDANCE },\n {\n when: HELP_WHEN,\n ...HELP_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/po-use-help/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/po-use-help/SKILL.md');\n if (!text.trim()) throw new Error('The installed Help skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_CHATGPT_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/po-use-chatgpt-instructions/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/po-use-chatgpt-instructions/SKILL.md');\n if (!text.trim()) throw new Error('The installed ChatGPT instruction skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_NATIVE_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/po-develop-native-extension/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/po-develop-native-extension/SKILL.md');\n if (!text.trim()) throw new Error('The installed native extension skill is missing or unreadable.');\n return text;\n },\n },\n ];\n const selectMode = async (enabled: boolean, signal?: AbortSignal): Promise<void> => {\n if (disposed) throw new Error('Help runtime is disposed.');\n signal?.throwIfAborted();\n const operation = ++generation;\n pending = enabled;\n failure = undefined;\n modeOwner?.publish();\n try {\n if (enabled) await resources[1]!.read(host.context);\n signal?.throwIfAborted();\n if (operation !== generation || disposed) throw new Error('Help activation was cancelled.');\n const modes = (host.context.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== HELP_MODE_ID);\n await host.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: enabled ? [...modes, HELP_MODE_ID] : modes,\n });\n } catch (error) {\n if (operation === generation) failure = (error instanceof Error ? error.message : String(error)).slice(0, 160);\n throw error;\n } finally {\n if (operation === generation) {\n pending = undefined;\n modeOwner?.publish();\n }\n }\n };\n const command: PoHeadlessCommand = {\n name: HELP_COMMAND_NAME,\n description: HELP_COMMAND_DESCRIPTION,\n async execute(_args, execution) {\n await selectMode(!(pending ?? active()));\n await execution.client.notify({\n title: 'Po Help',\n body: active() ? 'Help mode activated.' : 'Help mode deactivated.',\n level: 'info',\n });\n },\n };\n modeOwner = defineMinorMode({\n descriptor: {\n source: HELP_PACKAGE_SOURCE,\n id: HELP_MODE_ID,\n label: 'Help',\n description: 'Package guidance and read-only diagnostics for agent setup and debugging.',\n order: 50,\n actions: [\n {\n id: 'activate',\n label: 'Activate',\n description: 'Expose Help guidance and diagnostic tools.',\n contexts: ['headless'],\n parameters: [],\n },\n {\n id: 'deactivate',\n label: 'Deactivate',\n description: 'Withdraw Help-only guidance and diagnostic tools.',\n contexts: ['headless'],\n parameters: [],\n },\n ],\n },\n state: modeState,\n async handleAction(_runtime, actionId, _argumentsValue, { signal }) {\n if (actionId !== 'activate' && actionId !== 'deactivate')\n throw new Error(`Unknown Help mode action: ${actionId}`);\n await selectMode(actionId === 'activate', signal);\n return { message: active() ? 'Help mode activated.' : 'Help mode deactivated.' };\n },\n }).createOwner(undefined);\n return {\n services: [serverMinorModes([modeOwner])],\n resources,\n commands: [command],\n tools: [\n createHelpStatusTool(inspect, (signal) => {\n signal?.throwIfAborted();\n host.assertActive(HELP_PACKAGE_SOURCE);\n if (disposed || !active()) throw new Error('Help mode is not active.');\n return signal ?? new AbortController().signal;\n }),\n ],\n onDispose() {\n disposed = true;\n generation += 1;\n },\n };\n}\n","import type { PoServerPluginDefinition, PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nimport { createHelpServerSession } from '../../../../../services/helpServerSession';\n\nexport default (({ agent }): Partial<PoServerSessionPlugin> =>\n agent ? createHelpServerSession(agent) : {}) satisfies NonNullable<PoServerPluginDefinition['session']>;\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverFacet';\n\nimport runtime from './_lib/runtime.server';\n\nexport default defineRoot((context: PoServerPluginContext) => {\n const value = runtime(context);\n return {\n value,\n services: value.services,\n activities: value.activities,\n onStart: value.onStart,\n onStop: value.onStop,\n onDispose: value.onDispose,\n };\n});\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.commands?.[0],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[3],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[0],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[2],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[1],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.tools?.[0],\n { cardinality: 'optional' },\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverFacet';\nimport { composeRootHooks } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport commandPoHelp from '../src/extensions/workspaces/sessions/(backend)/command/po-help.server';\nimport resourcePoDevelopNativeExtension from '../src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server';\nimport resourcePoHelp from '../src/extensions/workspaces/sessions/(backend)/resource/po-help.server';\nimport resourcePoUseChatgptInstructions from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-chatgpt-instructions.server';\nimport resourcePoUseHelp from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-help.server';\nimport toolHelpStatus from '../src/extensions/workspaces/sessions/(backend)/tool/help_status.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n/* v8 ignore next -- generated normalization branch */\nconst defined = <T>(values: readonly (T | undefined)[]): T[] =>\n values.filter((value): value is T => value !== undefined);\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const facet = defineServerPlugin({\n name: '@agimon-ai/po-help',\n providerOverrides: composeServerProviderOverrides(rootSession),\n session: async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get commands(): PoServerSessionPlugin['commands'] { return defined([via({ name: 'po-help' }, at(commandPoHelp, contextSession))]); },\n get resources(): PoServerSessionPlugin['resources'] { return defined([at(resourcePoDevelopNativeExtension, contextSession), at(resourcePoHelp, contextSession), at(resourcePoUseChatgptInstructions, contextSession), at(resourcePoUseHelp, contextSession)]); },\n get tools(): PoServerSessionPlugin['tools'] { return defined([via({ name: 'help_status' }, at(toolHelpStatus, contextSession))]); },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default facet;\n"],"mappings":";;;;;;;;;;AAAA,MAAa,oBAAoB;AACjC,MAAa,2BAA2B;AACxC,MAAa,eAAe;AAC5B,MAAa,sBAAsB;AACnC,MAAa,aAAa;CACxB,MAAM;CACN,aACE;AACJ;AACA,MAAa,gBACX;AACF,MAAa,wBAAwB;AACrC,MAAa,+BACX;AAGF,MAAa,qBAAqB;CAChC,MAAM;CACN,aACE;AACJ;AAEA,MAAa,oBAAoB;CAC/B,MAAM;CACN,aACE;AACJ;;;ACxBA,MAAa,uBAAuBA,QAAAA,KAAK,OAAO,CAAC,GAAG,EAAE,sBAAsB,MAAM,CAAC;;;ACYnF,SAAgB,iBAAiB,UAAwC,SAAoC;CAC3G,MAAM,UAAU,SAAS,aAAa,QAAQ,UAAU,MAAM,MAAM,QAAQ,kBAAkB,YAAY;CAC1G,MAAM,SAAS,QAAQ,QAAQ,UAAU,MAAM,SAAS,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;GAAG;GAC/P,IAAI,QAAwC;IAAE,OAAO,QAAQ,CAAC,IAAI,EAAE,MAAM,cAAc,GAAG,GAAGC,4BAAgB,cAAc,CAAC,CAAC,CAAC;GAAG;GAClI,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAkD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACvG;CACF;AACF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region generated/server.d.ts
|
|
2
|
-
export declare const facet: import("@agimon-ai/po-core/serverFacet").
|
|
2
|
+
export declare const facet: import("@agimon-ai/po-core/serverFacet").PoServerFacet;
|
|
3
3
|
//#endregion
|
|
4
4
|
export { facet as default };
|
|
5
5
|
//# sourceMappingURL=server.d.mts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PO_HELP_WHEN } from "@agimon-ai/po-core/help";
|
|
2
2
|
import { composeServerProviderOverrides, defineServerPlugin, defineTool, packageResourcePath, readPackageResource } from "@agimon-ai/po-core/serverFacet";
|
|
3
3
|
import { composeRootHooks, defineRoot, defineRoutedContribution } from "@agimon-ai/po-core/extensionFile";
|
|
4
4
|
import { defineMinorMode, serverMinorModes } from "@agimon-ai/po-minor-mode";
|
|
5
5
|
import { Type } from "typebox";
|
|
6
6
|
//#region src/constants/help.ts
|
|
7
|
-
const HELP_COMMAND_NAME = "
|
|
7
|
+
const HELP_COMMAND_NAME = "po-help";
|
|
8
8
|
const HELP_COMMAND_DESCRIPTION = "Toggle Help guidance and read-only support diagnostics";
|
|
9
9
|
const HELP_MODE_ID = "help";
|
|
10
10
|
const HELP_PACKAGE_SOURCE = "@agimon-ai/po-help";
|
|
@@ -69,7 +69,7 @@ function createHelpStatusTool(inspect, authorize) {
|
|
|
69
69
|
name: HELP_STATUS_TOOL_NAME,
|
|
70
70
|
description: HELP_STATUS_TOOL_DESCRIPTION,
|
|
71
71
|
parameters: helpStatusParameters,
|
|
72
|
-
when:
|
|
72
|
+
when: PO_HELP_WHEN,
|
|
73
73
|
promptGuidelines: [HELP_GUIDANCE],
|
|
74
74
|
async execute(_input, execution) {
|
|
75
75
|
const signal = authorize(execution.signal);
|
|
@@ -115,13 +115,13 @@ function createHelpServerSession(host) {
|
|
|
115
115
|
};
|
|
116
116
|
const resources = [
|
|
117
117
|
{
|
|
118
|
-
when:
|
|
118
|
+
when: PO_HELP_WHEN,
|
|
119
119
|
name: "po-help",
|
|
120
120
|
kind: "context",
|
|
121
121
|
read: () => HELP_GUIDANCE
|
|
122
122
|
},
|
|
123
123
|
{
|
|
124
|
-
when:
|
|
124
|
+
when: PO_HELP_WHEN,
|
|
125
125
|
...HELP_SKILL,
|
|
126
126
|
kind: "skill",
|
|
127
127
|
path: packageResourcePath(import.meta.url, "src/prompts/po-use-help/SKILL.md"),
|
|
@@ -132,7 +132,7 @@ function createHelpServerSession(host) {
|
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
134
|
{
|
|
135
|
-
when:
|
|
135
|
+
when: PO_HELP_WHEN,
|
|
136
136
|
...HELP_CHATGPT_SKILL,
|
|
137
137
|
kind: "skill",
|
|
138
138
|
path: packageResourcePath(import.meta.url, "src/prompts/po-use-chatgpt-instructions/SKILL.md"),
|
|
@@ -143,7 +143,7 @@ function createHelpServerSession(host) {
|
|
|
143
143
|
}
|
|
144
144
|
},
|
|
145
145
|
{
|
|
146
|
-
when:
|
|
146
|
+
when: PO_HELP_WHEN,
|
|
147
147
|
...HELP_NATIVE_SKILL,
|
|
148
148
|
kind: "skill",
|
|
149
149
|
path: packageResourcePath(import.meta.url, "src/prompts/po-develop-native-extension/SKILL.md"),
|
|
@@ -254,8 +254,8 @@ var root_server_default = defineRoot((context) => {
|
|
|
254
254
|
};
|
|
255
255
|
});
|
|
256
256
|
//#endregion
|
|
257
|
-
//#region src/extensions/workspaces/sessions/(backend)/command/
|
|
258
|
-
var
|
|
257
|
+
//#region src/extensions/workspaces/sessions/(backend)/command/po-help.server.ts
|
|
258
|
+
var po_help_server_default$1 = defineRoutedContribution((context) => context.root.commands?.[0], { cardinality: "optional" });
|
|
259
259
|
//#endregion
|
|
260
260
|
//#region src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server.ts
|
|
261
261
|
var po_develop_native_extension_server_default = defineRoutedContribution((context) => context.root.resources?.[3], { cardinality: "optional" });
|
|
@@ -292,7 +292,7 @@ const facet = defineServerPlugin({
|
|
|
292
292
|
return {
|
|
293
293
|
...composeRootHooks(scopeSession),
|
|
294
294
|
get commands() {
|
|
295
|
-
return defined([via({ name: "
|
|
295
|
+
return defined([via({ name: "po-help" }, at(po_help_server_default$1, contextSession))]);
|
|
296
296
|
},
|
|
297
297
|
get resources() {
|
|
298
298
|
return defined([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.mjs","names":["HELP_WHEN","HELP_WHEN","runtime","rootSession","commandDoomHelp","resourcePoDevelopNativeExtension","resourcePoHelp","resourcePoUseChatgptInstructions","resourcePoUseHelp","toolHelpStatus"],"sources":["../../src/constants/help.ts","../../src/schemas/diagnostics.ts","../../src/services/helpStatus/index.ts","../../src/services/helpServerSession/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/runtime.server.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/command/doom-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-chatgpt-instructions.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/help_status.server.ts","../../generated/server.ts"],"sourcesContent":["export const HELP_COMMAND_NAME = 'doom-help';\nexport const HELP_COMMAND_DESCRIPTION = 'Toggle Help guidance and read-only support diagnostics';\nexport const HELP_MODE_ID = 'help';\nexport const HELP_PACKAGE_SOURCE = '@agimon-ai/po-help';\nexport const HELP_SKILL = {\n name: 'po-use-help',\n description:\n 'Set up and debug Po agents using installed package guidance and scoped, read-only diagnostics. Diagnose missing capabilities before proposing authorized repairs.',\n} as const;\nexport const HELP_GUIDANCE =\n 'Help mode is active. Read po-use-help, inspect the available diagnostics, and use the narrowest package guidance for the task. Diagnose before proposing changes. Help does not grant additional permissions.';\nexport const HELP_STATUS_TOOL_NAME = 'help_status';\nexport const HELP_STATUS_TOOL_DESCRIPTION =\n 'Inspect active Help skills, diagnostic tools, contributor ownership, and unavailable contributions in this session. Read-only; does not change selection or permissions.';\nexport const HELP_STATUS_LIMIT = 128;\n\nexport const HELP_CHATGPT_SKILL = {\n name: 'po-use-chatgpt-instructions',\n description:\n \"Print a paste-ready ChatGPT project instruction (at most 8,000 characters) that routes code-mode work through this session's MCP tools and condenses every AGENTS.md rule. Writes no files.\",\n} as const;\n\nexport const HELP_NATIVE_SKILL = {\n name: 'po-develop-native-extension',\n description:\n \"Add or change a Po package's phone UI (.native files, native templates) so it mirrors the cockpit, passes the native build, and is approved and verified before it ships.\",\n} as const;\n","import { Type } from 'typebox';\n\nexport const helpStatusParameters = Type.Object({}, { additionalProperties: false });\n","import type { DoomHeadlessCapabilitySnapshot } from '@agimon-ai/po-core/headless';\nimport { DOOM_HELP_WHEN as HELP_WHEN } from '@agimon-ai/po-core/help';\nimport { defineTool } from '@agimon-ai/po-core/serverFacet';\n\nimport {\n HELP_GUIDANCE,\n HELP_MODE_ID,\n HELP_STATUS_LIMIT,\n HELP_STATUS_TOOL_DESCRIPTION,\n HELP_STATUS_TOOL_NAME,\n} from '../../constants/help';\nimport { helpStatusParameters } from '../../schemas/diagnostics';\nimport type { HelpStatusReport } from './type';\n\nexport function serverHelpStatus(snapshot: DoomHeadlessCapabilitySnapshot, enabled: boolean): HelpStatusReport {\n const entries = snapshot.capabilities.filter((entry) => entry.when?.state?.['minor-mode'] === HELP_MODE_ID);\n const skills = entries.filter((entry) => entry.kind === 'skill');\n const tools = entries.filter((entry) => entry.kind === 'tool');\n const diagnostics = entries\n .filter((entry) => enabled && entry.reason && entry.reason !== 'inactive')\n .map((entry) => ({ source: entry.source, code: `HELP_${entry.reason!.replaceAll('-', '_').toUpperCase()}` }));\n const ready = snapshot.ready;\n return {\n activation: !enabled ? 'inactive' : !ready ? 'activating' : diagnostics.length ? 'degraded' : 'active',\n ready,\n revision: snapshot.revision,\n counts: {\n skills: ready ? skills.filter((entry) => entry.active && entry.discoverable).length : null,\n tools: tools.filter((entry) => entry.active).length,\n },\n skills: skills.slice(0, HELP_STATUS_LIMIT).map(({ name, source, active, discoverable, reason }) => ({\n name,\n source,\n active: active && discoverable,\n ...(reason ? { reason } : {}),\n })),\n tools: tools\n .slice(0, HELP_STATUS_LIMIT)\n .map(({ name, source, active, reason }) => ({ name, source, active, ...(reason ? { reason } : {}) })),\n diagnostics: diagnostics.slice(0, HELP_STATUS_LIMIT),\n truncated:\n skills.length > HELP_STATUS_LIMIT || tools.length > HELP_STATUS_LIMIT || diagnostics.length > HELP_STATUS_LIMIT,\n };\n}\n\nexport function helpStatusDetail(report: HelpStatusReport): string {\n return `${report.counts.skills ?? 'pending'} Help skills, ${report.counts.tools} diagnostic tools${report.diagnostics.length ? ' (diagnostics available)' : ''}`;\n}\n\nexport function createHelpStatusTool(\n inspect: () => HelpStatusReport | Promise<HelpStatusReport>,\n authorize: (signal?: AbortSignal) => AbortSignal,\n) {\n return defineTool({\n name: HELP_STATUS_TOOL_NAME,\n description: HELP_STATUS_TOOL_DESCRIPTION,\n parameters: helpStatusParameters,\n when: HELP_WHEN,\n promptGuidelines: [HELP_GUIDANCE],\n async execute(_input, execution) {\n const signal = authorize(execution.signal);\n const report = await inspect();\n signal.throwIfAborted();\n authorize(execution.signal);\n return { content: [{ type: 'text', text: JSON.stringify(report, null, 2) }], details: report };\n },\n });\n}\n","import type { DoomHeadlessCommand, DoomHeadlessHostService, DoomHeadlessResource } from '@agimon-ai/po-core/headless';\nimport { DOOM_HELP_WHEN as HELP_WHEN } from '@agimon-ai/po-core/help';\nimport { type DoomServerSessionPlugin, packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverFacet';\nimport { defineMinorMode, serverMinorModes, type MinorModeOwner, type MinorModeState } from '@agimon-ai/po-minor-mode';\n\nimport {\n HELP_COMMAND_DESCRIPTION,\n HELP_COMMAND_NAME,\n HELP_GUIDANCE,\n HELP_MODE_ID,\n HELP_PACKAGE_SOURCE,\n HELP_CHATGPT_SKILL,\n HELP_NATIVE_SKILL,\n HELP_SKILL,\n} from '../../constants/help';\nimport { createHelpStatusTool, helpStatusDetail, serverHelpStatus } from '../helpStatus';\nexport function createHelpServerSession(host: DoomHeadlessHostService): DoomServerSessionPlugin {\n let modeOwner: MinorModeOwner | undefined;\n let pending: boolean | undefined;\n let failure: string | undefined;\n let generation = 0;\n let disposed = false;\n const active = () => (host.context.selection.state?.['minor-mode'] ?? []).includes(HELP_MODE_ID);\n const inspect = () => serverHelpStatus(host.inspectCapabilities(), active());\n const modeState = (): MinorModeState => {\n const report = inspect();\n return {\n activation: pending === true ? 'activating' : active() ? 'active' : 'inactive',\n condition:\n pending !== undefined || !report.ready\n ? 'queued'\n : failure\n ? 'failed'\n : report.activation === 'degraded'\n ? 'degraded'\n : 'ready',\n ...(pending !== undefined\n ? { detail: 'applying Help capabilities' }\n : failure\n ? { detail: failure }\n : active()\n ? { detail: helpStatusDetail(report) }\n : {}),\n actions: [\n {\n id: 'activate',\n enabled: !active() && pending === undefined,\n ...(!active() && pending === undefined ? {} : { disabledReason: 'Help is active or changing.' }),\n },\n {\n id: 'deactivate',\n enabled: active() || pending === true,\n ...(active() || pending === true ? {} : { disabledReason: 'Help mode is not active.' }),\n },\n ],\n };\n };\n const resources: DoomHeadlessResource[] = [\n { when: HELP_WHEN, name: 'po-help', kind: 'context', read: () => HELP_GUIDANCE },\n {\n when: HELP_WHEN,\n ...HELP_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/po-use-help/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/po-use-help/SKILL.md');\n if (!text.trim()) throw new Error('The installed Help skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_CHATGPT_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/po-use-chatgpt-instructions/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/po-use-chatgpt-instructions/SKILL.md');\n if (!text.trim()) throw new Error('The installed ChatGPT instruction skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_NATIVE_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/po-develop-native-extension/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/po-develop-native-extension/SKILL.md');\n if (!text.trim()) throw new Error('The installed native extension skill is missing or unreadable.');\n return text;\n },\n },\n ];\n const selectMode = async (enabled: boolean, signal?: AbortSignal): Promise<void> => {\n if (disposed) throw new Error('Help runtime is disposed.');\n signal?.throwIfAborted();\n const operation = ++generation;\n pending = enabled;\n failure = undefined;\n modeOwner?.publish();\n try {\n if (enabled) await resources[1]!.read(host.context);\n signal?.throwIfAborted();\n if (operation !== generation || disposed) throw new Error('Help activation was cancelled.');\n const modes = (host.context.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== HELP_MODE_ID);\n await host.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: enabled ? [...modes, HELP_MODE_ID] : modes,\n });\n } catch (error) {\n if (operation === generation) failure = (error instanceof Error ? error.message : String(error)).slice(0, 160);\n throw error;\n } finally {\n if (operation === generation) {\n pending = undefined;\n modeOwner?.publish();\n }\n }\n };\n const command: DoomHeadlessCommand = {\n name: HELP_COMMAND_NAME,\n description: HELP_COMMAND_DESCRIPTION,\n async execute(_args, execution) {\n await selectMode(!(pending ?? active()));\n await execution.client.notify({\n title: 'Po Help',\n body: active() ? 'Help mode activated.' : 'Help mode deactivated.',\n level: 'info',\n });\n },\n };\n modeOwner = defineMinorMode({\n descriptor: {\n source: HELP_PACKAGE_SOURCE,\n id: HELP_MODE_ID,\n label: 'Help',\n description: 'Package guidance and read-only diagnostics for agent setup and debugging.',\n order: 50,\n actions: [\n {\n id: 'activate',\n label: 'Activate',\n description: 'Expose Help guidance and diagnostic tools.',\n contexts: ['headless'],\n parameters: [],\n },\n {\n id: 'deactivate',\n label: 'Deactivate',\n description: 'Withdraw Help-only guidance and diagnostic tools.',\n contexts: ['headless'],\n parameters: [],\n },\n ],\n },\n state: modeState,\n async handleAction(_runtime, actionId, _argumentsValue, { signal }) {\n if (actionId !== 'activate' && actionId !== 'deactivate')\n throw new Error(`Unknown Help mode action: ${actionId}`);\n await selectMode(actionId === 'activate', signal);\n return { message: active() ? 'Help mode activated.' : 'Help mode deactivated.' };\n },\n }).createOwner(undefined);\n return {\n services: [serverMinorModes([modeOwner])],\n resources,\n commands: [command],\n tools: [\n createHelpStatusTool(inspect, (signal) => {\n signal?.throwIfAborted();\n host.assertActive(HELP_PACKAGE_SOURCE);\n if (disposed || !active()) throw new Error('Help mode is not active.');\n return signal ?? new AbortController().signal;\n }),\n ],\n onDispose() {\n disposed = true;\n generation += 1;\n },\n };\n}\n","import type { DoomServerPluginDefinition, DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nimport { createHelpServerSession } from '../../../../../services/helpServerSession';\n\nexport default (({ agent }): Partial<DoomServerSessionPlugin> =>\n agent ? createHelpServerSession(agent) : {}) satisfies NonNullable<DoomServerPluginDefinition['session']>;\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/po-core/serverFacet';\n\nimport runtime from './_lib/runtime.server';\n\nexport default defineRoot((context: DoomServerPluginContext) => {\n const value = runtime(context);\n return {\n value,\n services: value.services,\n activities: value.activities,\n onStart: value.onStart,\n onStop: value.onStop,\n onDispose: value.onDispose,\n };\n});\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { DoomServerPluginContext, DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<DoomServerPluginContext, Partial<DoomServerSessionPlugin>>) => context.root.commands?.[0],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { DoomServerPluginContext, DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<DoomServerPluginContext, Partial<DoomServerSessionPlugin>>) => context.root.resources?.[3],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { DoomServerPluginContext, DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<DoomServerPluginContext, Partial<DoomServerSessionPlugin>>) => context.root.resources?.[0],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { DoomServerPluginContext, DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<DoomServerPluginContext, Partial<DoomServerSessionPlugin>>) => context.root.resources?.[2],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { DoomServerPluginContext, DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<DoomServerPluginContext, Partial<DoomServerSessionPlugin>>) => context.root.resources?.[1],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { DoomServerPluginContext, DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<DoomServerPluginContext, Partial<DoomServerSessionPlugin>>) => context.root.tools?.[0],\n { cardinality: 'optional' },\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type DoomServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverFacet';\nimport { composeRootHooks } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport commandDoomHelp from '../src/extensions/workspaces/sessions/(backend)/command/doom-help.server';\nimport resourcePoDevelopNativeExtension from '../src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server';\nimport resourcePoHelp from '../src/extensions/workspaces/sessions/(backend)/resource/po-help.server';\nimport resourcePoUseChatgptInstructions from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-chatgpt-instructions.server';\nimport resourcePoUseHelp from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-help.server';\nimport toolHelpStatus from '../src/extensions/workspaces/sessions/(backend)/tool/help_status.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n/* v8 ignore next -- generated normalization branch */\nconst defined = <T>(values: readonly (T | undefined)[]): T[] =>\n values.filter((value): value is T => value !== undefined);\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const facet = defineServerPlugin({\n name: '@agimon-ai/po-help',\n providerOverrides: composeServerProviderOverrides(rootSession),\n session: async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get commands(): DoomServerSessionPlugin['commands'] { return defined([via({ name: 'doom-help' }, at(commandDoomHelp, contextSession))]); },\n get resources(): DoomServerSessionPlugin['resources'] { return defined([at(resourcePoDevelopNativeExtension, contextSession), at(resourcePoHelp, contextSession), at(resourcePoUseChatgptInstructions, contextSession), at(resourcePoUseHelp, contextSession)]); },\n get tools(): DoomServerSessionPlugin['tools'] { return defined([via({ name: 'help_status' }, at(toolHelpStatus, contextSession))]); },\n services: [...(scopeSession.services ?? [])],\n get activities(): DoomServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default facet;\n"],"mappings":";;;;;;AAAA,MAAa,oBAAoB;AACjC,MAAa,2BAA2B;AACxC,MAAa,eAAe;AAC5B,MAAa,sBAAsB;AACnC,MAAa,aAAa;CACxB,MAAM;CACN,aACE;AACJ;AACA,MAAa,gBACX;AACF,MAAa,wBAAwB;AACrC,MAAa,+BACX;AAGF,MAAa,qBAAqB;CAChC,MAAM;CACN,aACE;AACJ;AAEA,MAAa,oBAAoB;CAC/B,MAAM;CACN,aACE;AACJ;;;ACxBA,MAAa,uBAAuB,KAAK,OAAO,CAAC,GAAG,EAAE,sBAAsB,MAAM,CAAC;;;ACYnF,SAAgB,iBAAiB,UAA0C,SAAoC;CAC7G,MAAM,UAAU,SAAS,aAAa,QAAQ,UAAU,MAAM,MAAM,QAAQ,kBAAkB,YAAY;CAC1G,MAAM,SAAS,QAAQ,QAAQ,UAAU,MAAM,SAAS,OAAO;CAC/D,MAAM,QAAQ,QAAQ,QAAQ,UAAU,MAAM,SAAS,MAAM;CAC7D,MAAM,cAAc,QACjB,QAAQ,UAAU,WAAW,MAAM,UAAU,MAAM,WAAW,UAAU,CAAC,CACzE,KAAK,WAAW;EAAE,QAAQ,MAAM;EAAQ,MAAM,QAAQ,MAAM,OAAQ,WAAW,KAAK,GAAG,CAAC,CAAC,YAAY;CAAI,EAAE;CAC9G,MAAM,QAAQ,SAAS;CACvB,OAAO;EACL,YAAY,CAAC,UAAU,aAAa,CAAC,QAAQ,eAAe,YAAY,SAAS,aAAa;EAC9F;EACA,UAAU,SAAS;EACnB,QAAQ;GACN,QAAQ,QAAQ,OAAO,QAAQ,UAAU,MAAM,U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G;GACjQ,IAAI,QAA0C;IAAE,OAAO,QAAQ,CAAC,IAAI,EAAE,MAAM,cAAc,GAAG,GAAGC,4BAAgB,cAAc,CAAC,CAAC,CAAC;GAAG;GACpI,UAAU,CAAC,GAAI,aAAa,YAAY,CAAC,CAAE;GAC3C,IAAI,aAAoD;IAAE,OAAO,CAAC,GAAI,aAAa,cAAc,CAAC,CAAE;GAAG;EACzG;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"server.mjs","names":["HELP_WHEN","HELP_WHEN","runtime","rootSession","commandPoHelp","resourcePoDevelopNativeExtension","resourcePoHelp","resourcePoUseChatgptInstructions","resourcePoUseHelp","toolHelpStatus"],"sources":["../../src/constants/help.ts","../../src/schemas/diagnostics.ts","../../src/services/helpStatus/index.ts","../../src/services/helpServerSession/index.ts","../../src/extensions/workspaces/sessions/(backend)/_lib/runtime.server.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/command/po-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-chatgpt-instructions.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/po-use-help.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/help_status.server.ts","../../generated/server.ts"],"sourcesContent":["export const HELP_COMMAND_NAME = 'po-help';\nexport const HELP_COMMAND_DESCRIPTION = 'Toggle Help guidance and read-only support diagnostics';\nexport const HELP_MODE_ID = 'help';\nexport const HELP_PACKAGE_SOURCE = '@agimon-ai/po-help';\nexport const HELP_SKILL = {\n name: 'po-use-help',\n description:\n 'Set up and debug Po agents using installed package guidance and scoped, read-only diagnostics. Diagnose missing capabilities before proposing authorized repairs.',\n} as const;\nexport const HELP_GUIDANCE =\n 'Help mode is active. Read po-use-help, inspect the available diagnostics, and use the narrowest package guidance for the task. Diagnose before proposing changes. Help does not grant additional permissions.';\nexport const HELP_STATUS_TOOL_NAME = 'help_status';\nexport const HELP_STATUS_TOOL_DESCRIPTION =\n 'Inspect active Help skills, diagnostic tools, contributor ownership, and unavailable contributions in this session. Read-only; does not change selection or permissions.';\nexport const HELP_STATUS_LIMIT = 128;\n\nexport const HELP_CHATGPT_SKILL = {\n name: 'po-use-chatgpt-instructions',\n description:\n \"Print a paste-ready ChatGPT project instruction (at most 8,000 characters) that routes code-mode work through this session's MCP tools and condenses every AGENTS.md rule. Writes no files.\",\n} as const;\n\nexport const HELP_NATIVE_SKILL = {\n name: 'po-develop-native-extension',\n description:\n \"Add or change a Po package's phone UI (.native files, native templates) so it mirrors the cockpit, passes the native build, and is approved and verified before it ships.\",\n} as const;\n","import { Type } from 'typebox';\n\nexport const helpStatusParameters = Type.Object({}, { additionalProperties: false });\n","import type { PoHeadlessCapabilitySnapshot } from '@agimon-ai/po-core/headless';\nimport { PO_HELP_WHEN as HELP_WHEN } from '@agimon-ai/po-core/help';\nimport { defineTool } from '@agimon-ai/po-core/serverFacet';\n\nimport {\n HELP_GUIDANCE,\n HELP_MODE_ID,\n HELP_STATUS_LIMIT,\n HELP_STATUS_TOOL_DESCRIPTION,\n HELP_STATUS_TOOL_NAME,\n} from '../../constants/help';\nimport { helpStatusParameters } from '../../schemas/diagnostics';\nimport type { HelpStatusReport } from './type';\n\nexport function serverHelpStatus(snapshot: PoHeadlessCapabilitySnapshot, enabled: boolean): HelpStatusReport {\n const entries = snapshot.capabilities.filter((entry) => entry.when?.state?.['minor-mode'] === HELP_MODE_ID);\n const skills = entries.filter((entry) => entry.kind === 'skill');\n const tools = entries.filter((entry) => entry.kind === 'tool');\n const diagnostics = entries\n .filter((entry) => enabled && entry.reason && entry.reason !== 'inactive')\n .map((entry) => ({ source: entry.source, code: `HELP_${entry.reason!.replaceAll('-', '_').toUpperCase()}` }));\n const ready = snapshot.ready;\n return {\n activation: !enabled ? 'inactive' : !ready ? 'activating' : diagnostics.length ? 'degraded' : 'active',\n ready,\n revision: snapshot.revision,\n counts: {\n skills: ready ? skills.filter((entry) => entry.active && entry.discoverable).length : null,\n tools: tools.filter((entry) => entry.active).length,\n },\n skills: skills.slice(0, HELP_STATUS_LIMIT).map(({ name, source, active, discoverable, reason }) => ({\n name,\n source,\n active: active && discoverable,\n ...(reason ? { reason } : {}),\n })),\n tools: tools\n .slice(0, HELP_STATUS_LIMIT)\n .map(({ name, source, active, reason }) => ({ name, source, active, ...(reason ? { reason } : {}) })),\n diagnostics: diagnostics.slice(0, HELP_STATUS_LIMIT),\n truncated:\n skills.length > HELP_STATUS_LIMIT || tools.length > HELP_STATUS_LIMIT || diagnostics.length > HELP_STATUS_LIMIT,\n };\n}\n\nexport function helpStatusDetail(report: HelpStatusReport): string {\n return `${report.counts.skills ?? 'pending'} Help skills, ${report.counts.tools} diagnostic tools${report.diagnostics.length ? ' (diagnostics available)' : ''}`;\n}\n\nexport function createHelpStatusTool(\n inspect: () => HelpStatusReport | Promise<HelpStatusReport>,\n authorize: (signal?: AbortSignal) => AbortSignal,\n) {\n return defineTool({\n name: HELP_STATUS_TOOL_NAME,\n description: HELP_STATUS_TOOL_DESCRIPTION,\n parameters: helpStatusParameters,\n when: HELP_WHEN,\n promptGuidelines: [HELP_GUIDANCE],\n async execute(_input, execution) {\n const signal = authorize(execution.signal);\n const report = await inspect();\n signal.throwIfAborted();\n authorize(execution.signal);\n return { content: [{ type: 'text', text: JSON.stringify(report, null, 2) }], details: report };\n },\n });\n}\n","import type { PoHeadlessCommand, PoHeadlessHostService, PoHeadlessResource } from '@agimon-ai/po-core/headless';\nimport { PO_HELP_WHEN as HELP_WHEN } from '@agimon-ai/po-core/help';\nimport { type PoServerSessionPlugin, packageResourcePath, readPackageResource } from '@agimon-ai/po-core/serverFacet';\nimport { defineMinorMode, serverMinorModes, type MinorModeOwner, type MinorModeState } from '@agimon-ai/po-minor-mode';\n\nimport {\n HELP_COMMAND_DESCRIPTION,\n HELP_COMMAND_NAME,\n HELP_GUIDANCE,\n HELP_MODE_ID,\n HELP_PACKAGE_SOURCE,\n HELP_CHATGPT_SKILL,\n HELP_NATIVE_SKILL,\n HELP_SKILL,\n} from '../../constants/help';\nimport { createHelpStatusTool, helpStatusDetail, serverHelpStatus } from '../helpStatus';\nexport function createHelpServerSession(host: PoHeadlessHostService): PoServerSessionPlugin {\n let modeOwner: MinorModeOwner | undefined;\n let pending: boolean | undefined;\n let failure: string | undefined;\n let generation = 0;\n let disposed = false;\n const active = () => (host.context.selection.state?.['minor-mode'] ?? []).includes(HELP_MODE_ID);\n const inspect = () => serverHelpStatus(host.inspectCapabilities(), active());\n const modeState = (): MinorModeState => {\n const report = inspect();\n return {\n activation: pending === true ? 'activating' : active() ? 'active' : 'inactive',\n condition:\n pending !== undefined || !report.ready\n ? 'queued'\n : failure\n ? 'failed'\n : report.activation === 'degraded'\n ? 'degraded'\n : 'ready',\n ...(pending !== undefined\n ? { detail: 'applying Help capabilities' }\n : failure\n ? { detail: failure }\n : active()\n ? { detail: helpStatusDetail(report) }\n : {}),\n actions: [\n {\n id: 'activate',\n enabled: !active() && pending === undefined,\n ...(!active() && pending === undefined ? {} : { disabledReason: 'Help is active or changing.' }),\n },\n {\n id: 'deactivate',\n enabled: active() || pending === true,\n ...(active() || pending === true ? {} : { disabledReason: 'Help mode is not active.' }),\n },\n ],\n };\n };\n const resources: PoHeadlessResource[] = [\n { when: HELP_WHEN, name: 'po-help', kind: 'context', read: () => HELP_GUIDANCE },\n {\n when: HELP_WHEN,\n ...HELP_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/po-use-help/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/po-use-help/SKILL.md');\n if (!text.trim()) throw new Error('The installed Help skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_CHATGPT_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/po-use-chatgpt-instructions/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/po-use-chatgpt-instructions/SKILL.md');\n if (!text.trim()) throw new Error('The installed ChatGPT instruction skill is missing or unreadable.');\n return text;\n },\n },\n {\n when: HELP_WHEN,\n ...HELP_NATIVE_SKILL,\n kind: 'skill',\n path: packageResourcePath(import.meta.url, 'src/prompts/po-develop-native-extension/SKILL.md'),\n read: async () => {\n const text = await readPackageResource(import.meta.url, 'src/prompts/po-develop-native-extension/SKILL.md');\n if (!text.trim()) throw new Error('The installed native extension skill is missing or unreadable.');\n return text;\n },\n },\n ];\n const selectMode = async (enabled: boolean, signal?: AbortSignal): Promise<void> => {\n if (disposed) throw new Error('Help runtime is disposed.');\n signal?.throwIfAborted();\n const operation = ++generation;\n pending = enabled;\n failure = undefined;\n modeOwner?.publish();\n try {\n if (enabled) await resources[1]!.read(host.context);\n signal?.throwIfAborted();\n if (operation !== generation || disposed) throw new Error('Help activation was cancelled.');\n const modes = (host.context.selection.state?.['minor-mode'] ?? []).filter((mode) => mode !== HELP_MODE_ID);\n await host.changeSelection({\n axis: 'state',\n key: 'minor-mode',\n values: enabled ? [...modes, HELP_MODE_ID] : modes,\n });\n } catch (error) {\n if (operation === generation) failure = (error instanceof Error ? error.message : String(error)).slice(0, 160);\n throw error;\n } finally {\n if (operation === generation) {\n pending = undefined;\n modeOwner?.publish();\n }\n }\n };\n const command: PoHeadlessCommand = {\n name: HELP_COMMAND_NAME,\n description: HELP_COMMAND_DESCRIPTION,\n async execute(_args, execution) {\n await selectMode(!(pending ?? active()));\n await execution.client.notify({\n title: 'Po Help',\n body: active() ? 'Help mode activated.' : 'Help mode deactivated.',\n level: 'info',\n });\n },\n };\n modeOwner = defineMinorMode({\n descriptor: {\n source: HELP_PACKAGE_SOURCE,\n id: HELP_MODE_ID,\n label: 'Help',\n description: 'Package guidance and read-only diagnostics for agent setup and debugging.',\n order: 50,\n actions: [\n {\n id: 'activate',\n label: 'Activate',\n description: 'Expose Help guidance and diagnostic tools.',\n contexts: ['headless'],\n parameters: [],\n },\n {\n id: 'deactivate',\n label: 'Deactivate',\n description: 'Withdraw Help-only guidance and diagnostic tools.',\n contexts: ['headless'],\n parameters: [],\n },\n ],\n },\n state: modeState,\n async handleAction(_runtime, actionId, _argumentsValue, { signal }) {\n if (actionId !== 'activate' && actionId !== 'deactivate')\n throw new Error(`Unknown Help mode action: ${actionId}`);\n await selectMode(actionId === 'activate', signal);\n return { message: active() ? 'Help mode activated.' : 'Help mode deactivated.' };\n },\n }).createOwner(undefined);\n return {\n services: [serverMinorModes([modeOwner])],\n resources,\n commands: [command],\n tools: [\n createHelpStatusTool(inspect, (signal) => {\n signal?.throwIfAborted();\n host.assertActive(HELP_PACKAGE_SOURCE);\n if (disposed || !active()) throw new Error('Help mode is not active.');\n return signal ?? new AbortController().signal;\n }),\n ],\n onDispose() {\n disposed = true;\n generation += 1;\n },\n };\n}\n","import type { PoServerPluginDefinition, PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nimport { createHelpServerSession } from '../../../../../services/helpServerSession';\n\nexport default (({ agent }): Partial<PoServerSessionPlugin> =>\n agent ? createHelpServerSession(agent) : {}) satisfies NonNullable<PoServerPluginDefinition['session']>;\n","import { defineRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext } from '@agimon-ai/po-core/serverFacet';\n\nimport runtime from './_lib/runtime.server';\n\nexport default defineRoot((context: PoServerPluginContext) => {\n const value = runtime(context);\n return {\n value,\n services: value.services,\n activities: value.activities,\n onStart: value.onStart,\n onStop: value.onStop,\n onDispose: value.onDispose,\n };\n});\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.commands?.[0],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[3],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[0],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[2],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.resources?.[1],\n { cardinality: 'optional' },\n);\n","import { defineRoutedContribution, type WithRoot } from '@agimon-ai/po-core/extensionFile';\nimport type { PoServerPluginContext, PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\n\nexport default defineRoutedContribution(\n (context: WithRoot<PoServerPluginContext, Partial<PoServerSessionPlugin>>) => context.root.tools?.[0],\n { cardinality: 'optional' },\n);\n","// Generated by @agimon-ai/po-build. Do not edit by hand.\nimport { defineServerPlugin, type PoServerSessionPlugin } from '@agimon-ai/po-core/serverFacet';\nimport { composeServerProviderOverrides } from '@agimon-ai/po-core/serverFacet';\nimport { composeRootHooks } from '@agimon-ai/po-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport commandPoHelp from '../src/extensions/workspaces/sessions/(backend)/command/po-help.server';\nimport resourcePoDevelopNativeExtension from '../src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server';\nimport resourcePoHelp from '../src/extensions/workspaces/sessions/(backend)/resource/po-help.server';\nimport resourcePoUseChatgptInstructions from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-chatgpt-instructions.server';\nimport resourcePoUseHelp from '../src/extensions/workspaces/sessions/(backend)/resource/po-use-help.server';\nimport toolHelpStatus from '../src/extensions/workspaces/sessions/(backend)/tool/help_status.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\n/* v8 ignore next -- generated normalization branch */\nconst defined = <T>(values: readonly (T | undefined)[]): T[] =>\n values.filter((value): value is T => value !== undefined);\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const facet = defineServerPlugin({\n name: '@agimon-ai/po-help',\n providerOverrides: composeServerProviderOverrides(rootSession),\n session: async (context) => {\n const scopeSession = await rootSession(context);\n const contextSession = { ...context, root: scopeSession.value };\n return {\n ...composeRootHooks(scopeSession),\n get commands(): PoServerSessionPlugin['commands'] { return defined([via({ name: 'po-help' }, at(commandPoHelp, contextSession))]); },\n get resources(): PoServerSessionPlugin['resources'] { return defined([at(resourcePoDevelopNativeExtension, contextSession), at(resourcePoHelp, contextSession), at(resourcePoUseChatgptInstructions, contextSession), at(resourcePoUseHelp, contextSession)]); },\n get tools(): PoServerSessionPlugin['tools'] { return defined([via({ name: 'help_status' }, at(toolHelpStatus, contextSession))]); },\n services: [...(scopeSession.services ?? [])],\n get activities(): PoServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n };\n },\n});\n\nexport default facet;\n"],"mappings":";;;;;;AAAA,MAAa,oBAAoB;AACjC,MAAa,2BAA2B;AACxC,MAA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function diagnostic(source, code, error) {
|
|
|
138
138
|
return {
|
|
139
139
|
source,
|
|
140
140
|
code,
|
|
141
|
-
message: ((error instanceof Error ? error.message : String(error)) || "Unknown Help activation failure.").slice(0, _agimon_ai_po_core_help.
|
|
141
|
+
message: ((error instanceof Error ? error.message : String(error)) || "Unknown Help activation failure.").slice(0, _agimon_ai_po_core_help.PO_HELP_MAX_DIAGNOSTIC_LENGTH)
|
|
142
142
|
};
|
|
143
143
|
}
|
|
144
144
|
function contributionFingerprint(contributions) {
|
|
@@ -277,7 +277,7 @@ var DefaultHelpActivationService = class {
|
|
|
277
277
|
const skills = [];
|
|
278
278
|
const names = /* @__PURE__ */ new Set();
|
|
279
279
|
for (const source of loaded) for (const skill of source.skills) {
|
|
280
|
-
if (skills.length >= _agimon_ai_po_core_help.
|
|
280
|
+
if (skills.length >= _agimon_ai_po_core_help.PO_HELP_MAX_SKILLS) {
|
|
281
281
|
diagnostics.push(diagnostic(source.contribution.source, "HELP_SKILL_LIMIT", "The Help skill limit was reached."));
|
|
282
282
|
break;
|
|
283
283
|
}
|
|
@@ -288,7 +288,7 @@ var DefaultHelpActivationService = class {
|
|
|
288
288
|
names.add(skill.name);
|
|
289
289
|
skills.push({ ...skill });
|
|
290
290
|
}
|
|
291
|
-
const boundedDiagnostics = diagnostics.slice(0, _agimon_ai_po_core_help.
|
|
291
|
+
const boundedDiagnostics = diagnostics.slice(0, _agimon_ai_po_core_help.PO_HELP_MAX_DIAGNOSTICS);
|
|
292
292
|
if (skills.length === 0) {
|
|
293
293
|
this.publish({
|
|
294
294
|
activation: "inactive",
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["DOOM_HELP_MAX_DIAGNOSTIC_LENGTH","DOOM_HELP_MAX_SKILLS","DOOM_HELP_MAX_DIAGNOSTICS","HELP_INDEX_PATH","isRecord","path","fs","fileURLToPath","os","poHomeDirectory","createHash","randomUUID","fs","createHash","path"],"sources":["../src/services/llmsContent/index.ts","../src/services/helpActivation/index.ts","../src/services/helpStorage/index.ts","../src/services/llmsResolver/index.ts","../src/services/helpRuntime/index.ts"],"sourcesContent":["import type { DoomHelpSkillDescriptor } from '@agimon-ai/po-core/help';\n\nimport type { ResolvedHelpIndex } from '../../types/help';\n\nexport const MAX_LLMS_BYTES = 1024 * 1024;\nexport const MAX_AGGREGATE_LLMS_BYTES = 4 * MAX_LLMS_BYTES;\n\nconst MARKDOWN_LINK_PATTERN = /!?\\[[^\\]]*\\]\\(\\s*<?([^\\s)>]+)>?(?:\\s+[^)]*)?\\)/gu;\nconst MARKDOWN_REFERENCE_LINK_PATTERN = /^\\s{0,3}\\[[^\\]\\r\\n]+\\]:\\s*<?([^\\s>]+)>?/gmu;\nconst MARKDOWN_AUTOLINK_PATTERN = /<((?:\\.{0,2}\\/|[A-Za-z][A-Za-z0-9+.-]*:)[^<>\\s]+)>/gu;\nconst HTML_LINK_PATTERN = /\\b(?:href|src)\\s*=\\s*[\"']([^\"']+)[\"']/giu;\nconst URI_SCHEME_PATTERN = /^[a-z][a-z0-9+.-]*:/iu;\nconst NESTED_PATH_ENCODING_PATTERN = /%(?:25|2e|2f|3a|5c)/iu;\nconst SAFE_EXTERNAL_SCHEMES = new Set(['http:', 'https:', 'mailto:']);\n\nfunction externalScheme(target: string): string | undefined {\n if (!URI_SCHEME_PATTERN.test(target)) return undefined;\n return target.slice(0, target.indexOf(':') + 1).toLowerCase();\n}\n\nfunction decodeRelativeTarget(rawTarget: string): string {\n let decoded = rawTarget;\n try {\n for (let pass = 0; pass < 2; pass += 1) {\n const next = decodeURIComponent(decoded);\n if (next === decoded) break;\n decoded = next;\n }\n } catch {\n throw new Error(`llms.txt contains an invalid encoded link '${rawTarget}'.`);\n }\n if (NESTED_PATH_ENCODING_PATTERN.test(decoded)) {\n throw new Error(`llms.txt contains an unsafe nested encoding in link '${rawTarget}'.`);\n }\n return decoded;\n}\n\nfunction validateRelativeLink(rawTarget: string): void {\n if (!rawTarget || rawTarget.startsWith('#')) return;\n const rawScheme = externalScheme(rawTarget);\n if (rawScheme) {\n if (!SAFE_EXTERNAL_SCHEMES.has(rawScheme)) {\n throw new Error(`llms.txt contains unsupported link scheme '${rawScheme}'.`);\n }\n return;\n }\n\n const decoded = decodeRelativeTarget(rawTarget);\n const decodedScheme = externalScheme(decoded);\n if (decodedScheme) {\n if (!SAFE_EXTERNAL_SCHEMES.has(decodedScheme)) {\n throw new Error(`llms.txt contains unsupported link scheme '${decodedScheme}'.`);\n }\n return;\n }\n const withoutSuffix = decoded.split(/[?#]/u, 1)[0]?.replaceAll('\\\\', '/') ?? '';\n if (withoutSuffix.startsWith('/') || withoutSuffix.split('/').some((segment) => segment === '..')) {\n throw new Error(`llms.txt link '${rawTarget}' escapes the package root.`);\n }\n}\n\nfunction containsUnsafeControl(text: string): boolean {\n for (const character of text) {\n const code = character.codePointAt(0) ?? 0;\n if ((code >= 0 && code <= 8) || code === 11 || code === 12 || (code >= 14 && code <= 31) || code === 127) {\n return true;\n }\n }\n return false;\n}\n\nexport function validateLlmsBytes(bytes: Uint8Array): string {\n if (bytes.byteLength === 0) throw new Error('llms.txt is empty.');\n if (bytes.byteLength > MAX_LLMS_BYTES) throw new Error(`llms.txt exceeds ${MAX_LLMS_BYTES} bytes.`);\n\n let text: string;\n try {\n text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);\n } catch {\n throw new Error('llms.txt is not valid UTF-8.');\n }\n if (text.startsWith('\\uFEFF')) text = text.slice(1);\n if (containsUnsafeControl(text)) throw new Error('llms.txt contains unsafe control bytes.');\n\n const firstContentLine = text\n .split(/\\r?\\n/u)\n .find((line) => line.trim().length > 0)\n ?.trim();\n if (!firstContentLine || !/^#\\s+\\S/u.test(firstContentLine)) {\n throw new Error('llms.txt must begin with a Markdown H1 heading.');\n }\n for (const pattern of [\n MARKDOWN_LINK_PATTERN,\n MARKDOWN_REFERENCE_LINK_PATTERN,\n MARKDOWN_AUTOLINK_PATTERN,\n HTML_LINK_PATTERN,\n ]) {\n for (const match of text.matchAll(pattern)) validateRelativeLink(match[1] ?? '');\n }\n return text;\n}\n\nexport function renderHelpSkillWrapper(descriptor: DoomHelpSkillDescriptor, index: ResolvedHelpIndex): string {\n const name = JSON.stringify(descriptor.name);\n const description = JSON.stringify(descriptor.description);\n const indexPath = JSON.stringify(index.filePath);\n const referenceBase = JSON.stringify(index.referenceBase);\n return `---\\nname: ${name}\\ndescription: ${description}\\n---\\n\\n# Package Help\\n\\nRead the validated package Help index at ${indexPath}.\\nResolve relative links in that index against ${referenceBase}.\\nOpen only the linked documents relevant to the current request, as needed; do not recursively load the whole reference set.\\n`;\n}\n","import {\n DOOM_HELP_MAX_DIAGNOSTIC_LENGTH,\n DOOM_HELP_MAX_DIAGNOSTICS,\n DOOM_HELP_MAX_SKILLS,\n type DoomHelpContribution,\n type DoomHelpDiagnostic,\n type DoomHelpSkill,\n} from '@agimon-ai/po-core/help';\n\nimport type {\n HelpActivationDependencies,\n HelpActivationService,\n HelpRuntimeState,\n ResolvedHelpIndex,\n} from '../../types/help';\nimport { MAX_AGGREGATE_LLMS_BYTES } from '../llmsContent';\n\nconst MAX_RESOLUTION_CONCURRENCY = 4;\nconst FAILURE_MESSAGE = 'No package Help source could be activated.';\nconst CANCELLATION_MESSAGE = 'Help activation was cancelled.';\n\ninterface LoadedSource {\n contribution: DoomHelpContribution;\n index: ResolvedHelpIndex;\n skills: readonly DoomHelpSkill[];\n}\n\ninterface SourceOutcome {\n source: string;\n loaded?: LoadedSource;\n error?: unknown;\n}\n\nexport class HelpActivationError extends Error {\n constructor(message = FAILURE_MESSAGE) {\n super(message);\n this.name = 'HelpActivationError';\n }\n}\n\nfunction cloneContribution(contribution: DoomHelpContribution): DoomHelpContribution {\n return {\n source: contribution.source,\n moduleUrl: contribution.moduleUrl,\n skills: contribution.skills.map((skill) => ({ ...skill })),\n };\n}\n\nfunction cloneState(state: HelpRuntimeState): HelpRuntimeState {\n return {\n activation: state.activation,\n skills: state.skills.map((skill) => ({ ...skill })),\n diagnostics: state.diagnostics.map((diagnostic) => ({ ...diagnostic })),\n };\n}\n\nfunction diagnostic(source: string, code: string, error: unknown): DoomHelpDiagnostic {\n const raw = error instanceof Error ? error.message : String(error);\n const message = (raw || 'Unknown Help activation failure.').slice(0, DOOM_HELP_MAX_DIAGNOSTIC_LENGTH);\n return { source, code, message };\n}\n\nfunction contributionFingerprint(contributions: readonly DoomHelpContribution[]): string {\n return JSON.stringify(\n contributions.map((contribution) => ({\n source: contribution.source,\n moduleUrl: contribution.moduleUrl,\n skills: contribution.skills,\n })),\n );\n}\n\nexport class DefaultHelpActivationService implements HelpActivationService {\n private readonly dependencies: HelpActivationDependencies;\n private readonly listeners = new Set<(state: HelpRuntimeState) => void>();\n private contributions: DoomHelpContribution[] = [];\n private fingerprint = '[]';\n private state: HelpRuntimeState = { activation: 'inactive', skills: [], diagnostics: [] };\n private settledState: HelpRuntimeState = { activation: 'inactive', skills: [], diagnostics: [] };\n private generation = 0;\n private controller: AbortController | undefined;\n private disposed = false;\n\n constructor(dependencies: HelpActivationDependencies) {\n this.dependencies = dependencies;\n }\n\n getState(): HelpRuntimeState {\n return cloneState(this.state);\n }\n\n replaceContributions(contributions: readonly DoomHelpContribution[]): void {\n if (this.disposed) return;\n const next = contributions.map(cloneContribution).sort((left, right) => left.source.localeCompare(right.source));\n const fingerprint = contributionFingerprint(next);\n if (fingerprint === this.fingerprint) return;\n const previous = new Map(this.contributions.map((entry) => [entry.source, contributionFingerprint([entry])]));\n const retained = new Set(\n next\n .filter((entry) => previous.get(entry.source) === contributionFingerprint([entry]))\n .map((entry) => entry.source),\n );\n // A refresh may retain unchanged owners, never withdrawn or replaced ones.\n // Prune the rollback snapshot too, so cancellation cannot resurrect them.\n const skills = this.settledState.skills.filter((entry) => retained.has(entry.source));\n const diagnostics = this.settledState.diagnostics.filter((entry) => !entry.source || retained.has(entry.source));\n this.settledState = {\n activation: skills.length === 0 ? 'inactive' : diagnostics.length > 0 ? 'degraded' : 'active',\n skills,\n diagnostics,\n };\n this.contributions = next;\n this.fingerprint = fingerprint;\n if (this.state.activation !== 'inactive') {\n void this.activate().catch((error: unknown) => {\n // Activation failures publish a bounded settled state before rejecting.\n // Only unexpected implementation failures need an out-of-band report.\n if (error instanceof HelpActivationError) return;\n this.dependencies.onBackgroundError(error);\n });\n }\n }\n\n subscribe(listener: (state: HelpRuntimeState) => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n private publish(state: HelpRuntimeState): HelpRuntimeState {\n this.state = cloneState(state);\n if (state.activation !== 'activating') this.settledState = cloneState(state);\n this.dependencies.publisher.publish(this.state);\n for (const listener of this.listeners) listener(cloneState(this.state));\n return this.getState();\n }\n\n private async loadSources(signal: AbortSignal): Promise<SourceOutcome[]> {\n const contributions = this.contributions;\n const outcomes: SourceOutcome[] = Array.from({ length: contributions.length });\n let cursor = 0;\n const worker = async (): Promise<void> => {\n while (cursor < contributions.length) {\n const index = cursor;\n cursor += 1;\n const contribution = contributions[index];\n if (!contribution) return;\n if (signal.aborted) throw new HelpActivationError(CANCELLATION_MESSAGE);\n try {\n const resolved = await this.dependencies.resolver.resolve(contribution, signal);\n if (signal.aborted) throw new HelpActivationError(CANCELLATION_MESSAGE);\n const skills = await this.dependencies.materializer.materialize(contribution, resolved, signal);\n outcomes[index] = { source: contribution.source, loaded: { contribution, index: resolved, skills } };\n } catch (error) {\n if (signal.aborted) throw new HelpActivationError(CANCELLATION_MESSAGE);\n outcomes[index] = { source: contribution.source, error };\n }\n }\n };\n const count = Math.min(MAX_RESOLUTION_CONCURRENCY, contributions.length);\n await Promise.all(Array.from({ length: count }, () => worker()));\n return outcomes;\n }\n\n async activate(externalSignal?: AbortSignal): Promise<HelpRuntimeState> {\n if (this.disposed) throw new HelpActivationError('Help runtime is disposed.');\n this.controller?.abort('Help activation generation replaced.');\n const controller = new AbortController();\n this.controller = controller;\n const generation = ++this.generation;\n const abortFromExternal = () => controller.abort(externalSignal?.reason);\n externalSignal?.addEventListener('abort', abortFromExternal, { once: true });\n if (externalSignal?.aborted) abortFromExternal();\n\n const settledState = cloneState(this.settledState);\n this.publish({ activation: 'activating', skills: settledState.skills, diagnostics: settledState.diagnostics });\n try {\n const outcomes = await this.loadSources(controller.signal);\n if (controller.signal.aborted || generation !== this.generation) {\n throw new HelpActivationError(CANCELLATION_MESSAGE);\n }\n\n const diagnostics: DoomHelpDiagnostic[] = [];\n const loaded: LoadedSource[] = [];\n let aggregateBytes = 0;\n for (const outcome of outcomes) {\n if (!outcome) continue;\n if (outcome.error || !outcome.loaded) {\n diagnostics.push(diagnostic(outcome.source, 'HELP_SOURCE_FAILED', outcome.error));\n continue;\n }\n if (aggregateBytes + outcome.loaded.index.byteLength > MAX_AGGREGATE_LLMS_BYTES) {\n diagnostics.push(\n diagnostic(outcome.source, 'HELP_AGGREGATE_LIMIT', 'The aggregate llms.txt byte limit was exceeded.'),\n );\n continue;\n }\n aggregateBytes += outcome.loaded.index.byteLength;\n loaded.push(outcome.loaded);\n }\n\n const skills: DoomHelpSkill[] = [];\n const names = new Set<string>();\n for (const source of loaded) {\n for (const skill of source.skills) {\n if (skills.length >= DOOM_HELP_MAX_SKILLS) {\n diagnostics.push(\n diagnostic(source.contribution.source, 'HELP_SKILL_LIMIT', 'The Help skill limit was reached.'),\n );\n break;\n }\n if (names.has(skill.name)) {\n diagnostics.push(\n diagnostic(\n source.contribution.source,\n 'HELP_SKILL_COLLISION',\n `Help skill '${skill.name}' was already provided by an earlier package source.`,\n ),\n );\n continue;\n }\n names.add(skill.name);\n skills.push({ ...skill });\n }\n }\n\n const boundedDiagnostics = diagnostics.slice(0, DOOM_HELP_MAX_DIAGNOSTICS);\n if (skills.length === 0) {\n this.publish({ activation: 'inactive', skills: [], diagnostics: boundedDiagnostics });\n throw new HelpActivationError();\n }\n return this.publish({\n activation: boundedDiagnostics.length > 0 ? 'degraded' : 'active',\n skills,\n diagnostics: boundedDiagnostics,\n });\n } catch (error) {\n if (generation === this.generation && this.state.activation === 'activating') this.publish(settledState);\n throw error;\n } finally {\n externalSignal?.removeEventListener('abort', abortFromExternal);\n if (this.controller === controller) this.controller = undefined;\n }\n }\n\n deactivate(): HelpRuntimeState {\n this.generation += 1;\n this.controller?.abort('Help deactivated.');\n this.controller = undefined;\n return this.publish({ activation: 'inactive', skills: [], diagnostics: [] });\n }\n\n dispose(): void {\n if (this.disposed) return;\n this.deactivate();\n this.disposed = true;\n this.listeners.clear();\n }\n}\n","import { createHash, randomUUID } from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { DoomHelpContribution, DoomHelpSkill } from '@agimon-ai/po-core/help';\nimport { poHomeDirectory } from '@agimon-ai/po-core/piSettings';\n\nimport type { HelpPackageIdentity, HelpSkillMaterializer, ResolvedHelpIndex } from '../../types/help';\nimport { renderHelpSkillWrapper } from '../llmsContent';\n\nconst PACKAGE_MANIFEST = 'package.json';\nconst HELP_INDEX_PATH = 'llms.txt';\nconst CACHE_SCHEMA_VERSION = 1;\nconst PRIVATE_FILE_MODE = 0o600;\nconst PRIVATE_DIRECTORY_MODE = 0o700;\nconst COMPLETION_FILE = '.complete';\nconst CACHE_METADATA_FILE = 'metadata.json';\nconst WRAPPER_DIRECTORY = 'wrappers';\nconst SKILL_FILE = 'SKILL.md';\nconst EXACT_SEMVER_PATTERN =\n /^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/u;\nconst NPM_PACKAGE_NAME_PATTERN = /^(?:@[a-z0-9][a-z0-9._~-]*\\/)?[a-z0-9][a-z0-9._~-]*$/u;\n\ninterface CacheMetadata {\n schemaVersion: typeof CACHE_SCHEMA_VERSION;\n source: string;\n version: string;\n path: typeof HELP_INDEX_PATH;\n integrity: string;\n digest: string;\n referenceBase: string;\n}\n\nexport interface CachedHelpIndex {\n bytes: Uint8Array;\n filePath: string;\n integrity: string;\n digest: string;\n referenceBase: string;\n}\n\nfunction assertNotAborted(signal: AbortSignal): void {\n if (signal.aborted) throw new Error('Help activation was cancelled.');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isContained(root: string, candidate: string): boolean {\n const relative = path.relative(root, candidate);\n return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));\n}\n\nfunction readManifest(filePath: string): Record<string, unknown> {\n let parsed: unknown;\n try {\n parsed = JSON.parse(fs.readFileSync(filePath, 'utf8')) as unknown;\n } catch (error) {\n throw new Error(\n `Cannot read Help package manifest at ${filePath}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n if (!isRecord(parsed)) throw new Error(`Help package manifest at ${filePath} must contain an object.`);\n return parsed;\n}\n\nexport function resolveHelpPackageIdentity(moduleUrl: string, expectedSource: string): HelpPackageIdentity {\n if (!NPM_PACKAGE_NAME_PATTERN.test(expectedSource)) {\n throw new Error(`Help source '${expectedSource}' must be a valid lowercase npm package name.`);\n }\n let modulePath: string;\n try {\n const url = new URL(moduleUrl);\n if (url.protocol !== 'file:') throw new Error(`Help module URL must use file:, received ${url.protocol}`);\n modulePath = fs.realpathSync(fileURLToPath(url));\n } catch (error) {\n throw new Error(\n `Invalid Help contributor module URL '${moduleUrl}': ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n if (!fs.lstatSync(modulePath).isFile())\n throw new Error(`Help contributor module is not a regular file: ${modulePath}`);\n\n let directory = path.dirname(modulePath);\n while (true) {\n const manifestPath = path.join(directory, PACKAGE_MANIFEST);\n if (fs.existsSync(manifestPath)) {\n const manifest = readManifest(manifestPath);\n const source = manifest.name;\n const version = manifest.version;\n if (source !== expectedSource) {\n throw new Error(`Help source '${expectedSource}' does not match nearest package '${String(source)}'.`);\n }\n if (typeof version !== 'string' || !EXACT_SEMVER_PATTERN.test(version)) {\n throw new Error(`Help package '${expectedSource}' must declare an exact semantic version.`);\n }\n const packageRoot = fs.realpathSync(directory);\n if (!isContained(packageRoot, modulePath))\n throw new Error('Help contributor module escapes its resolved package root.');\n return { source: expectedSource, version, packageRoot, modulePath };\n }\n const parent = path.dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n throw new Error(`Cannot find a package manifest for Help contributor ${modulePath}.`);\n}\n\nexport function defaultHelpCacheRoot(homeDirectory = os.homedir()): string {\n return path.join(poHomeDirectory(homeDirectory), 'llms-cache');\n}\n\nexport function sha256Hex(bytes: Uint8Array | string): string {\n return createHash('sha256').update(bytes).digest('hex');\n}\n\nfunction parseCacheMetadata(value: unknown, identity: HelpPackageIdentity): CacheMetadata | undefined {\n if (!isRecord(value)) return undefined;\n if (\n value.schemaVersion !== CACHE_SCHEMA_VERSION ||\n value.source !== identity.source ||\n value.version !== identity.version ||\n value.path !== HELP_INDEX_PATH ||\n typeof value.integrity !== 'string' ||\n typeof value.digest !== 'string' ||\n typeof value.referenceBase !== 'string'\n ) {\n return undefined;\n }\n return value as unknown as CacheMetadata;\n}\n\nfunction regularFile(filePath: string): boolean {\n try {\n const metadata = fs.lstatSync(filePath);\n return metadata.isFile() && !metadata.isSymbolicLink();\n } catch {\n return false;\n }\n}\n\nexport class HelpIndexCache {\n readonly root: string;\n\n constructor(root = defaultHelpCacheRoot()) {\n this.root = root;\n }\n\n entryDirectory(identity: HelpPackageIdentity): string {\n const key = sha256Hex(`${identity.source}\\0${identity.version}\\0${HELP_INDEX_PATH}`);\n return path.join(this.root, key);\n }\n\n discard(identity: HelpPackageIdentity): void {\n fs.rmSync(this.entryDirectory(identity), { recursive: true, force: true });\n }\n\n read(identity: HelpPackageIdentity): CachedHelpIndex | undefined {\n const directory = this.entryDirectory(identity);\n const completionPath = path.join(directory, COMPLETION_FILE);\n const indexPath = path.join(directory, HELP_INDEX_PATH);\n const metadataPath = path.join(directory, CACHE_METADATA_FILE);\n if (!regularFile(completionPath) || !regularFile(indexPath) || !regularFile(metadataPath)) return undefined;\n try {\n const metadata = parseCacheMetadata(JSON.parse(fs.readFileSync(metadataPath, 'utf8')) as unknown, identity);\n if (!metadata) return undefined;\n const bytes = fs.readFileSync(indexPath);\n if (sha256Hex(bytes) !== metadata.digest) return undefined;\n if (fs.readFileSync(completionPath, 'utf8').trim() !== metadata.digest) return undefined;\n return {\n bytes,\n filePath: indexPath,\n integrity: metadata.integrity,\n digest: metadata.digest,\n referenceBase: metadata.referenceBase,\n };\n } catch {\n return undefined;\n }\n }\n\n publish(\n identity: HelpPackageIdentity,\n bytes: Uint8Array,\n integrity: string,\n referenceBase: string,\n signal: AbortSignal,\n ): CachedHelpIndex {\n assertNotAborted(signal);\n const existing = this.read(identity);\n if (existing) return existing;\n const directory = this.entryDirectory(identity);\n fs.mkdirSync(this.root, { mode: PRIVATE_DIRECTORY_MODE, recursive: true });\n if (fs.existsSync(directory)) fs.rmSync(directory, { recursive: true, force: true });\n const temporary = `${directory}.${process.pid}.${randomUUID()}.tmp`;\n const digest = sha256Hex(bytes);\n const metadata: CacheMetadata = {\n schemaVersion: CACHE_SCHEMA_VERSION,\n source: identity.source,\n version: identity.version,\n path: HELP_INDEX_PATH,\n integrity,\n digest,\n referenceBase,\n };\n try {\n fs.mkdirSync(temporary, { mode: PRIVATE_DIRECTORY_MODE });\n fs.writeFileSync(path.join(temporary, HELP_INDEX_PATH), bytes, { mode: PRIVATE_FILE_MODE });\n fs.writeFileSync(path.join(temporary, CACHE_METADATA_FILE), `${JSON.stringify(metadata, null, 2)}\\n`, {\n mode: PRIVATE_FILE_MODE,\n });\n assertNotAborted(signal);\n fs.writeFileSync(path.join(temporary, COMPLETION_FILE), `${digest}\\n`, { mode: PRIVATE_FILE_MODE });\n try {\n fs.renameSync(temporary, directory);\n } catch (error) {\n const winner = this.read(identity);\n if (winner) return winner;\n throw error;\n }\n return {\n bytes: Uint8Array.from(bytes),\n filePath: path.join(directory, HELP_INDEX_PATH),\n integrity,\n digest,\n referenceBase,\n };\n } finally {\n fs.rmSync(temporary, { recursive: true, force: true });\n }\n }\n}\n\nexport class DefaultHelpSkillMaterializer implements HelpSkillMaterializer {\n constructor(private readonly cacheRoot = defaultHelpCacheRoot()) {}\n\n async materialize(\n contribution: DoomHelpContribution,\n index: ResolvedHelpIndex,\n signal: AbortSignal,\n ): Promise<readonly DoomHelpSkill[]> {\n const skills: DoomHelpSkill[] = [];\n for (const descriptor of contribution.skills) {\n assertNotAborted(signal);\n const key = sha256Hex(\n `${index.identity.source}\\0${index.identity.version}\\0${descriptor.name}\\0${descriptor.description}\\0${index.digest}`,\n );\n const directory = path.join(this.cacheRoot, WRAPPER_DIRECTORY, key);\n const filePath = path.join(directory, SKILL_FILE);\n const content = renderHelpSkillWrapper(descriptor, index);\n if (!regularFile(filePath) || fs.readFileSync(filePath, 'utf8') !== content) {\n fs.mkdirSync(path.dirname(directory), { mode: PRIVATE_DIRECTORY_MODE, recursive: true });\n if (fs.existsSync(directory)) fs.rmSync(directory, { recursive: true, force: true });\n const temporary = `${directory}.${process.pid}.${randomUUID()}.tmp`;\n try {\n fs.mkdirSync(temporary, { mode: PRIVATE_DIRECTORY_MODE });\n fs.writeFileSync(path.join(temporary, SKILL_FILE), content, { mode: PRIVATE_FILE_MODE });\n assertNotAborted(signal);\n try {\n fs.renameSync(temporary, directory);\n } catch (error) {\n if (!regularFile(filePath) || fs.readFileSync(filePath, 'utf8') !== content) throw error;\n }\n } finally {\n fs.rmSync(temporary, { recursive: true, force: true });\n }\n }\n skills.push({\n source: contribution.source,\n name: descriptor.name,\n description: descriptor.description,\n filePath,\n baseDir: directory,\n });\n }\n return skills;\n }\n}\n","import { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { DoomHelpContribution } from '@agimon-ai/po-core/help';\n\nimport type { HelpFetch, HelpFetchResponse, HelpIndexResolver, ResolvedHelpIndex } from '../../types/help';\nimport { HelpIndexCache, resolveHelpPackageIdentity, sha256Hex } from '../helpStorage';\nimport { MAX_LLMS_BYTES, validateLlmsBytes } from '../llmsContent';\n\nconst HELP_INDEX_PATH = 'llms.txt';\nconst UNPKG_ORIGIN = 'https://unpkg.com';\nconst DEFAULT_FETCH_TIMEOUT_MS = 5_000;\nconst MAX_METADATA_BYTES = 512 * 1024;\nconst MAX_REDIRECTS = 3;\nconst SRI_PATTERN = /^sha256-([A-Za-z0-9+/]+={0,2})$/u;\n\ninterface UnpkgMetadataFile {\n path: string;\n size?: number;\n integrity: string;\n}\n\nexport interface DefaultHelpIndexResolverOptions {\n cache?: HelpIndexCache;\n fetch?: HelpFetch;\n timeoutMs?: number;\n}\n\nfunction defaultFetch(input: string, init: { signal: AbortSignal; redirect: 'manual' }): Promise<HelpFetchResponse> {\n return fetch(input, init) as unknown as Promise<HelpFetchResponse>;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isRegularFile(filePath: string): boolean {\n try {\n const metadata = fs.lstatSync(filePath);\n return metadata.isFile() && !metadata.isSymbolicLink();\n } catch {\n return false;\n }\n}\n\nfunction unpkgPackagePath(source: string, version: string): string {\n const encoded = source\n .split('/')\n .map((segment) =>\n segment.startsWith('@') ? `@${encodeURIComponent(segment.slice(1))}` : encodeURIComponent(segment),\n )\n .join('/');\n return `${encoded}@${encodeURIComponent(version)}`;\n}\n\nfunction exactUnpkgBase(source: string, version: string): string {\n return `${UNPKG_ORIGIN}/${unpkgPackagePath(source, version)}/`;\n}\n\nfunction contentLength(response: HelpFetchResponse): number | undefined {\n const raw = response.headers.get('content-length');\n if (!raw) return undefined;\n const parsed = Number.parseInt(raw, 10);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : undefined;\n}\n\nfunction timeoutSignal(parent: AbortSignal, timeoutMs: number): { signal: AbortSignal; dispose(): void } {\n const controller = new AbortController();\n const abort = () => controller.abort(parent.reason);\n parent.addEventListener('abort', abort, { once: true });\n const timer = setTimeout(() => controller.abort(new Error('Help download timed out.')), timeoutMs);\n if (parent.aborted) abort();\n return {\n signal: controller.signal,\n dispose() {\n clearTimeout(timer);\n parent.removeEventListener('abort', abort);\n },\n };\n}\n\nasync function fetchExact(fetcher: HelpFetch, initialUrl: string, signal: AbortSignal): Promise<HelpFetchResponse> {\n let url = initialUrl;\n const expected = new URL(initialUrl);\n for (let redirect = 0; redirect <= MAX_REDIRECTS; redirect += 1) {\n const response = await fetcher(url, { signal, redirect: 'manual' });\n if (response.status < 300 || response.status >= 400) return response;\n const location = response.headers.get('location');\n if (!location) throw new Error(`Unpkg redirected ${url} without a location.`);\n const next = new URL(location, url);\n if (next.origin !== UNPKG_ORIGIN || next.pathname !== expected.pathname || next.search !== expected.search) {\n throw new Error(`Unpkg redirect escaped the exact package/version path: ${next.href}`);\n }\n url = next.href;\n }\n throw new Error(`Unpkg exceeded ${MAX_REDIRECTS} redirects.`);\n}\n\nfunction parseMetadata(text: string): UnpkgMetadataFile {\n let parsed: unknown;\n try {\n parsed = JSON.parse(text) as unknown;\n } catch {\n throw new Error('Unpkg metadata is not valid JSON.');\n }\n if (!isRecord(parsed) || !Array.isArray(parsed.files)) throw new Error('Unpkg metadata has no files list.');\n const match = parsed.files.find((entry) => isRecord(entry) && entry.path === `/${HELP_INDEX_PATH}`);\n if (!isRecord(match) || typeof match.integrity !== 'string') {\n throw new Error(`Unpkg package does not publish /${HELP_INDEX_PATH}.`);\n }\n const size = typeof match.size === 'number' ? match.size : undefined;\n if (size !== undefined && (!Number.isSafeInteger(size) || size < 0 || size > MAX_LLMS_BYTES)) {\n throw new Error(`Unpkg /${HELP_INDEX_PATH} exceeds the Help size limit.`);\n }\n if (!SRI_PATTERN.test(match.integrity)) throw new Error('Unpkg llms.txt metadata does not contain SHA-256 SRI.');\n return { path: match.path as string, ...(size === undefined ? {} : { size }), integrity: match.integrity };\n}\n\nfunction verifySri(bytes: Uint8Array, integrity: string): void {\n const expected = SRI_PATTERN.exec(integrity)?.[1];\n if (!expected) throw new Error('Invalid llms.txt SRI metadata.');\n const actual = createHash('sha256').update(bytes).digest('base64');\n if (actual !== expected) throw new Error('Downloaded llms.txt failed SRI verification.');\n}\n\nexport class DefaultHelpIndexResolver implements HelpIndexResolver {\n private readonly cache: HelpIndexCache;\n private readonly fetcher: HelpFetch;\n private readonly timeoutMs: number;\n\n constructor(options: DefaultHelpIndexResolverOptions = {}) {\n this.cache = options.cache ?? new HelpIndexCache();\n this.fetcher = options.fetch ?? defaultFetch;\n this.timeoutMs = options.timeoutMs ?? DEFAULT_FETCH_TIMEOUT_MS;\n }\n\n async resolve(contribution: DoomHelpContribution, signal: AbortSignal): Promise<ResolvedHelpIndex> {\n if (signal.aborted) throw new Error('Help activation was cancelled.');\n const identity = resolveHelpPackageIdentity(contribution.moduleUrl, contribution.source);\n const localPath = path.join(identity.packageRoot, HELP_INDEX_PATH);\n if (fs.existsSync(localPath)) {\n if (!isRegularFile(localPath)) throw new Error(`Bundled ${HELP_INDEX_PATH} must be a regular file.`);\n const bytes = fs.readFileSync(localPath);\n validateLlmsBytes(bytes);\n return {\n identity,\n location: 'local',\n filePath: localPath,\n referenceBase: identity.packageRoot,\n byteLength: bytes.byteLength,\n digest: sha256Hex(bytes),\n };\n }\n\n const cached = this.cache.read(identity);\n if (cached) {\n try {\n validateLlmsBytes(cached.bytes);\n return {\n identity,\n location: 'cache',\n filePath: cached.filePath,\n referenceBase: cached.referenceBase,\n byteLength: cached.bytes.byteLength,\n digest: cached.digest,\n };\n } catch {\n this.cache.discard(identity);\n }\n }\n\n const timed = timeoutSignal(signal, this.timeoutMs);\n try {\n const referenceBase = exactUnpkgBase(identity.source, identity.version);\n const metadataResponse = await fetchExact(this.fetcher, `${referenceBase}?meta`, timed.signal);\n const metadataLength = contentLength(metadataResponse);\n if (metadataLength !== undefined && metadataLength > MAX_METADATA_BYTES) {\n throw new Error('Unpkg metadata exceeds the Help metadata size limit.');\n }\n if (!metadataResponse.ok) throw new Error(`Unpkg metadata request failed with HTTP ${metadataResponse.status}.`);\n const metadataText = await metadataResponse.text();\n if (Buffer.byteLength(metadataText, 'utf8') > MAX_METADATA_BYTES) {\n throw new Error('Unpkg metadata exceeds the Help metadata size limit.');\n }\n const metadata = parseMetadata(metadataText);\n const indexResponse = await fetchExact(this.fetcher, `${referenceBase}${HELP_INDEX_PATH}`, timed.signal);\n const indexLength = contentLength(indexResponse);\n if (indexLength !== undefined && indexLength > MAX_LLMS_BYTES) {\n throw new Error(`Downloaded ${HELP_INDEX_PATH} exceeds ${MAX_LLMS_BYTES} bytes.`);\n }\n if (!indexResponse.ok) throw new Error(`Unpkg llms.txt request failed with HTTP ${indexResponse.status}.`);\n const bytes = new Uint8Array(await indexResponse.arrayBuffer());\n validateLlmsBytes(bytes);\n verifySri(bytes, metadata.integrity);\n const published = this.cache.publish(identity, bytes, metadata.integrity, referenceBase, timed.signal);\n return {\n identity,\n location: 'remote',\n filePath: published.filePath,\n referenceBase: published.referenceBase,\n byteLength: published.bytes.byteLength,\n digest: published.digest,\n };\n } finally {\n timed.dispose();\n }\n }\n}\n","import type { DoomHelpContribution, DoomHelpService } from '@agimon-ai/po-core/help';\n\nimport type { HelpFetch } from '../../types/help';\nimport { DefaultHelpActivationService } from '../helpActivation';\nimport { DefaultHelpSkillMaterializer, defaultHelpCacheRoot, HelpIndexCache } from '../helpStorage';\nimport { DefaultHelpIndexResolver } from '../llmsResolver';\n\nexport interface HelpRuntimeOptions {\n cacheRoot?: string;\n fetch?: HelpFetch;\n timeoutMs?: number;\n onBackgroundError?(error: unknown): void;\n}\n\nexport interface HelpRuntimeComposition {\n activation: DefaultHelpActivationService;\n dispose(): void;\n}\n\nfunction reportAsync(error: unknown): void {\n queueMicrotask(() => {\n throw error instanceof Error ? error : new Error(String(error));\n });\n}\n\nexport function createHelpRuntime(service: DoomHelpService, options: HelpRuntimeOptions = {}): HelpRuntimeComposition {\n const cacheRoot = options.cacheRoot ?? defaultHelpCacheRoot();\n const cache = new HelpIndexCache(cacheRoot);\n const activation = new DefaultHelpActivationService({\n resolver: new DefaultHelpIndexResolver({ cache, fetch: options.fetch, timeoutMs: options.timeoutMs }),\n materializer: new DefaultHelpSkillMaterializer(cacheRoot),\n publisher: { publish: (snapshot) => service.publish(snapshot) },\n onBackgroundError(error) {\n if (options.onBackgroundError) options.onBackgroundError(error);\n else reportAsync(error);\n },\n });\n const synchronize = (contributions: readonly DoomHelpContribution[]): void => {\n activation.replaceContributions(contributions);\n };\n const unsubscribe = service.subscribeContributions((contributions) => synchronize(contributions));\n synchronize(service.listContributions());\n let disposed = false;\n return {\n activation,\n dispose() {\n if (disposed) return;\n disposed = true;\n unsubscribe();\n activation.dispose();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAa,iBAAiB;AAG9B,MAAM,wBAAwB;AAC9B,MAAM,kCAAkC;AACxC,MAAM,4BAA4B;AAClC,MAAM,oBAAoB;AAC1B,MAAM,qBAAqB;AAC3B,MAAM,+BAA+B;AACrC,MAAM,wCAAwB,IAAI,IAAI;CAAC;CAAS;CAAU;AAAS,CAAC;AAEpE,SAAS,eAAe,QAAoC;CAC1D,IAAI,CAAC,mBAAmB,KAAK,MAAM,GAAG,OAAO,KAAA;CAC7C,OAAO,OAAO,MAAM,GAAG,OAAO,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,YAAY;AAC9D;AAEA,SAAS,qBAAqB,WAA2B;CACvD,IAAI,UAAU;CACd,IAAI;EACF,KAAK,IAAI,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG;GACtC,MAAM,OAAO,mBAAmB,OAAO;GACvC,IAAI,SAAS,SAAS;GACtB,UAAU;EACZ;CACF,QAAQ;EACN,MAAM,IAAI,MAAM,8CAA8C,UAAU,GAAG;CAC7E;CACA,IAAI,6BAA6B,KAAK,OAAO,GAC3C,MAAM,IAAI,MAAM,wDAAwD,UAAU,GAAG;CAEv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E5D,MAAM,aAAa,IAAI,6BAA6B;EAClD,UAAU,IAAI,yBAAyB;GAAE,WAFzB,eAAe,SAEU;GAAO,OAAO,QAAQ;GAAO,WAAW,QAAQ;EAAU,CAAC;EACpG,cAAc,IAAI,6BAA6B,SAAS;EACxD,WAAW,EAAE,UAAU,aAAa,QAAQ,QAAQ,QAAQ,EAAE;EAC9D,kBAAkB,OAAO;GACvB,IAAI,QAAQ,mBAAmB,QAAQ,kBAAkB,KAAK;QACzD,YAAY,KAAK;EACxB;CACF,CAAC;CACD,MAAM,eAAe,kBAAyD;EAC5E,WAAW,qBAAqB,aAAa;CAC/C;CACA,MAAM,cAAc,QAAQ,wBAAwB,kBAAkB,YAAY,aAAa,CAAC;CAChG,YAAY,QAAQ,kBAAkB,CAAC;CACvC,IAAI,WAAW;CACf,OAAO;EACL;EACA,UAAU;GACR,IAAI,UAAU;GACd,WAAW;GACX,YAAY;GACZ,WAAW,QAAQ;EACrB;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["PO_HELP_MAX_DIAGNOSTIC_LENGTH","PO_HELP_MAX_SKILLS","PO_HELP_MAX_DIAGNOSTICS","HELP_INDEX_PATH","isRecord","path","fs","fileURLToPath","os","poHomeDirectory","createHash","randomUUID","fs","createHash","path"],"sources":["../src/services/llmsContent/index.ts","../src/services/helpActivation/index.ts","../src/services/helpStorage/index.ts","../src/services/llmsResolver/index.ts","../src/services/helpRuntime/index.ts"],"sourcesContent":["import type { PoHelpSkillDescriptor } from '@agimon-ai/po-core/help';\n\nimport type { ResolvedHelpIndex } from '../../types/help';\n\nexport const MAX_LLMS_BYTES = 1024 * 1024;\nexport const MAX_AGGREGATE_LLMS_BYTES = 4 * MAX_LLMS_BYTES;\n\nconst MARKDOWN_LINK_PATTERN = /!?\\[[^\\]]*\\]\\(\\s*<?([^\\s)>]+)>?(?:\\s+[^)]*)?\\)/gu;\nconst MARKDOWN_REFERENCE_LINK_PATTERN = /^\\s{0,3}\\[[^\\]\\r\\n]+\\]:\\s*<?([^\\s>]+)>?/gmu;\nconst MARKDOWN_AUTOLINK_PATTERN = /<((?:\\.{0,2}\\/|[A-Za-z][A-Za-z0-9+.-]*:)[^<>\\s]+)>/gu;\nconst HTML_LINK_PATTERN = /\\b(?:href|src)\\s*=\\s*[\"']([^\"']+)[\"']/giu;\nconst URI_SCHEME_PATTERN = /^[a-z][a-z0-9+.-]*:/iu;\nconst NESTED_PATH_ENCODING_PATTERN = /%(?:25|2e|2f|3a|5c)/iu;\nconst SAFE_EXTERNAL_SCHEMES = new Set(['http:', 'https:', 'mailto:']);\n\nfunction externalScheme(target: string): string | undefined {\n if (!URI_SCHEME_PATTERN.test(target)) return undefined;\n return target.slice(0, target.indexOf(':') + 1).toLowerCase();\n}\n\nfunction decodeRelativeTarget(rawTarget: string): string {\n let decoded = rawTarget;\n try {\n for (let pass = 0; pass < 2; pass += 1) {\n const next = decodeURIComponent(decoded);\n if (next === decoded) break;\n decoded = next;\n }\n } catch {\n throw new Error(`llms.txt contains an invalid encoded link '${rawTarget}'.`);\n }\n if (NESTED_PATH_ENCODING_PATTERN.test(decoded)) {\n throw new Error(`llms.txt contains an unsafe nested encoding in link '${rawTarget}'.`);\n }\n return decoded;\n}\n\nfunction validateRelativeLink(rawTarget: string): void {\n if (!rawTarget || rawTarget.startsWith('#')) return;\n const rawScheme = externalScheme(rawTarget);\n if (rawScheme) {\n if (!SAFE_EXTERNAL_SCHEMES.has(rawScheme)) {\n throw new Error(`llms.txt contains unsupported link scheme '${rawScheme}'.`);\n }\n return;\n }\n\n const decoded = decodeRelativeTarget(rawTarget);\n const decodedScheme = externalScheme(decoded);\n if (decodedScheme) {\n if (!SAFE_EXTERNAL_SCHEMES.has(decodedScheme)) {\n throw new Error(`llms.txt contains unsupported link scheme '${decodedScheme}'.`);\n }\n return;\n }\n const withoutSuffix = decoded.split(/[?#]/u, 1)[0]?.replaceAll('\\\\', '/') ?? '';\n if (withoutSuffix.startsWith('/') || withoutSuffix.split('/').some((segment) => segment === '..')) {\n throw new Error(`llms.txt link '${rawTarget}' escapes the package root.`);\n }\n}\n\nfunction containsUnsafeControl(text: string): boolean {\n for (const character of text) {\n const code = character.codePointAt(0) ?? 0;\n if ((code >= 0 && code <= 8) || code === 11 || code === 12 || (code >= 14 && code <= 31) || code === 127) {\n return true;\n }\n }\n return false;\n}\n\nexport function validateLlmsBytes(bytes: Uint8Array): string {\n if (bytes.byteLength === 0) throw new Error('llms.txt is empty.');\n if (bytes.byteLength > MAX_LLMS_BYTES) throw new Error(`llms.txt exceeds ${MAX_LLMS_BYTES} bytes.`);\n\n let text: string;\n try {\n text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);\n } catch {\n throw new Error('llms.txt is not valid UTF-8.');\n }\n if (text.startsWith('\\uFEFF')) text = text.slice(1);\n if (containsUnsafeControl(text)) throw new Error('llms.txt contains unsafe control bytes.');\n\n const firstContentLine = text\n .split(/\\r?\\n/u)\n .find((line) => line.trim().length > 0)\n ?.trim();\n if (!firstContentLine || !/^#\\s+\\S/u.test(firstContentLine)) {\n throw new Error('llms.txt must begin with a Markdown H1 heading.');\n }\n for (const pattern of [\n MARKDOWN_LINK_PATTERN,\n MARKDOWN_REFERENCE_LINK_PATTERN,\n MARKDOWN_AUTOLINK_PATTERN,\n HTML_LINK_PATTERN,\n ]) {\n for (const match of text.matchAll(pattern)) validateRelativeLink(match[1] ?? '');\n }\n return text;\n}\n\nexport function renderHelpSkillWrapper(descriptor: PoHelpSkillDescriptor, index: ResolvedHelpIndex): string {\n const name = JSON.stringify(descriptor.name);\n const description = JSON.stringify(descriptor.description);\n const indexPath = JSON.stringify(index.filePath);\n const referenceBase = JSON.stringify(index.referenceBase);\n return `---\\nname: ${name}\\ndescription: ${description}\\n---\\n\\n# Package Help\\n\\nRead the validated package Help index at ${indexPath}.\\nResolve relative links in that index against ${referenceBase}.\\nOpen only the linked documents relevant to the current request, as needed; do not recursively load the whole reference set.\\n`;\n}\n","import {\n PO_HELP_MAX_DIAGNOSTIC_LENGTH,\n PO_HELP_MAX_DIAGNOSTICS,\n PO_HELP_MAX_SKILLS,\n type PoHelpContribution,\n type PoHelpDiagnostic,\n type PoHelpSkill,\n} from '@agimon-ai/po-core/help';\n\nimport type {\n HelpActivationDependencies,\n HelpActivationService,\n HelpRuntimeState,\n ResolvedHelpIndex,\n} from '../../types/help';\nimport { MAX_AGGREGATE_LLMS_BYTES } from '../llmsContent';\n\nconst MAX_RESOLUTION_CONCURRENCY = 4;\nconst FAILURE_MESSAGE = 'No package Help source could be activated.';\nconst CANCELLATION_MESSAGE = 'Help activation was cancelled.';\n\ninterface LoadedSource {\n contribution: PoHelpContribution;\n index: ResolvedHelpIndex;\n skills: readonly PoHelpSkill[];\n}\n\ninterface SourceOutcome {\n source: string;\n loaded?: LoadedSource;\n error?: unknown;\n}\n\nexport class HelpActivationError extends Error {\n constructor(message = FAILURE_MESSAGE) {\n super(message);\n this.name = 'HelpActivationError';\n }\n}\n\nfunction cloneContribution(contribution: PoHelpContribution): PoHelpContribution {\n return {\n source: contribution.source,\n moduleUrl: contribution.moduleUrl,\n skills: contribution.skills.map((skill) => ({ ...skill })),\n };\n}\n\nfunction cloneState(state: HelpRuntimeState): HelpRuntimeState {\n return {\n activation: state.activation,\n skills: state.skills.map((skill) => ({ ...skill })),\n diagnostics: state.diagnostics.map((diagnostic) => ({ ...diagnostic })),\n };\n}\n\nfunction diagnostic(source: string, code: string, error: unknown): PoHelpDiagnostic {\n const raw = error instanceof Error ? error.message : String(error);\n const message = (raw || 'Unknown Help activation failure.').slice(0, PO_HELP_MAX_DIAGNOSTIC_LENGTH);\n return { source, code, message };\n}\n\nfunction contributionFingerprint(contributions: readonly PoHelpContribution[]): string {\n return JSON.stringify(\n contributions.map((contribution) => ({\n source: contribution.source,\n moduleUrl: contribution.moduleUrl,\n skills: contribution.skills,\n })),\n );\n}\n\nexport class DefaultHelpActivationService implements HelpActivationService {\n private readonly dependencies: HelpActivationDependencies;\n private readonly listeners = new Set<(state: HelpRuntimeState) => void>();\n private contributions: PoHelpContribution[] = [];\n private fingerprint = '[]';\n private state: HelpRuntimeState = { activation: 'inactive', skills: [], diagnostics: [] };\n private settledState: HelpRuntimeState = { activation: 'inactive', skills: [], diagnostics: [] };\n private generation = 0;\n private controller: AbortController | undefined;\n private disposed = false;\n\n constructor(dependencies: HelpActivationDependencies) {\n this.dependencies = dependencies;\n }\n\n getState(): HelpRuntimeState {\n return cloneState(this.state);\n }\n\n replaceContributions(contributions: readonly PoHelpContribution[]): void {\n if (this.disposed) return;\n const next = contributions.map(cloneContribution).sort((left, right) => left.source.localeCompare(right.source));\n const fingerprint = contributionFingerprint(next);\n if (fingerprint === this.fingerprint) return;\n const previous = new Map(this.contributions.map((entry) => [entry.source, contributionFingerprint([entry])]));\n const retained = new Set(\n next\n .filter((entry) => previous.get(entry.source) === contributionFingerprint([entry]))\n .map((entry) => entry.source),\n );\n // A refresh may retain unchanged owners, never withdrawn or replaced ones.\n // Prune the rollback snapshot too, so cancellation cannot resurrect them.\n const skills = this.settledState.skills.filter((entry) => retained.has(entry.source));\n const diagnostics = this.settledState.diagnostics.filter((entry) => !entry.source || retained.has(entry.source));\n this.settledState = {\n activation: skills.length === 0 ? 'inactive' : diagnostics.length > 0 ? 'degraded' : 'active',\n skills,\n diagnostics,\n };\n this.contributions = next;\n this.fingerprint = fingerprint;\n if (this.state.activation !== 'inactive') {\n void this.activate().catch((error: unknown) => {\n // Activation failures publish a bounded settled state before rejecting.\n // Only unexpected implementation failures need an out-of-band report.\n if (error instanceof HelpActivationError) return;\n this.dependencies.onBackgroundError(error);\n });\n }\n }\n\n subscribe(listener: (state: HelpRuntimeState) => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n private publish(state: HelpRuntimeState): HelpRuntimeState {\n this.state = cloneState(state);\n if (state.activation !== 'activating') this.settledState = cloneState(state);\n this.dependencies.publisher.publish(this.state);\n for (const listener of this.listeners) listener(cloneState(this.state));\n return this.getState();\n }\n\n private async loadSources(signal: AbortSignal): Promise<SourceOutcome[]> {\n const contributions = this.contributions;\n const outcomes: SourceOutcome[] = Array.from({ length: contributions.length });\n let cursor = 0;\n const worker = async (): Promise<void> => {\n while (cursor < contributions.length) {\n const index = cursor;\n cursor += 1;\n const contribution = contributions[index];\n if (!contribution) return;\n if (signal.aborted) throw new HelpActivationError(CANCELLATION_MESSAGE);\n try {\n const resolved = await this.dependencies.resolver.resolve(contribution, signal);\n if (signal.aborted) throw new HelpActivationError(CANCELLATION_MESSAGE);\n const skills = await this.dependencies.materializer.materialize(contribution, resolved, signal);\n outcomes[index] = { source: contribution.source, loaded: { contribution, index: resolved, skills } };\n } catch (error) {\n if (signal.aborted) throw new HelpActivationError(CANCELLATION_MESSAGE);\n outcomes[index] = { source: contribution.source, error };\n }\n }\n };\n const count = Math.min(MAX_RESOLUTION_CONCURRENCY, contributions.length);\n await Promise.all(Array.from({ length: count }, () => worker()));\n return outcomes;\n }\n\n async activate(externalSignal?: AbortSignal): Promise<HelpRuntimeState> {\n if (this.disposed) throw new HelpActivationError('Help runtime is disposed.');\n this.controller?.abort('Help activation generation replaced.');\n const controller = new AbortController();\n this.controller = controller;\n const generation = ++this.generation;\n const abortFromExternal = () => controller.abort(externalSignal?.reason);\n externalSignal?.addEventListener('abort', abortFromExternal, { once: true });\n if (externalSignal?.aborted) abortFromExternal();\n\n const settledState = cloneState(this.settledState);\n this.publish({ activation: 'activating', skills: settledState.skills, diagnostics: settledState.diagnostics });\n try {\n const outcomes = await this.loadSources(controller.signal);\n if (controller.signal.aborted || generation !== this.generation) {\n throw new HelpActivationError(CANCELLATION_MESSAGE);\n }\n\n const diagnostics: PoHelpDiagnostic[] = [];\n const loaded: LoadedSource[] = [];\n let aggregateBytes = 0;\n for (const outcome of outcomes) {\n if (!outcome) continue;\n if (outcome.error || !outcome.loaded) {\n diagnostics.push(diagnostic(outcome.source, 'HELP_SOURCE_FAILED', outcome.error));\n continue;\n }\n if (aggregateBytes + outcome.loaded.index.byteLength > MAX_AGGREGATE_LLMS_BYTES) {\n diagnostics.push(\n diagnostic(outcome.source, 'HELP_AGGREGATE_LIMIT', 'The aggregate llms.txt byte limit was exceeded.'),\n );\n continue;\n }\n aggregateBytes += outcome.loaded.index.byteLength;\n loaded.push(outcome.loaded);\n }\n\n const skills: PoHelpSkill[] = [];\n const names = new Set<string>();\n for (const source of loaded) {\n for (const skill of source.skills) {\n if (skills.length >= PO_HELP_MAX_SKILLS) {\n diagnostics.push(\n diagnostic(source.contribution.source, 'HELP_SKILL_LIMIT', 'The Help skill limit was reached.'),\n );\n break;\n }\n if (names.has(skill.name)) {\n diagnostics.push(\n diagnostic(\n source.contribution.source,\n 'HELP_SKILL_COLLISION',\n `Help skill '${skill.name}' was already provided by an earlier package source.`,\n ),\n );\n continue;\n }\n names.add(skill.name);\n skills.push({ ...skill });\n }\n }\n\n const boundedDiagnostics = diagnostics.slice(0, PO_HELP_MAX_DIAGNOSTICS);\n if (skills.length === 0) {\n this.publish({ activation: 'inactive', skills: [], diagnostics: boundedDiagnostics });\n throw new HelpActivationError();\n }\n return this.publish({\n activation: boundedDiagnostics.length > 0 ? 'degraded' : 'active',\n skills,\n diagnostics: boundedDiagnostics,\n });\n } catch (error) {\n if (generation === this.generation && this.state.activation === 'activating') this.publish(settledState);\n throw error;\n } finally {\n externalSignal?.removeEventListener('abort', abortFromExternal);\n if (this.controller === controller) this.controller = undefined;\n }\n }\n\n deactivate(): HelpRuntimeState {\n this.generation += 1;\n this.controller?.abort('Help deactivated.');\n this.controller = undefined;\n return this.publish({ activation: 'inactive', skills: [], diagnostics: [] });\n }\n\n dispose(): void {\n if (this.disposed) return;\n this.deactivate();\n this.disposed = true;\n this.listeners.clear();\n }\n}\n","import { createHash, randomUUID } from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { PoHelpContribution, PoHelpSkill } from '@agimon-ai/po-core/help';\nimport { poHomeDirectory } from '@agimon-ai/po-core/piSettings';\n\nimport type { HelpPackageIdentity, HelpSkillMaterializer, ResolvedHelpIndex } from '../../types/help';\nimport { renderHelpSkillWrapper } from '../llmsContent';\n\nconst PACKAGE_MANIFEST = 'package.json';\nconst HELP_INDEX_PATH = 'llms.txt';\nconst CACHE_SCHEMA_VERSION = 1;\nconst PRIVATE_FILE_MODE = 0o600;\nconst PRIVATE_DIRECTORY_MODE = 0o700;\nconst COMPLETION_FILE = '.complete';\nconst CACHE_METADATA_FILE = 'metadata.json';\nconst WRAPPER_DIRECTORY = 'wrappers';\nconst SKILL_FILE = 'SKILL.md';\nconst EXACT_SEMVER_PATTERN =\n /^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/u;\nconst NPM_PACKAGE_NAME_PATTERN = /^(?:@[a-z0-9][a-z0-9._~-]*\\/)?[a-z0-9][a-z0-9._~-]*$/u;\n\ninterface CacheMetadata {\n schemaVersion: typeof CACHE_SCHEMA_VERSION;\n source: string;\n version: string;\n path: typeof HELP_INDEX_PATH;\n integrity: string;\n digest: string;\n referenceBase: string;\n}\n\nexport interface CachedHelpIndex {\n bytes: Uint8Array;\n filePath: string;\n integrity: string;\n digest: string;\n referenceBase: string;\n}\n\nfunction assertNotAborted(signal: AbortSignal): void {\n if (signal.aborted) throw new Error('Help activation was cancelled.');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isContained(root: string, candidate: string): boolean {\n const relative = path.relative(root, candidate);\n return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));\n}\n\nfunction readManifest(filePath: string): Record<string, unknown> {\n let parsed: unknown;\n try {\n parsed = JSON.parse(fs.readFileSync(filePath, 'utf8')) as unknown;\n } catch (error) {\n throw new Error(\n `Cannot read Help package manifest at ${filePath}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n if (!isRecord(parsed)) throw new Error(`Help package manifest at ${filePath} must contain an object.`);\n return parsed;\n}\n\nexport function resolveHelpPackageIdentity(moduleUrl: string, expectedSource: string): HelpPackageIdentity {\n if (!NPM_PACKAGE_NAME_PATTERN.test(expectedSource)) {\n throw new Error(`Help source '${expectedSource}' must be a valid lowercase npm package name.`);\n }\n let modulePath: string;\n try {\n const url = new URL(moduleUrl);\n if (url.protocol !== 'file:') throw new Error(`Help module URL must use file:, received ${url.protocol}`);\n modulePath = fs.realpathSync(fileURLToPath(url));\n } catch (error) {\n throw new Error(\n `Invalid Help contributor module URL '${moduleUrl}': ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n if (!fs.lstatSync(modulePath).isFile())\n throw new Error(`Help contributor module is not a regular file: ${modulePath}`);\n\n let directory = path.dirname(modulePath);\n while (true) {\n const manifestPath = path.join(directory, PACKAGE_MANIFEST);\n if (fs.existsSync(manifestPath)) {\n const manifest = readManifest(manifestPath);\n const source = manifest.name;\n const version = manifest.version;\n if (source !== expectedSource) {\n throw new Error(`Help source '${expectedSource}' does not match nearest package '${String(source)}'.`);\n }\n if (typeof version !== 'string' || !EXACT_SEMVER_PATTERN.test(version)) {\n throw new Error(`Help package '${expectedSource}' must declare an exact semantic version.`);\n }\n const packageRoot = fs.realpathSync(directory);\n if (!isContained(packageRoot, modulePath))\n throw new Error('Help contributor module escapes its resolved package root.');\n return { source: expectedSource, version, packageRoot, modulePath };\n }\n const parent = path.dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n throw new Error(`Cannot find a package manifest for Help contributor ${modulePath}.`);\n}\n\nexport function defaultHelpCacheRoot(homeDirectory = os.homedir()): string {\n return path.join(poHomeDirectory(homeDirectory), 'llms-cache');\n}\n\nexport function sha256Hex(bytes: Uint8Array | string): string {\n return createHash('sha256').update(bytes).digest('hex');\n}\n\nfunction parseCacheMetadata(value: unknown, identity: HelpPackageIdentity): CacheMetadata | undefined {\n if (!isRecord(value)) return undefined;\n if (\n value.schemaVersion !== CACHE_SCHEMA_VERSION ||\n value.source !== identity.source ||\n value.version !== identity.version ||\n value.path !== HELP_INDEX_PATH ||\n typeof value.integrity !== 'string' ||\n typeof value.digest !== 'string' ||\n typeof value.referenceBase !== 'string'\n ) {\n return undefined;\n }\n return value as unknown as CacheMetadata;\n}\n\nfunction regularFile(filePath: string): boolean {\n try {\n const metadata = fs.lstatSync(filePath);\n return metadata.isFile() && !metadata.isSymbolicLink();\n } catch {\n return false;\n }\n}\n\nexport class HelpIndexCache {\n readonly root: string;\n\n constructor(root = defaultHelpCacheRoot()) {\n this.root = root;\n }\n\n entryDirectory(identity: HelpPackageIdentity): string {\n const key = sha256Hex(`${identity.source}\\0${identity.version}\\0${HELP_INDEX_PATH}`);\n return path.join(this.root, key);\n }\n\n discard(identity: HelpPackageIdentity): void {\n fs.rmSync(this.entryDirectory(identity), { recursive: true, force: true });\n }\n\n read(identity: HelpPackageIdentity): CachedHelpIndex | undefined {\n const directory = this.entryDirectory(identity);\n const completionPath = path.join(directory, COMPLETION_FILE);\n const indexPath = path.join(directory, HELP_INDEX_PATH);\n const metadataPath = path.join(directory, CACHE_METADATA_FILE);\n if (!regularFile(completionPath) || !regularFile(indexPath) || !regularFile(metadataPath)) return undefined;\n try {\n const metadata = parseCacheMetadata(JSON.parse(fs.readFileSync(metadataPath, 'utf8')) as unknown, identity);\n if (!metadata) return undefined;\n const bytes = fs.readFileSync(indexPath);\n if (sha256Hex(bytes) !== metadata.digest) return undefined;\n if (fs.readFileSync(completionPath, 'utf8').trim() !== metadata.digest) return undefined;\n return {\n bytes,\n filePath: indexPath,\n integrity: metadata.integrity,\n digest: metadata.digest,\n referenceBase: metadata.referenceBase,\n };\n } catch {\n return undefined;\n }\n }\n\n publish(\n identity: HelpPackageIdentity,\n bytes: Uint8Array,\n integrity: string,\n referenceBase: string,\n signal: AbortSignal,\n ): CachedHelpIndex {\n assertNotAborted(signal);\n const existing = this.read(identity);\n if (existing) return existing;\n const directory = this.entryDirectory(identity);\n fs.mkdirSync(this.root, { mode: PRIVATE_DIRECTORY_MODE, recursive: true });\n if (fs.existsSync(directory)) fs.rmSync(directory, { recursive: true, force: true });\n const temporary = `${directory}.${process.pid}.${randomUUID()}.tmp`;\n const digest = sha256Hex(bytes);\n const metadata: CacheMetadata = {\n schemaVersion: CACHE_SCHEMA_VERSION,\n source: identity.source,\n version: identity.version,\n path: HELP_INDEX_PATH,\n integrity,\n digest,\n referenceBase,\n };\n try {\n fs.mkdirSync(temporary, { mode: PRIVATE_DIRECTORY_MODE });\n fs.writeFileSync(path.join(temporary, HELP_INDEX_PATH), bytes, { mode: PRIVATE_FILE_MODE });\n fs.writeFileSync(path.join(temporary, CACHE_METADATA_FILE), `${JSON.stringify(metadata, null, 2)}\\n`, {\n mode: PRIVATE_FILE_MODE,\n });\n assertNotAborted(signal);\n fs.writeFileSync(path.join(temporary, COMPLETION_FILE), `${digest}\\n`, { mode: PRIVATE_FILE_MODE });\n try {\n fs.renameSync(temporary, directory);\n } catch (error) {\n const winner = this.read(identity);\n if (winner) return winner;\n throw error;\n }\n return {\n bytes: Uint8Array.from(bytes),\n filePath: path.join(directory, HELP_INDEX_PATH),\n integrity,\n digest,\n referenceBase,\n };\n } finally {\n fs.rmSync(temporary, { recursive: true, force: true });\n }\n }\n}\n\nexport class DefaultHelpSkillMaterializer implements HelpSkillMaterializer {\n constructor(private readonly cacheRoot = defaultHelpCacheRoot()) {}\n\n async materialize(\n contribution: PoHelpContribution,\n index: ResolvedHelpIndex,\n signal: AbortSignal,\n ): Promise<readonly PoHelpSkill[]> {\n const skills: PoHelpSkill[] = [];\n for (const descriptor of contribution.skills) {\n assertNotAborted(signal);\n const key = sha256Hex(\n `${index.identity.source}\\0${index.identity.version}\\0${descriptor.name}\\0${descriptor.description}\\0${index.digest}`,\n );\n const directory = path.join(this.cacheRoot, WRAPPER_DIRECTORY, key);\n const filePath = path.join(directory, SKILL_FILE);\n const content = renderHelpSkillWrapper(descriptor, index);\n if (!regularFile(filePath) || fs.readFileSync(filePath, 'utf8') !== content) {\n fs.mkdirSync(path.dirname(directory), { mode: PRIVATE_DIRECTORY_MODE, recursive: true });\n if (fs.existsSync(directory)) fs.rmSync(directory, { recursive: true, force: true });\n const temporary = `${directory}.${process.pid}.${randomUUID()}.tmp`;\n try {\n fs.mkdirSync(temporary, { mode: PRIVATE_DIRECTORY_MODE });\n fs.writeFileSync(path.join(temporary, SKILL_FILE), content, { mode: PRIVATE_FILE_MODE });\n assertNotAborted(signal);\n try {\n fs.renameSync(temporary, directory);\n } catch (error) {\n if (!regularFile(filePath) || fs.readFileSync(filePath, 'utf8') !== content) throw error;\n }\n } finally {\n fs.rmSync(temporary, { recursive: true, force: true });\n }\n }\n skills.push({\n source: contribution.source,\n name: descriptor.name,\n description: descriptor.description,\n filePath,\n baseDir: directory,\n });\n }\n return skills;\n }\n}\n","import { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { PoHelpContribution } from '@agimon-ai/po-core/help';\n\nimport type { HelpFetch, HelpFetchResponse, HelpIndexResolver, ResolvedHelpIndex } from '../../types/help';\nimport { HelpIndexCache, resolveHelpPackageIdentity, sha256Hex } from '../helpStorage';\nimport { MAX_LLMS_BYTES, validateLlmsBytes } from '../llmsContent';\n\nconst HELP_INDEX_PATH = 'llms.txt';\nconst UNPKG_ORIGIN = 'https://unpkg.com';\nconst DEFAULT_FETCH_TIMEOUT_MS = 5_000;\nconst MAX_METADATA_BYTES = 512 * 1024;\nconst MAX_REDIRECTS = 3;\nconst SRI_PATTERN = /^sha256-([A-Za-z0-9+/]+={0,2})$/u;\n\ninterface UnpkgMetadataFile {\n path: string;\n size?: number;\n integrity: string;\n}\n\nexport interface DefaultHelpIndexResolverOptions {\n cache?: HelpIndexCache;\n fetch?: HelpFetch;\n timeoutMs?: number;\n}\n\nfunction defaultFetch(input: string, init: { signal: AbortSignal; redirect: 'manual' }): Promise<HelpFetchResponse> {\n return fetch(input, init) as unknown as Promise<HelpFetchResponse>;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isRegularFile(filePath: string): boolean {\n try {\n const metadata = fs.lstatSync(filePath);\n return metadata.isFile() && !metadata.isSymbolicLink();\n } catch {\n return false;\n }\n}\n\nfunction unpkgPackagePath(source: string, version: string): string {\n const encoded = source\n .split('/')\n .map((segment) =>\n segment.startsWith('@') ? `@${encodeURIComponent(segment.slice(1))}` : encodeURIComponent(segment),\n )\n .join('/');\n return `${encoded}@${encodeURIComponent(version)}`;\n}\n\nfunction exactUnpkgBase(source: string, version: string): string {\n return `${UNPKG_ORIGIN}/${unpkgPackagePath(source, version)}/`;\n}\n\nfunction contentLength(response: HelpFetchResponse): number | undefined {\n const raw = response.headers.get('content-length');\n if (!raw) return undefined;\n const parsed = Number.parseInt(raw, 10);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : undefined;\n}\n\nfunction timeoutSignal(parent: AbortSignal, timeoutMs: number): { signal: AbortSignal; dispose(): void } {\n const controller = new AbortController();\n const abort = () => controller.abort(parent.reason);\n parent.addEventListener('abort', abort, { once: true });\n const timer = setTimeout(() => controller.abort(new Error('Help download timed out.')), timeoutMs);\n if (parent.aborted) abort();\n return {\n signal: controller.signal,\n dispose() {\n clearTimeout(timer);\n parent.removeEventListener('abort', abort);\n },\n };\n}\n\nasync function fetchExact(fetcher: HelpFetch, initialUrl: string, signal: AbortSignal): Promise<HelpFetchResponse> {\n let url = initialUrl;\n const expected = new URL(initialUrl);\n for (let redirect = 0; redirect <= MAX_REDIRECTS; redirect += 1) {\n const response = await fetcher(url, { signal, redirect: 'manual' });\n if (response.status < 300 || response.status >= 400) return response;\n const location = response.headers.get('location');\n if (!location) throw new Error(`Unpkg redirected ${url} without a location.`);\n const next = new URL(location, url);\n if (next.origin !== UNPKG_ORIGIN || next.pathname !== expected.pathname || next.search !== expected.search) {\n throw new Error(`Unpkg redirect escaped the exact package/version path: ${next.href}`);\n }\n url = next.href;\n }\n throw new Error(`Unpkg exceeded ${MAX_REDIRECTS} redirects.`);\n}\n\nfunction parseMetadata(text: string): UnpkgMetadataFile {\n let parsed: unknown;\n try {\n parsed = JSON.parse(text) as unknown;\n } catch {\n throw new Error('Unpkg metadata is not valid JSON.');\n }\n if (!isRecord(parsed) || !Array.isArray(parsed.files)) throw new Error('Unpkg metadata has no files list.');\n const match = parsed.files.find((entry) => isRecord(entry) && entry.path === `/${HELP_INDEX_PATH}`);\n if (!isRecord(match) || typeof match.integrity !== 'string') {\n throw new Error(`Unpkg package does not publish /${HELP_INDEX_PATH}.`);\n }\n const size = typeof match.size === 'number' ? match.size : undefined;\n if (size !== undefined && (!Number.isSafeInteger(size) || size < 0 || size > MAX_LLMS_BYTES)) {\n throw new Error(`Unpkg /${HELP_INDEX_PATH} exceeds the Help size limit.`);\n }\n if (!SRI_PATTERN.test(match.integrity)) throw new Error('Unpkg llms.txt metadata does not contain SHA-256 SRI.');\n return { path: match.path as string, ...(size === undefined ? {} : { size }), integrity: match.integrity };\n}\n\nfunction verifySri(bytes: Uint8Array, integrity: string): void {\n const expected = SRI_PATTERN.exec(integrity)?.[1];\n if (!expected) throw new Error('Invalid llms.txt SRI metadata.');\n const actual = createHash('sha256').update(bytes).digest('base64');\n if (actual !== expected) throw new Error('Downloaded llms.txt failed SRI verification.');\n}\n\nexport class DefaultHelpIndexResolver implements HelpIndexResolver {\n private readonly cache: HelpIndexCache;\n private readonly fetcher: HelpFetch;\n private readonly timeoutMs: number;\n\n constructor(options: DefaultHelpIndexResolverOptions = {}) {\n this.cache = options.cache ?? new HelpIndexCache();\n this.fetcher = options.fetch ?? defaultFetch;\n this.timeoutMs = options.timeoutMs ?? DEFAULT_FETCH_TIMEOUT_MS;\n }\n\n async resolve(contribution: PoHelpContribution, signal: AbortSignal): Promise<ResolvedHelpIndex> {\n if (signal.aborted) throw new Error('Help activation was cancelled.');\n const identity = resolveHelpPackageIdentity(contribution.moduleUrl, contribution.source);\n const localPath = path.join(identity.packageRoot, HELP_INDEX_PATH);\n if (fs.existsSync(localPath)) {\n if (!isRegularFile(localPath)) throw new Error(`Bundled ${HELP_INDEX_PATH} must be a regular file.`);\n const bytes = fs.readFileSync(localPath);\n validateLlmsBytes(bytes);\n return {\n identity,\n location: 'local',\n filePath: localPath,\n referenceBase: identity.packageRoot,\n byteLength: bytes.byteLength,\n digest: sha256Hex(bytes),\n };\n }\n\n const cached = this.cache.read(identity);\n if (cached) {\n try {\n validateLlmsBytes(cached.bytes);\n return {\n identity,\n location: 'cache',\n filePath: cached.filePath,\n referenceBase: cached.referenceBase,\n byteLength: cached.bytes.byteLength,\n digest: cached.digest,\n };\n } catch {\n this.cache.discard(identity);\n }\n }\n\n const timed = timeoutSignal(signal, this.timeoutMs);\n try {\n const referenceBase = exactUnpkgBase(identity.source, identity.version);\n const metadataResponse = await fetchExact(this.fetcher, `${referenceBase}?meta`, timed.signal);\n const metadataLength = contentLength(metadataResponse);\n if (metadataLength !== undefined && metadataLength > MAX_METADATA_BYTES) {\n throw new Error('Unpkg metadata exceeds the Help metadata size limit.');\n }\n if (!metadataResponse.ok) throw new Error(`Unpkg metadata request failed with HTTP ${metadataResponse.status}.`);\n const metadataText = await metadataResponse.text();\n if (Buffer.byteLength(metadataText, 'utf8') > MAX_METADATA_BYTES) {\n throw new Error('Unpkg metadata exceeds the Help metadata size limit.');\n }\n const metadata = parseMetadata(metadataText);\n const indexResponse = await fetchExact(this.fetcher, `${referenceBase}${HELP_INDEX_PATH}`, timed.signal);\n const indexLength = contentLength(indexResponse);\n if (indexLength !== undefined && indexLength > MAX_LLMS_BYTES) {\n throw new Error(`Downloaded ${HELP_INDEX_PATH} exceeds ${MAX_LLMS_BYTES} bytes.`);\n }\n if (!indexResponse.ok) throw new Error(`Unpkg llms.txt request failed with HTTP ${indexResponse.status}.`);\n const bytes = new Uint8Array(await indexResponse.arrayBuffer());\n validateLlmsBytes(bytes);\n verifySri(bytes, metadata.integrity);\n const published = this.cache.publish(identity, bytes, metadata.integrity, referenceBase, timed.signal);\n return {\n identity,\n location: 'remote',\n filePath: published.filePath,\n referenceBase: published.referenceBase,\n byteLength: published.bytes.byteLength,\n digest: published.digest,\n };\n } finally {\n timed.dispose();\n }\n }\n}\n","import type { PoHelpContribution, PoHelpService } from '@agimon-ai/po-core/help';\n\nimport type { HelpFetch } from '../../types/help';\nimport { DefaultHelpActivationService } from '../helpActivation';\nimport { DefaultHelpSkillMaterializer, defaultHelpCacheRoot, HelpIndexCache } from '../helpStorage';\nimport { DefaultHelpIndexResolver } from '../llmsResolver';\n\nexport interface HelpRuntimeOptions {\n cacheRoot?: string;\n fetch?: HelpFetch;\n timeoutMs?: number;\n onBackgroundError?(error: unknown): void;\n}\n\nexport interface HelpRuntimeComposition {\n activation: DefaultHelpActivationService;\n dispose(): void;\n}\n\nfunction reportAsync(error: unknown): void {\n queueMicrotask(() => {\n throw error instanceof Error ? error : new Error(String(error));\n });\n}\n\nexport function createHelpRuntime(service: PoHelpService, options: HelpRuntimeOptions = {}): HelpRuntimeComposition {\n const cacheRoot = options.cacheRoot ?? defaultHelpCacheRoot();\n const cache = new HelpIndexCache(cacheRoot);\n const activation = new DefaultHelpActivationService({\n resolver: new DefaultHelpIndexResolver({ cache, fetch: options.fetch, timeoutMs: options.timeoutMs }),\n materializer: new DefaultHelpSkillMaterializer(cacheRoot),\n publisher: { publish: (snapshot) => service.publish(snapshot) },\n onBackgroundError(error) {\n if (options.onBackgroundError) options.onBackgroundError(error);\n else reportAsync(error);\n },\n });\n const synchronize = (contributions: readonly PoHelpContribution[]): void => {\n activation.replaceContributions(contributions);\n };\n const unsubscribe = service.subscribeContributions((contributions) => synchronize(contributions));\n synchronize(service.listContributions());\n let disposed = false;\n return {\n activation,\n dispose() {\n if (disposed) return;\n disposed = true;\n unsubscribe();\n activation.dispose();\n },\n };\n}\n"],"mappings":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B,CAAC;CACvC,IAAI,WAAW;CACf,OAAO;EACL;EACA,UAAU;GACR,IAAI,UAAU;GACd,WAAW;GACX,YAAY;GACZ,WAAW,QAAQ;EACrB;CACF;AACF"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PoHelpActivation, PoHelpContribution, PoHelpDiagnostic, PoHelpService, PoHelpSkill } from "@agimon-ai/po-core/help";
|
|
2
2
|
//#region src/types/help.d.ts
|
|
3
3
|
interface HelpPackageIdentity {
|
|
4
4
|
source: string;
|
|
@@ -16,15 +16,15 @@ interface ResolvedHelpIndex {
|
|
|
16
16
|
digest: string;
|
|
17
17
|
}
|
|
18
18
|
interface HelpIndexResolver {
|
|
19
|
-
resolve(contribution:
|
|
19
|
+
resolve(contribution: PoHelpContribution, signal: AbortSignal): Promise<ResolvedHelpIndex>;
|
|
20
20
|
}
|
|
21
21
|
interface HelpSkillMaterializer {
|
|
22
|
-
materialize(contribution:
|
|
22
|
+
materialize(contribution: PoHelpContribution, index: ResolvedHelpIndex, signal: AbortSignal): Promise<readonly PoHelpSkill[]>;
|
|
23
23
|
}
|
|
24
24
|
interface HelpRuntimeState {
|
|
25
|
-
activation:
|
|
26
|
-
skills: readonly
|
|
27
|
-
diagnostics: readonly
|
|
25
|
+
activation: PoHelpActivation;
|
|
26
|
+
skills: readonly PoHelpSkill[];
|
|
27
|
+
diagnostics: readonly PoHelpDiagnostic[];
|
|
28
28
|
}
|
|
29
29
|
interface HelpSnapshotPublisher {
|
|
30
30
|
publish(snapshot: HelpRuntimeState): unknown;
|
|
@@ -37,7 +37,7 @@ interface HelpActivationDependencies {
|
|
|
37
37
|
}
|
|
38
38
|
interface HelpActivationService {
|
|
39
39
|
getState(): HelpRuntimeState;
|
|
40
|
-
replaceContributions(contributions: readonly
|
|
40
|
+
replaceContributions(contributions: readonly PoHelpContribution[]): void;
|
|
41
41
|
subscribe(listener: (state: HelpRuntimeState) => void): () => void;
|
|
42
42
|
activate(signal?: AbortSignal): Promise<HelpRuntimeState>;
|
|
43
43
|
deactivate(): HelpRuntimeState;
|
|
@@ -70,7 +70,7 @@ export declare class DefaultHelpActivationService implements HelpActivationServi
|
|
|
70
70
|
private disposed;
|
|
71
71
|
constructor(dependencies: HelpActivationDependencies);
|
|
72
72
|
getState(): HelpRuntimeState;
|
|
73
|
-
replaceContributions(contributions: readonly
|
|
73
|
+
replaceContributions(contributions: readonly PoHelpContribution[]): void;
|
|
74
74
|
subscribe(listener: (state: HelpRuntimeState) => void): () => void;
|
|
75
75
|
private publish;
|
|
76
76
|
private loadSources;
|
|
@@ -90,7 +90,7 @@ interface HelpRuntimeComposition {
|
|
|
90
90
|
activation: DefaultHelpActivationService;
|
|
91
91
|
dispose(): void;
|
|
92
92
|
}
|
|
93
|
-
export declare function createHelpRuntime(service:
|
|
93
|
+
export declare function createHelpRuntime(service: PoHelpService, options?: HelpRuntimeOptions): HelpRuntimeComposition;
|
|
94
94
|
//#endregion
|
|
95
95
|
//#region src/services/helpStorage/index.d.ts
|
|
96
96
|
interface CachedHelpIndex {
|
|
@@ -112,7 +112,7 @@ export declare class HelpIndexCache {
|
|
|
112
112
|
export declare class DefaultHelpSkillMaterializer implements HelpSkillMaterializer {
|
|
113
113
|
private readonly cacheRoot;
|
|
114
114
|
constructor(cacheRoot?: string);
|
|
115
|
-
materialize(contribution:
|
|
115
|
+
materialize(contribution: PoHelpContribution, index: ResolvedHelpIndex, signal: AbortSignal): Promise<readonly PoHelpSkill[]>;
|
|
116
116
|
}
|
|
117
117
|
//#endregion
|
|
118
118
|
//#region src/services/llmsResolver/index.d.ts
|
|
@@ -126,7 +126,7 @@ export declare class DefaultHelpIndexResolver implements HelpIndexResolver {
|
|
|
126
126
|
private readonly fetcher;
|
|
127
127
|
private readonly timeoutMs;
|
|
128
128
|
constructor(options?: DefaultHelpIndexResolverOptions);
|
|
129
|
-
resolve(contribution:
|
|
129
|
+
resolve(contribution: PoHelpContribution, signal: AbortSignal): Promise<ResolvedHelpIndex>;
|
|
130
130
|
}
|
|
131
131
|
//#endregion
|
|
132
132
|
export type { HelpActivationDependencies, HelpActivationService, HelpFetch, HelpFetchResponse, HelpIndexLocation, HelpIndexResolver, HelpPackageIdentity, HelpRuntimeComposition, HelpRuntimeOptions, HelpRuntimeState, HelpSkillMaterializer, HelpSnapshotPublisher, ResolvedHelpIndex };
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/help.ts","../src/services/helpActivation/index.ts","../src/services/helpRuntime/index.ts","../src/services/helpStorage/index.ts","../src/services/llmsResolver/index.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/help.ts","../src/services/helpActivation/index.ts","../src/services/helpRuntime/index.ts","../src/services/helpStorage/index.ts","../src/services/llmsResolver/index.ts"],"mappings":";;UAEiB;EACf;EACA;EACA;EACA;;KAGU;UAEK;EACf,UAAU;EACV,UAAU;EACV;EACA;EACA;EACA;;UAGe;EACf,QAAQ,cAAc,oBAAoB,QAAQ,cAAc,QAAQ;;UAGzD;EACf,YACE,cAAc,oBACd,OAAO,mBACP,QAAQ,cACP,iBAAiB;;UAGL;EACf,YAAY;EACZ,iBAAiB;EACjB,sBAAsB;;UAGP;EACf,QAAQ,UAAU;;UAGH;EACf,UAAU;EACV,cAAc;EACd,WAAW;EACX,kBAAkB;;UAGH;EACf,YAAY;EACZ,qBAAqB,wBAAwB;EAC7C,UAAU,WAAW,OAAO;EAC5B,SAAS,SAAS,cAAc,QAAQ;EACxC,cAAc;EACd;;UAGe;EACf;EACA;EACA;IAAW,IAAI;;EACf,QAAQ;EACR,eAAe,QAAQ;;KAGb,aACV,eACA;EAAQ,QAAQ;EAAa;MAC1B,QAAQ;;;qBCGA,wCAAwC;mBAClC;mBACA;UACT;UACA;UACA;UACA;UACA;UACA;UACA;EAER,YAAY,cAAc;EAI1B,YAAY;EAIZ,qBAAqB,wBAAwB;EAgC7C,UAAU,WAAW,OAAO;UAKpB;UAQM;EA2BR,SAAS,iBAAiB,cAAc,QAAQ;EAiFtD,cAAc;EAOd;;;;UCpPe;EACf;EACA,QAAQ;EACR;EACA,mBAAmB;;UAGJ;EACf,YAAY;EACZ;;wBASc,kBAAkB,SAAS,eAAe,UAAS,qBAA0B;;;UCU5E;EACf,OAAO;EACP;EACA;EACA;EACA;;wBAuEc,qBAAqB;qBAiCxB;WACF;EAET,YAAY;EAIZ,eAAe,UAAU;EAKzB,QAAQ,UAAU;EAIlB,KAAK,UAAU,sBAAsB;EAwBrC,QACE,UAAU,qBACV,OAAO,YACP,mBACA,uBACA,QAAQ,cACP;;qBA8CQ,wCAAwC;mBACtB;EAA7B,YAA6B;EAEvB,YACJ,cAAc,oBACd,OAAO,mBACP,QAAQ,cACP,iBAAiB;;;;UC5NL;EACf,QAAQ;EACR,QAAQ;EACR;;qBAoGW,oCAAoC;mBAC9B;mBACA;mBACA;EAEjB,YAAY,UAAS;EAMf,QAAQ,cAAc,oBAAoB,QAAQ,cAAc,QAAQ"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PO_HELP_MAX_DIAGNOSTICS, PO_HELP_MAX_DIAGNOSTIC_LENGTH, PO_HELP_MAX_SKILLS } from "@agimon-ai/po-core/help";
|
|
2
2
|
import { createHash, randomUUID } from "node:crypto";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import os from "node:os";
|
|
@@ -112,7 +112,7 @@ function diagnostic(source, code, error) {
|
|
|
112
112
|
return {
|
|
113
113
|
source,
|
|
114
114
|
code,
|
|
115
|
-
message: ((error instanceof Error ? error.message : String(error)) || "Unknown Help activation failure.").slice(0,
|
|
115
|
+
message: ((error instanceof Error ? error.message : String(error)) || "Unknown Help activation failure.").slice(0, PO_HELP_MAX_DIAGNOSTIC_LENGTH)
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
118
|
function contributionFingerprint(contributions) {
|
|
@@ -251,7 +251,7 @@ var DefaultHelpActivationService = class {
|
|
|
251
251
|
const skills = [];
|
|
252
252
|
const names = /* @__PURE__ */ new Set();
|
|
253
253
|
for (const source of loaded) for (const skill of source.skills) {
|
|
254
|
-
if (skills.length >=
|
|
254
|
+
if (skills.length >= PO_HELP_MAX_SKILLS) {
|
|
255
255
|
diagnostics.push(diagnostic(source.contribution.source, "HELP_SKILL_LIMIT", "The Help skill limit was reached."));
|
|
256
256
|
break;
|
|
257
257
|
}
|
|
@@ -262,7 +262,7 @@ var DefaultHelpActivationService = class {
|
|
|
262
262
|
names.add(skill.name);
|
|
263
263
|
skills.push({ ...skill });
|
|
264
264
|
}
|
|
265
|
-
const boundedDiagnostics = diagnostics.slice(0,
|
|
265
|
+
const boundedDiagnostics = diagnostics.slice(0, PO_HELP_MAX_DIAGNOSTICS);
|
|
266
266
|
if (skills.length === 0) {
|
|
267
267
|
this.publish({
|
|
268
268
|
activation: "inactive",
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["HELP_INDEX_PATH","isRecord"],"sources":["../src/services/llmsContent/index.ts","../src/services/helpActivation/index.ts","../src/services/helpStorage/index.ts","../src/services/llmsResolver/index.ts","../src/services/helpRuntime/index.ts"],"sourcesContent":["import type { DoomHelpSkillDescriptor } from '@agimon-ai/po-core/help';\n\nimport type { ResolvedHelpIndex } from '../../types/help';\n\nexport const MAX_LLMS_BYTES = 1024 * 1024;\nexport const MAX_AGGREGATE_LLMS_BYTES = 4 * MAX_LLMS_BYTES;\n\nconst MARKDOWN_LINK_PATTERN = /!?\\[[^\\]]*\\]\\(\\s*<?([^\\s)>]+)>?(?:\\s+[^)]*)?\\)/gu;\nconst MARKDOWN_REFERENCE_LINK_PATTERN = /^\\s{0,3}\\[[^\\]\\r\\n]+\\]:\\s*<?([^\\s>]+)>?/gmu;\nconst MARKDOWN_AUTOLINK_PATTERN = /<((?:\\.{0,2}\\/|[A-Za-z][A-Za-z0-9+.-]*:)[^<>\\s]+)>/gu;\nconst HTML_LINK_PATTERN = /\\b(?:href|src)\\s*=\\s*[\"']([^\"']+)[\"']/giu;\nconst URI_SCHEME_PATTERN = /^[a-z][a-z0-9+.-]*:/iu;\nconst NESTED_PATH_ENCODING_PATTERN = /%(?:25|2e|2f|3a|5c)/iu;\nconst SAFE_EXTERNAL_SCHEMES = new Set(['http:', 'https:', 'mailto:']);\n\nfunction externalScheme(target: string): string | undefined {\n if (!URI_SCHEME_PATTERN.test(target)) return undefined;\n return target.slice(0, target.indexOf(':') + 1).toLowerCase();\n}\n\nfunction decodeRelativeTarget(rawTarget: string): string {\n let decoded = rawTarget;\n try {\n for (let pass = 0; pass < 2; pass += 1) {\n const next = decodeURIComponent(decoded);\n if (next === decoded) break;\n decoded = next;\n }\n } catch {\n throw new Error(`llms.txt contains an invalid encoded link '${rawTarget}'.`);\n }\n if (NESTED_PATH_ENCODING_PATTERN.test(decoded)) {\n throw new Error(`llms.txt contains an unsafe nested encoding in link '${rawTarget}'.`);\n }\n return decoded;\n}\n\nfunction validateRelativeLink(rawTarget: string): void {\n if (!rawTarget || rawTarget.startsWith('#')) return;\n const rawScheme = externalScheme(rawTarget);\n if (rawScheme) {\n if (!SAFE_EXTERNAL_SCHEMES.has(rawScheme)) {\n throw new Error(`llms.txt contains unsupported link scheme '${rawScheme}'.`);\n }\n return;\n }\n\n const decoded = decodeRelativeTarget(rawTarget);\n const decodedScheme = externalScheme(decoded);\n if (decodedScheme) {\n if (!SAFE_EXTERNAL_SCHEMES.has(decodedScheme)) {\n throw new Error(`llms.txt contains unsupported link scheme '${decodedScheme}'.`);\n }\n return;\n }\n const withoutSuffix = decoded.split(/[?#]/u, 1)[0]?.replaceAll('\\\\', '/') ?? '';\n if (withoutSuffix.startsWith('/') || withoutSuffix.split('/').some((segment) => segment === '..')) {\n throw new Error(`llms.txt link '${rawTarget}' escapes the package root.`);\n }\n}\n\nfunction containsUnsafeControl(text: string): boolean {\n for (const character of text) {\n const code = character.codePointAt(0) ?? 0;\n if ((code >= 0 && code <= 8) || code === 11 || code === 12 || (code >= 14 && code <= 31) || code === 127) {\n return true;\n }\n }\n return false;\n}\n\nexport function validateLlmsBytes(bytes: Uint8Array): string {\n if (bytes.byteLength === 0) throw new Error('llms.txt is empty.');\n if (bytes.byteLength > MAX_LLMS_BYTES) throw new Error(`llms.txt exceeds ${MAX_LLMS_BYTES} bytes.`);\n\n let text: string;\n try {\n text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);\n } catch {\n throw new Error('llms.txt is not valid UTF-8.');\n }\n if (text.startsWith('\\uFEFF')) text = text.slice(1);\n if (containsUnsafeControl(text)) throw new Error('llms.txt contains unsafe control bytes.');\n\n const firstContentLine = text\n .split(/\\r?\\n/u)\n .find((line) => line.trim().length > 0)\n ?.trim();\n if (!firstContentLine || !/^#\\s+\\S/u.test(firstContentLine)) {\n throw new Error('llms.txt must begin with a Markdown H1 heading.');\n }\n for (const pattern of [\n MARKDOWN_LINK_PATTERN,\n MARKDOWN_REFERENCE_LINK_PATTERN,\n MARKDOWN_AUTOLINK_PATTERN,\n HTML_LINK_PATTERN,\n ]) {\n for (const match of text.matchAll(pattern)) validateRelativeLink(match[1] ?? '');\n }\n return text;\n}\n\nexport function renderHelpSkillWrapper(descriptor: DoomHelpSkillDescriptor, index: ResolvedHelpIndex): string {\n const name = JSON.stringify(descriptor.name);\n const description = JSON.stringify(descriptor.description);\n const indexPath = JSON.stringify(index.filePath);\n const referenceBase = JSON.stringify(index.referenceBase);\n return `---\\nname: ${name}\\ndescription: ${description}\\n---\\n\\n# Package Help\\n\\nRead the validated package Help index at ${indexPath}.\\nResolve relative links in that index against ${referenceBase}.\\nOpen only the linked documents relevant to the current request, as needed; do not recursively load the whole reference set.\\n`;\n}\n","import {\n DOOM_HELP_MAX_DIAGNOSTIC_LENGTH,\n DOOM_HELP_MAX_DIAGNOSTICS,\n DOOM_HELP_MAX_SKILLS,\n type DoomHelpContribution,\n type DoomHelpDiagnostic,\n type DoomHelpSkill,\n} from '@agimon-ai/po-core/help';\n\nimport type {\n HelpActivationDependencies,\n HelpActivationService,\n HelpRuntimeState,\n ResolvedHelpIndex,\n} from '../../types/help';\nimport { MAX_AGGREGATE_LLMS_BYTES } from '../llmsContent';\n\nconst MAX_RESOLUTION_CONCURRENCY = 4;\nconst FAILURE_MESSAGE = 'No package Help source could be activated.';\nconst CANCELLATION_MESSAGE = 'Help activation was cancelled.';\n\ninterface LoadedSource {\n contribution: DoomHelpContribution;\n index: ResolvedHelpIndex;\n skills: readonly DoomHelpSkill[];\n}\n\ninterface SourceOutcome {\n source: string;\n loaded?: LoadedSource;\n error?: unknown;\n}\n\nexport class HelpActivationError extends Error {\n constructor(message = FAILURE_MESSAGE) {\n super(message);\n this.name = 'HelpActivationError';\n }\n}\n\nfunction cloneContribution(contribution: DoomHelpContribution): DoomHelpContribution {\n return {\n source: contribution.source,\n moduleUrl: contribution.moduleUrl,\n skills: contribution.skills.map((skill) => ({ ...skill })),\n };\n}\n\nfunction cloneState(state: HelpRuntimeState): HelpRuntimeState {\n return {\n activation: state.activation,\n skills: state.skills.map((skill) => ({ ...skill })),\n diagnostics: state.diagnostics.map((diagnostic) => ({ ...diagnostic })),\n };\n}\n\nfunction diagnostic(source: string, code: string, error: unknown): DoomHelpDiagnostic {\n const raw = error instanceof Error ? error.message : String(error);\n const message = (raw || 'Unknown Help activation failure.').slice(0, DOOM_HELP_MAX_DIAGNOSTIC_LENGTH);\n return { source, code, message };\n}\n\nfunction contributionFingerprint(contributions: readonly DoomHelpContribution[]): string {\n return JSON.stringify(\n contributions.map((contribution) => ({\n source: contribution.source,\n moduleUrl: contribution.moduleUrl,\n skills: contribution.skills,\n })),\n );\n}\n\nexport class DefaultHelpActivationService implements HelpActivationService {\n private readonly dependencies: HelpActivationDependencies;\n private readonly listeners = new Set<(state: HelpRuntimeState) => void>();\n private contributions: DoomHelpContribution[] = [];\n private fingerprint = '[]';\n private state: HelpRuntimeState = { activation: 'inactive', skills: [], diagnostics: [] };\n private settledState: HelpRuntimeState = { activation: 'inactive', skills: [], diagnostics: [] };\n private generation = 0;\n private controller: AbortController | undefined;\n private disposed = false;\n\n constructor(dependencies: HelpActivationDependencies) {\n this.dependencies = dependencies;\n }\n\n getState(): HelpRuntimeState {\n return cloneState(this.state);\n }\n\n replaceContributions(contributions: readonly DoomHelpContribution[]): void {\n if (this.disposed) return;\n const next = contributions.map(cloneContribution).sort((left, right) => left.source.localeCompare(right.source));\n const fingerprint = contributionFingerprint(next);\n if (fingerprint === this.fingerprint) return;\n const previous = new Map(this.contributions.map((entry) => [entry.source, contributionFingerprint([entry])]));\n const retained = new Set(\n next\n .filter((entry) => previous.get(entry.source) === contributionFingerprint([entry]))\n .map((entry) => entry.source),\n );\n // A refresh may retain unchanged owners, never withdrawn or replaced ones.\n // Prune the rollback snapshot too, so cancellation cannot resurrect them.\n const skills = this.settledState.skills.filter((entry) => retained.has(entry.source));\n const diagnostics = this.settledState.diagnostics.filter((entry) => !entry.source || retained.has(entry.source));\n this.settledState = {\n activation: skills.length === 0 ? 'inactive' : diagnostics.length > 0 ? 'degraded' : 'active',\n skills,\n diagnostics,\n };\n this.contributions = next;\n this.fingerprint = fingerprint;\n if (this.state.activation !== 'inactive') {\n void this.activate().catch((error: unknown) => {\n // Activation failures publish a bounded settled state before rejecting.\n // Only unexpected implementation failures need an out-of-band report.\n if (error instanceof HelpActivationError) return;\n this.dependencies.onBackgroundError(error);\n });\n }\n }\n\n subscribe(listener: (state: HelpRuntimeState) => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n private publish(state: HelpRuntimeState): HelpRuntimeState {\n this.state = cloneState(state);\n if (state.activation !== 'activating') this.settledState = cloneState(state);\n this.dependencies.publisher.publish(this.state);\n for (const listener of this.listeners) listener(cloneState(this.state));\n return this.getState();\n }\n\n private async loadSources(signal: AbortSignal): Promise<SourceOutcome[]> {\n const contributions = this.contributions;\n const outcomes: SourceOutcome[] = Array.from({ length: contributions.length });\n let cursor = 0;\n const worker = async (): Promise<void> => {\n while (cursor < contributions.length) {\n const index = cursor;\n cursor += 1;\n const contribution = contributions[index];\n if (!contribution) return;\n if (signal.aborted) throw new HelpActivationError(CANCELLATION_MESSAGE);\n try {\n const resolved = await this.dependencies.resolver.resolve(contribution, signal);\n if (signal.aborted) throw new HelpActivationError(CANCELLATION_MESSAGE);\n const skills = await this.dependencies.materializer.materialize(contribution, resolved, signal);\n outcomes[index] = { source: contribution.source, loaded: { contribution, index: resolved, skills } };\n } catch (error) {\n if (signal.aborted) throw new HelpActivationError(CANCELLATION_MESSAGE);\n outcomes[index] = { source: contribution.source, error };\n }\n }\n };\n const count = Math.min(MAX_RESOLUTION_CONCURRENCY, contributions.length);\n await Promise.all(Array.from({ length: count }, () => worker()));\n return outcomes;\n }\n\n async activate(externalSignal?: AbortSignal): Promise<HelpRuntimeState> {\n if (this.disposed) throw new HelpActivationError('Help runtime is disposed.');\n this.controller?.abort('Help activation generation replaced.');\n const controller = new AbortController();\n this.controller = controller;\n const generation = ++this.generation;\n const abortFromExternal = () => controller.abort(externalSignal?.reason);\n externalSignal?.addEventListener('abort', abortFromExternal, { once: true });\n if (externalSignal?.aborted) abortFromExternal();\n\n const settledState = cloneState(this.settledState);\n this.publish({ activation: 'activating', skills: settledState.skills, diagnostics: settledState.diagnostics });\n try {\n const outcomes = await this.loadSources(controller.signal);\n if (controller.signal.aborted || generation !== this.generation) {\n throw new HelpActivationError(CANCELLATION_MESSAGE);\n }\n\n const diagnostics: DoomHelpDiagnostic[] = [];\n const loaded: LoadedSource[] = [];\n let aggregateBytes = 0;\n for (const outcome of outcomes) {\n if (!outcome) continue;\n if (outcome.error || !outcome.loaded) {\n diagnostics.push(diagnostic(outcome.source, 'HELP_SOURCE_FAILED', outcome.error));\n continue;\n }\n if (aggregateBytes + outcome.loaded.index.byteLength > MAX_AGGREGATE_LLMS_BYTES) {\n diagnostics.push(\n diagnostic(outcome.source, 'HELP_AGGREGATE_LIMIT', 'The aggregate llms.txt byte limit was exceeded.'),\n );\n continue;\n }\n aggregateBytes += outcome.loaded.index.byteLength;\n loaded.push(outcome.loaded);\n }\n\n const skills: DoomHelpSkill[] = [];\n const names = new Set<string>();\n for (const source of loaded) {\n for (const skill of source.skills) {\n if (skills.length >= DOOM_HELP_MAX_SKILLS) {\n diagnostics.push(\n diagnostic(source.contribution.source, 'HELP_SKILL_LIMIT', 'The Help skill limit was reached.'),\n );\n break;\n }\n if (names.has(skill.name)) {\n diagnostics.push(\n diagnostic(\n source.contribution.source,\n 'HELP_SKILL_COLLISION',\n `Help skill '${skill.name}' was already provided by an earlier package source.`,\n ),\n );\n continue;\n }\n names.add(skill.name);\n skills.push({ ...skill });\n }\n }\n\n const boundedDiagnostics = diagnostics.slice(0, DOOM_HELP_MAX_DIAGNOSTICS);\n if (skills.length === 0) {\n this.publish({ activation: 'inactive', skills: [], diagnostics: boundedDiagnostics });\n throw new HelpActivationError();\n }\n return this.publish({\n activation: boundedDiagnostics.length > 0 ? 'degraded' : 'active',\n skills,\n diagnostics: boundedDiagnostics,\n });\n } catch (error) {\n if (generation === this.generation && this.state.activation === 'activating') this.publish(settledState);\n throw error;\n } finally {\n externalSignal?.removeEventListener('abort', abortFromExternal);\n if (this.controller === controller) this.controller = undefined;\n }\n }\n\n deactivate(): HelpRuntimeState {\n this.generation += 1;\n this.controller?.abort('Help deactivated.');\n this.controller = undefined;\n return this.publish({ activation: 'inactive', skills: [], diagnostics: [] });\n }\n\n dispose(): void {\n if (this.disposed) return;\n this.deactivate();\n this.disposed = true;\n this.listeners.clear();\n }\n}\n","import { createHash, randomUUID } from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { DoomHelpContribution, DoomHelpSkill } from '@agimon-ai/po-core/help';\nimport { poHomeDirectory } from '@agimon-ai/po-core/piSettings';\n\nimport type { HelpPackageIdentity, HelpSkillMaterializer, ResolvedHelpIndex } from '../../types/help';\nimport { renderHelpSkillWrapper } from '../llmsContent';\n\nconst PACKAGE_MANIFEST = 'package.json';\nconst HELP_INDEX_PATH = 'llms.txt';\nconst CACHE_SCHEMA_VERSION = 1;\nconst PRIVATE_FILE_MODE = 0o600;\nconst PRIVATE_DIRECTORY_MODE = 0o700;\nconst COMPLETION_FILE = '.complete';\nconst CACHE_METADATA_FILE = 'metadata.json';\nconst WRAPPER_DIRECTORY = 'wrappers';\nconst SKILL_FILE = 'SKILL.md';\nconst EXACT_SEMVER_PATTERN =\n /^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/u;\nconst NPM_PACKAGE_NAME_PATTERN = /^(?:@[a-z0-9][a-z0-9._~-]*\\/)?[a-z0-9][a-z0-9._~-]*$/u;\n\ninterface CacheMetadata {\n schemaVersion: typeof CACHE_SCHEMA_VERSION;\n source: string;\n version: string;\n path: typeof HELP_INDEX_PATH;\n integrity: string;\n digest: string;\n referenceBase: string;\n}\n\nexport interface CachedHelpIndex {\n bytes: Uint8Array;\n filePath: string;\n integrity: string;\n digest: string;\n referenceBase: string;\n}\n\nfunction assertNotAborted(signal: AbortSignal): void {\n if (signal.aborted) throw new Error('Help activation was cancelled.');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isContained(root: string, candidate: string): boolean {\n const relative = path.relative(root, candidate);\n return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));\n}\n\nfunction readManifest(filePath: string): Record<string, unknown> {\n let parsed: unknown;\n try {\n parsed = JSON.parse(fs.readFileSync(filePath, 'utf8')) as unknown;\n } catch (error) {\n throw new Error(\n `Cannot read Help package manifest at ${filePath}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n if (!isRecord(parsed)) throw new Error(`Help package manifest at ${filePath} must contain an object.`);\n return parsed;\n}\n\nexport function resolveHelpPackageIdentity(moduleUrl: string, expectedSource: string): HelpPackageIdentity {\n if (!NPM_PACKAGE_NAME_PATTERN.test(expectedSource)) {\n throw new Error(`Help source '${expectedSource}' must be a valid lowercase npm package name.`);\n }\n let modulePath: string;\n try {\n const url = new URL(moduleUrl);\n if (url.protocol !== 'file:') throw new Error(`Help module URL must use file:, received ${url.protocol}`);\n modulePath = fs.realpathSync(fileURLToPath(url));\n } catch (error) {\n throw new Error(\n `Invalid Help contributor module URL '${moduleUrl}': ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n if (!fs.lstatSync(modulePath).isFile())\n throw new Error(`Help contributor module is not a regular file: ${modulePath}`);\n\n let directory = path.dirname(modulePath);\n while (true) {\n const manifestPath = path.join(directory, PACKAGE_MANIFEST);\n if (fs.existsSync(manifestPath)) {\n const manifest = readManifest(manifestPath);\n const source = manifest.name;\n const version = manifest.version;\n if (source !== expectedSource) {\n throw new Error(`Help source '${expectedSource}' does not match nearest package '${String(source)}'.`);\n }\n if (typeof version !== 'string' || !EXACT_SEMVER_PATTERN.test(version)) {\n throw new Error(`Help package '${expectedSource}' must declare an exact semantic version.`);\n }\n const packageRoot = fs.realpathSync(directory);\n if (!isContained(packageRoot, modulePath))\n throw new Error('Help contributor module escapes its resolved package root.');\n return { source: expectedSource, version, packageRoot, modulePath };\n }\n const parent = path.dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n throw new Error(`Cannot find a package manifest for Help contributor ${modulePath}.`);\n}\n\nexport function defaultHelpCacheRoot(homeDirectory = os.homedir()): string {\n return path.join(poHomeDirectory(homeDirectory), 'llms-cache');\n}\n\nexport function sha256Hex(bytes: Uint8Array | string): string {\n return createHash('sha256').update(bytes).digest('hex');\n}\n\nfunction parseCacheMetadata(value: unknown, identity: HelpPackageIdentity): CacheMetadata | undefined {\n if (!isRecord(value)) return undefined;\n if (\n value.schemaVersion !== CACHE_SCHEMA_VERSION ||\n value.source !== identity.source ||\n value.version !== identity.version ||\n value.path !== HELP_INDEX_PATH ||\n typeof value.integrity !== 'string' ||\n typeof value.digest !== 'string' ||\n typeof value.referenceBase !== 'string'\n ) {\n return undefined;\n }\n return value as unknown as CacheMetadata;\n}\n\nfunction regularFile(filePath: string): boolean {\n try {\n const metadata = fs.lstatSync(filePath);\n return metadata.isFile() && !metadata.isSymbolicLink();\n } catch {\n return false;\n }\n}\n\nexport class HelpIndexCache {\n readonly root: string;\n\n constructor(root = defaultHelpCacheRoot()) {\n this.root = root;\n }\n\n entryDirectory(identity: HelpPackageIdentity): string {\n const key = sha256Hex(`${identity.source}\\0${identity.version}\\0${HELP_INDEX_PATH}`);\n return path.join(this.root, key);\n }\n\n discard(identity: HelpPackageIdentity): void {\n fs.rmSync(this.entryDirectory(identity), { recursive: true, force: true });\n }\n\n read(identity: HelpPackageIdentity): CachedHelpIndex | undefined {\n const directory = this.entryDirectory(identity);\n const completionPath = path.join(directory, COMPLETION_FILE);\n const indexPath = path.join(directory, HELP_INDEX_PATH);\n const metadataPath = path.join(directory, CACHE_METADATA_FILE);\n if (!regularFile(completionPath) || !regularFile(indexPath) || !regularFile(metadataPath)) return undefined;\n try {\n const metadata = parseCacheMetadata(JSON.parse(fs.readFileSync(metadataPath, 'utf8')) as unknown, identity);\n if (!metadata) return undefined;\n const bytes = fs.readFileSync(indexPath);\n if (sha256Hex(bytes) !== metadata.digest) return undefined;\n if (fs.readFileSync(completionPath, 'utf8').trim() !== metadata.digest) return undefined;\n return {\n bytes,\n filePath: indexPath,\n integrity: metadata.integrity,\n digest: metadata.digest,\n referenceBase: metadata.referenceBase,\n };\n } catch {\n return undefined;\n }\n }\n\n publish(\n identity: HelpPackageIdentity,\n bytes: Uint8Array,\n integrity: string,\n referenceBase: string,\n signal: AbortSignal,\n ): CachedHelpIndex {\n assertNotAborted(signal);\n const existing = this.read(identity);\n if (existing) return existing;\n const directory = this.entryDirectory(identity);\n fs.mkdirSync(this.root, { mode: PRIVATE_DIRECTORY_MODE, recursive: true });\n if (fs.existsSync(directory)) fs.rmSync(directory, { recursive: true, force: true });\n const temporary = `${directory}.${process.pid}.${randomUUID()}.tmp`;\n const digest = sha256Hex(bytes);\n const metadata: CacheMetadata = {\n schemaVersion: CACHE_SCHEMA_VERSION,\n source: identity.source,\n version: identity.version,\n path: HELP_INDEX_PATH,\n integrity,\n digest,\n referenceBase,\n };\n try {\n fs.mkdirSync(temporary, { mode: PRIVATE_DIRECTORY_MODE });\n fs.writeFileSync(path.join(temporary, HELP_INDEX_PATH), bytes, { mode: PRIVATE_FILE_MODE });\n fs.writeFileSync(path.join(temporary, CACHE_METADATA_FILE), `${JSON.stringify(metadata, null, 2)}\\n`, {\n mode: PRIVATE_FILE_MODE,\n });\n assertNotAborted(signal);\n fs.writeFileSync(path.join(temporary, COMPLETION_FILE), `${digest}\\n`, { mode: PRIVATE_FILE_MODE });\n try {\n fs.renameSync(temporary, directory);\n } catch (error) {\n const winner = this.read(identity);\n if (winner) return winner;\n throw error;\n }\n return {\n bytes: Uint8Array.from(bytes),\n filePath: path.join(directory, HELP_INDEX_PATH),\n integrity,\n digest,\n referenceBase,\n };\n } finally {\n fs.rmSync(temporary, { recursive: true, force: true });\n }\n }\n}\n\nexport class DefaultHelpSkillMaterializer implements HelpSkillMaterializer {\n constructor(private readonly cacheRoot = defaultHelpCacheRoot()) {}\n\n async materialize(\n contribution: DoomHelpContribution,\n index: ResolvedHelpIndex,\n signal: AbortSignal,\n ): Promise<readonly DoomHelpSkill[]> {\n const skills: DoomHelpSkill[] = [];\n for (const descriptor of contribution.skills) {\n assertNotAborted(signal);\n const key = sha256Hex(\n `${index.identity.source}\\0${index.identity.version}\\0${descriptor.name}\\0${descriptor.description}\\0${index.digest}`,\n );\n const directory = path.join(this.cacheRoot, WRAPPER_DIRECTORY, key);\n const filePath = path.join(directory, SKILL_FILE);\n const content = renderHelpSkillWrapper(descriptor, index);\n if (!regularFile(filePath) || fs.readFileSync(filePath, 'utf8') !== content) {\n fs.mkdirSync(path.dirname(directory), { mode: PRIVATE_DIRECTORY_MODE, recursive: true });\n if (fs.existsSync(directory)) fs.rmSync(directory, { recursive: true, force: true });\n const temporary = `${directory}.${process.pid}.${randomUUID()}.tmp`;\n try {\n fs.mkdirSync(temporary, { mode: PRIVATE_DIRECTORY_MODE });\n fs.writeFileSync(path.join(temporary, SKILL_FILE), content, { mode: PRIVATE_FILE_MODE });\n assertNotAborted(signal);\n try {\n fs.renameSync(temporary, directory);\n } catch (error) {\n if (!regularFile(filePath) || fs.readFileSync(filePath, 'utf8') !== content) throw error;\n }\n } finally {\n fs.rmSync(temporary, { recursive: true, force: true });\n }\n }\n skills.push({\n source: contribution.source,\n name: descriptor.name,\n description: descriptor.description,\n filePath,\n baseDir: directory,\n });\n }\n return skills;\n }\n}\n","import { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { DoomHelpContribution } from '@agimon-ai/po-core/help';\n\nimport type { HelpFetch, HelpFetchResponse, HelpIndexResolver, ResolvedHelpIndex } from '../../types/help';\nimport { HelpIndexCache, resolveHelpPackageIdentity, sha256Hex } from '../helpStorage';\nimport { MAX_LLMS_BYTES, validateLlmsBytes } from '../llmsContent';\n\nconst HELP_INDEX_PATH = 'llms.txt';\nconst UNPKG_ORIGIN = 'https://unpkg.com';\nconst DEFAULT_FETCH_TIMEOUT_MS = 5_000;\nconst MAX_METADATA_BYTES = 512 * 1024;\nconst MAX_REDIRECTS = 3;\nconst SRI_PATTERN = /^sha256-([A-Za-z0-9+/]+={0,2})$/u;\n\ninterface UnpkgMetadataFile {\n path: string;\n size?: number;\n integrity: string;\n}\n\nexport interface DefaultHelpIndexResolverOptions {\n cache?: HelpIndexCache;\n fetch?: HelpFetch;\n timeoutMs?: number;\n}\n\nfunction defaultFetch(input: string, init: { signal: AbortSignal; redirect: 'manual' }): Promise<HelpFetchResponse> {\n return fetch(input, init) as unknown as Promise<HelpFetchResponse>;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isRegularFile(filePath: string): boolean {\n try {\n const metadata = fs.lstatSync(filePath);\n return metadata.isFile() && !metadata.isSymbolicLink();\n } catch {\n return false;\n }\n}\n\nfunction unpkgPackagePath(source: string, version: string): string {\n const encoded = source\n .split('/')\n .map((segment) =>\n segment.startsWith('@') ? `@${encodeURIComponent(segment.slice(1))}` : encodeURIComponent(segment),\n )\n .join('/');\n return `${encoded}@${encodeURIComponent(version)}`;\n}\n\nfunction exactUnpkgBase(source: string, version: string): string {\n return `${UNPKG_ORIGIN}/${unpkgPackagePath(source, version)}/`;\n}\n\nfunction contentLength(response: HelpFetchResponse): number | undefined {\n const raw = response.headers.get('content-length');\n if (!raw) return undefined;\n const parsed = Number.parseInt(raw, 10);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : undefined;\n}\n\nfunction timeoutSignal(parent: AbortSignal, timeoutMs: number): { signal: AbortSignal; dispose(): void } {\n const controller = new AbortController();\n const abort = () => controller.abort(parent.reason);\n parent.addEventListener('abort', abort, { once: true });\n const timer = setTimeout(() => controller.abort(new Error('Help download timed out.')), timeoutMs);\n if (parent.aborted) abort();\n return {\n signal: controller.signal,\n dispose() {\n clearTimeout(timer);\n parent.removeEventListener('abort', abort);\n },\n };\n}\n\nasync function fetchExact(fetcher: HelpFetch, initialUrl: string, signal: AbortSignal): Promise<HelpFetchResponse> {\n let url = initialUrl;\n const expected = new URL(initialUrl);\n for (let redirect = 0; redirect <= MAX_REDIRECTS; redirect += 1) {\n const response = await fetcher(url, { signal, redirect: 'manual' });\n if (response.status < 300 || response.status >= 400) return response;\n const location = response.headers.get('location');\n if (!location) throw new Error(`Unpkg redirected ${url} without a location.`);\n const next = new URL(location, url);\n if (next.origin !== UNPKG_ORIGIN || next.pathname !== expected.pathname || next.search !== expected.search) {\n throw new Error(`Unpkg redirect escaped the exact package/version path: ${next.href}`);\n }\n url = next.href;\n }\n throw new Error(`Unpkg exceeded ${MAX_REDIRECTS} redirects.`);\n}\n\nfunction parseMetadata(text: string): UnpkgMetadataFile {\n let parsed: unknown;\n try {\n parsed = JSON.parse(text) as unknown;\n } catch {\n throw new Error('Unpkg metadata is not valid JSON.');\n }\n if (!isRecord(parsed) || !Array.isArray(parsed.files)) throw new Error('Unpkg metadata has no files list.');\n const match = parsed.files.find((entry) => isRecord(entry) && entry.path === `/${HELP_INDEX_PATH}`);\n if (!isRecord(match) || typeof match.integrity !== 'string') {\n throw new Error(`Unpkg package does not publish /${HELP_INDEX_PATH}.`);\n }\n const size = typeof match.size === 'number' ? match.size : undefined;\n if (size !== undefined && (!Number.isSafeInteger(size) || size < 0 || size > MAX_LLMS_BYTES)) {\n throw new Error(`Unpkg /${HELP_INDEX_PATH} exceeds the Help size limit.`);\n }\n if (!SRI_PATTERN.test(match.integrity)) throw new Error('Unpkg llms.txt metadata does not contain SHA-256 SRI.');\n return { path: match.path as string, ...(size === undefined ? {} : { size }), integrity: match.integrity };\n}\n\nfunction verifySri(bytes: Uint8Array, integrity: string): void {\n const expected = SRI_PATTERN.exec(integrity)?.[1];\n if (!expected) throw new Error('Invalid llms.txt SRI metadata.');\n const actual = createHash('sha256').update(bytes).digest('base64');\n if (actual !== expected) throw new Error('Downloaded llms.txt failed SRI verification.');\n}\n\nexport class DefaultHelpIndexResolver implements HelpIndexResolver {\n private readonly cache: HelpIndexCache;\n private readonly fetcher: HelpFetch;\n private readonly timeoutMs: number;\n\n constructor(options: DefaultHelpIndexResolverOptions = {}) {\n this.cache = options.cache ?? new HelpIndexCache();\n this.fetcher = options.fetch ?? defaultFetch;\n this.timeoutMs = options.timeoutMs ?? DEFAULT_FETCH_TIMEOUT_MS;\n }\n\n async resolve(contribution: DoomHelpContribution, signal: AbortSignal): Promise<ResolvedHelpIndex> {\n if (signal.aborted) throw new Error('Help activation was cancelled.');\n const identity = resolveHelpPackageIdentity(contribution.moduleUrl, contribution.source);\n const localPath = path.join(identity.packageRoot, HELP_INDEX_PATH);\n if (fs.existsSync(localPath)) {\n if (!isRegularFile(localPath)) throw new Error(`Bundled ${HELP_INDEX_PATH} must be a regular file.`);\n const bytes = fs.readFileSync(localPath);\n validateLlmsBytes(bytes);\n return {\n identity,\n location: 'local',\n filePath: localPath,\n referenceBase: identity.packageRoot,\n byteLength: bytes.byteLength,\n digest: sha256Hex(bytes),\n };\n }\n\n const cached = this.cache.read(identity);\n if (cached) {\n try {\n validateLlmsBytes(cached.bytes);\n return {\n identity,\n location: 'cache',\n filePath: cached.filePath,\n referenceBase: cached.referenceBase,\n byteLength: cached.bytes.byteLength,\n digest: cached.digest,\n };\n } catch {\n this.cache.discard(identity);\n }\n }\n\n const timed = timeoutSignal(signal, this.timeoutMs);\n try {\n const referenceBase = exactUnpkgBase(identity.source, identity.version);\n const metadataResponse = await fetchExact(this.fetcher, `${referenceBase}?meta`, timed.signal);\n const metadataLength = contentLength(metadataResponse);\n if (metadataLength !== undefined && metadataLength > MAX_METADATA_BYTES) {\n throw new Error('Unpkg metadata exceeds the Help metadata size limit.');\n }\n if (!metadataResponse.ok) throw new Error(`Unpkg metadata request failed with HTTP ${metadataResponse.status}.`);\n const metadataText = await metadataResponse.text();\n if (Buffer.byteLength(metadataText, 'utf8') > MAX_METADATA_BYTES) {\n throw new Error('Unpkg metadata exceeds the Help metadata size limit.');\n }\n const metadata = parseMetadata(metadataText);\n const indexResponse = await fetchExact(this.fetcher, `${referenceBase}${HELP_INDEX_PATH}`, timed.signal);\n const indexLength = contentLength(indexResponse);\n if (indexLength !== undefined && indexLength > MAX_LLMS_BYTES) {\n throw new Error(`Downloaded ${HELP_INDEX_PATH} exceeds ${MAX_LLMS_BYTES} bytes.`);\n }\n if (!indexResponse.ok) throw new Error(`Unpkg llms.txt request failed with HTTP ${indexResponse.status}.`);\n const bytes = new Uint8Array(await indexResponse.arrayBuffer());\n validateLlmsBytes(bytes);\n verifySri(bytes, metadata.integrity);\n const published = this.cache.publish(identity, bytes, metadata.integrity, referenceBase, timed.signal);\n return {\n identity,\n location: 'remote',\n filePath: published.filePath,\n referenceBase: published.referenceBase,\n byteLength: published.bytes.byteLength,\n digest: published.digest,\n };\n } finally {\n timed.dispose();\n }\n }\n}\n","import type { DoomHelpContribution, DoomHelpService } from '@agimon-ai/po-core/help';\n\nimport type { HelpFetch } from '../../types/help';\nimport { DefaultHelpActivationService } from '../helpActivation';\nimport { DefaultHelpSkillMaterializer, defaultHelpCacheRoot, HelpIndexCache } from '../helpStorage';\nimport { DefaultHelpIndexResolver } from '../llmsResolver';\n\nexport interface HelpRuntimeOptions {\n cacheRoot?: string;\n fetch?: HelpFetch;\n timeoutMs?: number;\n onBackgroundError?(error: unknown): void;\n}\n\nexport interface HelpRuntimeComposition {\n activation: DefaultHelpActivationService;\n dispose(): void;\n}\n\nfunction reportAsync(error: unknown): void {\n queueMicrotask(() => {\n throw error instanceof Error ? error : new Error(String(error));\n });\n}\n\nexport function createHelpRuntime(service: DoomHelpService, options: HelpRuntimeOptions = {}): HelpRuntimeComposition {\n const cacheRoot = options.cacheRoot ?? defaultHelpCacheRoot();\n const cache = new HelpIndexCache(cacheRoot);\n const activation = new DefaultHelpActivationService({\n resolver: new DefaultHelpIndexResolver({ cache, fetch: options.fetch, timeoutMs: options.timeoutMs }),\n materializer: new DefaultHelpSkillMaterializer(cacheRoot),\n publisher: { publish: (snapshot) => service.publish(snapshot) },\n onBackgroundError(error) {\n if (options.onBackgroundError) options.onBackgroundError(error);\n else reportAsync(error);\n },\n });\n const synchronize = (contributions: readonly DoomHelpContribution[]): void => {\n activation.replaceContributions(contributions);\n };\n const unsubscribe = service.subscribeContributions((contributions) => synchronize(contributions));\n synchronize(service.listContributions());\n let disposed = false;\n return {\n activation,\n dispose() {\n if (disposed) return;\n disposed = true;\n unsubscribe();\n activation.dispose();\n },\n };\n}\n"],"mappings":";;;;;;;;AAIA,MAA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,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;CAChE,CAAC;AACH;AAEA,SAAgB,kBAAkB,SAA0B,UAA8B,CAAC,GAA2B;CACpH,MAAM,YAAY,QAAQ,aAAa,qBAAqB;CAE5D,MAAM,aAAa,IAAI,6BAA6B;EAClD,UAAU,IAAI,yBAAyB;GAAE,WAFzB,eAAe,SAEU;GAAO,OAAO,QAAQ;GAAO,WAAW,QAAQ;EAAU,CAAC;EACpG,cAAc,IAAI,6BAA6B,SAAS;EACxD,WAAW,EAAE,UAAU,aAAa,QAAQ,QAAQ,QAAQ,EAAE;EAC9D,kBAAkB,OAAO;GACvB,IAAI,QAAQ,mBAAmB,QAAQ,kBAAkB,KAAK;QACzD,YAAY,KAAK;EACxB;CACF,CAAC;CACD,MAAM,eAAe,kBAAyD;EAC5E,WAAW,qBAAqB,aAAa;CAC/C;CACA,MAAM,cAAc,QAAQ,wBAAwB,kBAAkB,YAAY,aAAa,CAAC;CAChG,YAAY,QAAQ,kBAAkB,CAAC;CACvC,IAAI,WAAW;CACf,OAAO;EACL;EACA,UAAU;GACR,IAAI,UAAU;GACd,WAAW;GACX,YAAY;GACZ,WAAW,QAAQ;EACrB;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["HELP_INDEX_PATH","isRecord"],"sources":["../src/services/llmsContent/index.ts","../src/services/helpActivation/index.ts","../src/services/helpStorage/index.ts","../src/services/llmsResolver/index.ts","../src/services/helpRuntime/index.ts"],"sourcesContent":["import type { PoHelpSkillDescriptor } from '@agimon-ai/po-core/help';\n\nimport type { ResolvedHelpIndex } from '../../types/help';\n\nexport const MAX_LLMS_BYTES = 1024 * 1024;\nexport const MAX_AGGREGATE_LLMS_BYTES = 4 * MAX_LLMS_BYTES;\n\nconst MARKDOWN_LINK_PATTERN = /!?\\[[^\\]]*\\]\\(\\s*<?([^\\s)>]+)>?(?:\\s+[^)]*)?\\)/gu;\nconst MARKDOWN_REFERENCE_LINK_PATTERN = /^\\s{0,3}\\[[^\\]\\r\\n]+\\]:\\s*<?([^\\s>]+)>?/gmu;\nconst MARKDOWN_AUTOLINK_PATTERN = /<((?:\\.{0,2}\\/|[A-Za-z][A-Za-z0-9+.-]*:)[^<>\\s]+)>/gu;\nconst HTML_LINK_PATTERN = /\\b(?:href|src)\\s*=\\s*[\"']([^\"']+)[\"']/giu;\nconst URI_SCHEME_PATTERN = /^[a-z][a-z0-9+.-]*:/iu;\nconst NESTED_PATH_ENCODING_PATTERN = /%(?:25|2e|2f|3a|5c)/iu;\nconst SAFE_EXTERNAL_SCHEMES = new Set(['http:', 'https:', 'mailto:']);\n\nfunction externalScheme(target: string): string | undefined {\n if (!URI_SCHEME_PATTERN.test(target)) return undefined;\n return target.slice(0, target.indexOf(':') + 1).toLowerCase();\n}\n\nfunction decodeRelativeTarget(rawTarget: string): string {\n let decoded = rawTarget;\n try {\n for (let pass = 0; pass < 2; pass += 1) {\n const next = decodeURIComponent(decoded);\n if (next === decoded) break;\n decoded = next;\n }\n } catch {\n throw new Error(`llms.txt contains an invalid encoded link '${rawTarget}'.`);\n }\n if (NESTED_PATH_ENCODING_PATTERN.test(decoded)) {\n throw new Error(`llms.txt contains an unsafe nested encoding in link '${rawTarget}'.`);\n }\n return decoded;\n}\n\nfunction validateRelativeLink(rawTarget: string): void {\n if (!rawTarget || rawTarget.startsWith('#')) return;\n const rawScheme = externalScheme(rawTarget);\n if (rawScheme) {\n if (!SAFE_EXTERNAL_SCHEMES.has(rawScheme)) {\n throw new Error(`llms.txt contains unsupported link scheme '${rawScheme}'.`);\n }\n return;\n }\n\n const decoded = decodeRelativeTarget(rawTarget);\n const decodedScheme = externalScheme(decoded);\n if (decodedScheme) {\n if (!SAFE_EXTERNAL_SCHEMES.has(decodedScheme)) {\n throw new Error(`llms.txt contains unsupported link scheme '${decodedScheme}'.`);\n }\n return;\n }\n const withoutSuffix = decoded.split(/[?#]/u, 1)[0]?.replaceAll('\\\\', '/') ?? '';\n if (withoutSuffix.startsWith('/') || withoutSuffix.split('/').some((segment) => segment === '..')) {\n throw new Error(`llms.txt link '${rawTarget}' escapes the package root.`);\n }\n}\n\nfunction containsUnsafeControl(text: string): boolean {\n for (const character of text) {\n const code = character.codePointAt(0) ?? 0;\n if ((code >= 0 && code <= 8) || code === 11 || code === 12 || (code >= 14 && code <= 31) || code === 127) {\n return true;\n }\n }\n return false;\n}\n\nexport function validateLlmsBytes(bytes: Uint8Array): string {\n if (bytes.byteLength === 0) throw new Error('llms.txt is empty.');\n if (bytes.byteLength > MAX_LLMS_BYTES) throw new Error(`llms.txt exceeds ${MAX_LLMS_BYTES} bytes.`);\n\n let text: string;\n try {\n text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);\n } catch {\n throw new Error('llms.txt is not valid UTF-8.');\n }\n if (text.startsWith('\\uFEFF')) text = text.slice(1);\n if (containsUnsafeControl(text)) throw new Error('llms.txt contains unsafe control bytes.');\n\n const firstContentLine = text\n .split(/\\r?\\n/u)\n .find((line) => line.trim().length > 0)\n ?.trim();\n if (!firstContentLine || !/^#\\s+\\S/u.test(firstContentLine)) {\n throw new Error('llms.txt must begin with a Markdown H1 heading.');\n }\n for (const pattern of [\n MARKDOWN_LINK_PATTERN,\n MARKDOWN_REFERENCE_LINK_PATTERN,\n MARKDOWN_AUTOLINK_PATTERN,\n HTML_LINK_PATTERN,\n ]) {\n for (const match of text.matchAll(pattern)) validateRelativeLink(match[1] ?? '');\n }\n return text;\n}\n\nexport function renderHelpSkillWrapper(descriptor: PoHelpSkillDescriptor, index: ResolvedHelpIndex): string {\n const name = JSON.stringify(descriptor.name);\n const description = JSON.stringify(descriptor.description);\n const indexPath = JSON.stringify(index.filePath);\n const referenceBase = JSON.stringify(index.referenceBase);\n return `---\\nname: ${name}\\ndescription: ${description}\\n---\\n\\n# Package Help\\n\\nRead the validated package Help index at ${indexPath}.\\nResolve relative links in that index against ${referenceBase}.\\nOpen only the linked documents relevant to the current request, as needed; do not recursively load the whole reference set.\\n`;\n}\n","import {\n PO_HELP_MAX_DIAGNOSTIC_LENGTH,\n PO_HELP_MAX_DIAGNOSTICS,\n PO_HELP_MAX_SKILLS,\n type PoHelpContribution,\n type PoHelpDiagnostic,\n type PoHelpSkill,\n} from '@agimon-ai/po-core/help';\n\nimport type {\n HelpActivationDependencies,\n HelpActivationService,\n HelpRuntimeState,\n ResolvedHelpIndex,\n} from '../../types/help';\nimport { MAX_AGGREGATE_LLMS_BYTES } from '../llmsContent';\n\nconst MAX_RESOLUTION_CONCURRENCY = 4;\nconst FAILURE_MESSAGE = 'No package Help source could be activated.';\nconst CANCELLATION_MESSAGE = 'Help activation was cancelled.';\n\ninterface LoadedSource {\n contribution: PoHelpContribution;\n index: ResolvedHelpIndex;\n skills: readonly PoHelpSkill[];\n}\n\ninterface SourceOutcome {\n source: string;\n loaded?: LoadedSource;\n error?: unknown;\n}\n\nexport class HelpActivationError extends Error {\n constructor(message = FAILURE_MESSAGE) {\n super(message);\n this.name = 'HelpActivationError';\n }\n}\n\nfunction cloneContribution(contribution: PoHelpContribution): PoHelpContribution {\n return {\n source: contribution.source,\n moduleUrl: contribution.moduleUrl,\n skills: contribution.skills.map((skill) => ({ ...skill })),\n };\n}\n\nfunction cloneState(state: HelpRuntimeState): HelpRuntimeState {\n return {\n activation: state.activation,\n skills: state.skills.map((skill) => ({ ...skill })),\n diagnostics: state.diagnostics.map((diagnostic) => ({ ...diagnostic })),\n };\n}\n\nfunction diagnostic(source: string, code: string, error: unknown): PoHelpDiagnostic {\n const raw = error instanceof Error ? error.message : String(error);\n const message = (raw || 'Unknown Help activation failure.').slice(0, PO_HELP_MAX_DIAGNOSTIC_LENGTH);\n return { source, code, message };\n}\n\nfunction contributionFingerprint(contributions: readonly PoHelpContribution[]): string {\n return JSON.stringify(\n contributions.map((contribution) => ({\n source: contribution.source,\n moduleUrl: contribution.moduleUrl,\n skills: contribution.skills,\n })),\n );\n}\n\nexport class DefaultHelpActivationService implements HelpActivationService {\n private readonly dependencies: HelpActivationDependencies;\n private readonly listeners = new Set<(state: HelpRuntimeState) => void>();\n private contributions: PoHelpContribution[] = [];\n private fingerprint = '[]';\n private state: HelpRuntimeState = { activation: 'inactive', skills: [], diagnostics: [] };\n private settledState: HelpRuntimeState = { activation: 'inactive', skills: [], diagnostics: [] };\n private generation = 0;\n private controller: AbortController | undefined;\n private disposed = false;\n\n constructor(dependencies: HelpActivationDependencies) {\n this.dependencies = dependencies;\n }\n\n getState(): HelpRuntimeState {\n return cloneState(this.state);\n }\n\n replaceContributions(contributions: readonly PoHelpContribution[]): void {\n if (this.disposed) return;\n const next = contributions.map(cloneContribution).sort((left, right) => left.source.localeCompare(right.source));\n const fingerprint = contributionFingerprint(next);\n if (fingerprint === this.fingerprint) return;\n const previous = new Map(this.contributions.map((entry) => [entry.source, contributionFingerprint([entry])]));\n const retained = new Set(\n next\n .filter((entry) => previous.get(entry.source) === contributionFingerprint([entry]))\n .map((entry) => entry.source),\n );\n // A refresh may retain unchanged owners, never withdrawn or replaced ones.\n // Prune the rollback snapshot too, so cancellation cannot resurrect them.\n const skills = this.settledState.skills.filter((entry) => retained.has(entry.source));\n const diagnostics = this.settledState.diagnostics.filter((entry) => !entry.source || retained.has(entry.source));\n this.settledState = {\n activation: skills.length === 0 ? 'inactive' : diagnostics.length > 0 ? 'degraded' : 'active',\n skills,\n diagnostics,\n };\n this.contributions = next;\n this.fingerprint = fingerprint;\n if (this.state.activation !== 'inactive') {\n void this.activate().catch((error: unknown) => {\n // Activation failures publish a bounded settled state before rejecting.\n // Only unexpected implementation failures need an out-of-band report.\n if (error instanceof HelpActivationError) return;\n this.dependencies.onBackgroundError(error);\n });\n }\n }\n\n subscribe(listener: (state: HelpRuntimeState) => void): () => void {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n }\n\n private publish(state: HelpRuntimeState): HelpRuntimeState {\n this.state = cloneState(state);\n if (state.activation !== 'activating') this.settledState = cloneState(state);\n this.dependencies.publisher.publish(this.state);\n for (const listener of this.listeners) listener(cloneState(this.state));\n return this.getState();\n }\n\n private async loadSources(signal: AbortSignal): Promise<SourceOutcome[]> {\n const contributions = this.contributions;\n const outcomes: SourceOutcome[] = Array.from({ length: contributions.length });\n let cursor = 0;\n const worker = async (): Promise<void> => {\n while (cursor < contributions.length) {\n const index = cursor;\n cursor += 1;\n const contribution = contributions[index];\n if (!contribution) return;\n if (signal.aborted) throw new HelpActivationError(CANCELLATION_MESSAGE);\n try {\n const resolved = await this.dependencies.resolver.resolve(contribution, signal);\n if (signal.aborted) throw new HelpActivationError(CANCELLATION_MESSAGE);\n const skills = await this.dependencies.materializer.materialize(contribution, resolved, signal);\n outcomes[index] = { source: contribution.source, loaded: { contribution, index: resolved, skills } };\n } catch (error) {\n if (signal.aborted) throw new HelpActivationError(CANCELLATION_MESSAGE);\n outcomes[index] = { source: contribution.source, error };\n }\n }\n };\n const count = Math.min(MAX_RESOLUTION_CONCURRENCY, contributions.length);\n await Promise.all(Array.from({ length: count }, () => worker()));\n return outcomes;\n }\n\n async activate(externalSignal?: AbortSignal): Promise<HelpRuntimeState> {\n if (this.disposed) throw new HelpActivationError('Help runtime is disposed.');\n this.controller?.abort('Help activation generation replaced.');\n const controller = new AbortController();\n this.controller = controller;\n const generation = ++this.generation;\n const abortFromExternal = () => controller.abort(externalSignal?.reason);\n externalSignal?.addEventListener('abort', abortFromExternal, { once: true });\n if (externalSignal?.aborted) abortFromExternal();\n\n const settledState = cloneState(this.settledState);\n this.publish({ activation: 'activating', skills: settledState.skills, diagnostics: settledState.diagnostics });\n try {\n const outcomes = await this.loadSources(controller.signal);\n if (controller.signal.aborted || generation !== this.generation) {\n throw new HelpActivationError(CANCELLATION_MESSAGE);\n }\n\n const diagnostics: PoHelpDiagnostic[] = [];\n const loaded: LoadedSource[] = [];\n let aggregateBytes = 0;\n for (const outcome of outcomes) {\n if (!outcome) continue;\n if (outcome.error || !outcome.loaded) {\n diagnostics.push(diagnostic(outcome.source, 'HELP_SOURCE_FAILED', outcome.error));\n continue;\n }\n if (aggregateBytes + outcome.loaded.index.byteLength > MAX_AGGREGATE_LLMS_BYTES) {\n diagnostics.push(\n diagnostic(outcome.source, 'HELP_AGGREGATE_LIMIT', 'The aggregate llms.txt byte limit was exceeded.'),\n );\n continue;\n }\n aggregateBytes += outcome.loaded.index.byteLength;\n loaded.push(outcome.loaded);\n }\n\n const skills: PoHelpSkill[] = [];\n const names = new Set<string>();\n for (const source of loaded) {\n for (const skill of source.skills) {\n if (skills.length >= PO_HELP_MAX_SKILLS) {\n diagnostics.push(\n diagnostic(source.contribution.source, 'HELP_SKILL_LIMIT', 'The Help skill limit was reached.'),\n );\n break;\n }\n if (names.has(skill.name)) {\n diagnostics.push(\n diagnostic(\n source.contribution.source,\n 'HELP_SKILL_COLLISION',\n `Help skill '${skill.name}' was already provided by an earlier package source.`,\n ),\n );\n continue;\n }\n names.add(skill.name);\n skills.push({ ...skill });\n }\n }\n\n const boundedDiagnostics = diagnostics.slice(0, PO_HELP_MAX_DIAGNOSTICS);\n if (skills.length === 0) {\n this.publish({ activation: 'inactive', skills: [], diagnostics: boundedDiagnostics });\n throw new HelpActivationError();\n }\n return this.publish({\n activation: boundedDiagnostics.length > 0 ? 'degraded' : 'active',\n skills,\n diagnostics: boundedDiagnostics,\n });\n } catch (error) {\n if (generation === this.generation && this.state.activation === 'activating') this.publish(settledState);\n throw error;\n } finally {\n externalSignal?.removeEventListener('abort', abortFromExternal);\n if (this.controller === controller) this.controller = undefined;\n }\n }\n\n deactivate(): HelpRuntimeState {\n this.generation += 1;\n this.controller?.abort('Help deactivated.');\n this.controller = undefined;\n return this.publish({ activation: 'inactive', skills: [], diagnostics: [] });\n }\n\n dispose(): void {\n if (this.disposed) return;\n this.deactivate();\n this.disposed = true;\n this.listeners.clear();\n }\n}\n","import { createHash, randomUUID } from 'node:crypto';\nimport fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nimport type { PoHelpContribution, PoHelpSkill } from '@agimon-ai/po-core/help';\nimport { poHomeDirectory } from '@agimon-ai/po-core/piSettings';\n\nimport type { HelpPackageIdentity, HelpSkillMaterializer, ResolvedHelpIndex } from '../../types/help';\nimport { renderHelpSkillWrapper } from '../llmsContent';\n\nconst PACKAGE_MANIFEST = 'package.json';\nconst HELP_INDEX_PATH = 'llms.txt';\nconst CACHE_SCHEMA_VERSION = 1;\nconst PRIVATE_FILE_MODE = 0o600;\nconst PRIVATE_DIRECTORY_MODE = 0o700;\nconst COMPLETION_FILE = '.complete';\nconst CACHE_METADATA_FILE = 'metadata.json';\nconst WRAPPER_DIRECTORY = 'wrappers';\nconst SKILL_FILE = 'SKILL.md';\nconst EXACT_SEMVER_PATTERN =\n /^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?$/u;\nconst NPM_PACKAGE_NAME_PATTERN = /^(?:@[a-z0-9][a-z0-9._~-]*\\/)?[a-z0-9][a-z0-9._~-]*$/u;\n\ninterface CacheMetadata {\n schemaVersion: typeof CACHE_SCHEMA_VERSION;\n source: string;\n version: string;\n path: typeof HELP_INDEX_PATH;\n integrity: string;\n digest: string;\n referenceBase: string;\n}\n\nexport interface CachedHelpIndex {\n bytes: Uint8Array;\n filePath: string;\n integrity: string;\n digest: string;\n referenceBase: string;\n}\n\nfunction assertNotAborted(signal: AbortSignal): void {\n if (signal.aborted) throw new Error('Help activation was cancelled.');\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isContained(root: string, candidate: string): boolean {\n const relative = path.relative(root, candidate);\n return relative === '' || (!relative.startsWith(`..${path.sep}`) && relative !== '..' && !path.isAbsolute(relative));\n}\n\nfunction readManifest(filePath: string): Record<string, unknown> {\n let parsed: unknown;\n try {\n parsed = JSON.parse(fs.readFileSync(filePath, 'utf8')) as unknown;\n } catch (error) {\n throw new Error(\n `Cannot read Help package manifest at ${filePath}: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n if (!isRecord(parsed)) throw new Error(`Help package manifest at ${filePath} must contain an object.`);\n return parsed;\n}\n\nexport function resolveHelpPackageIdentity(moduleUrl: string, expectedSource: string): HelpPackageIdentity {\n if (!NPM_PACKAGE_NAME_PATTERN.test(expectedSource)) {\n throw new Error(`Help source '${expectedSource}' must be a valid lowercase npm package name.`);\n }\n let modulePath: string;\n try {\n const url = new URL(moduleUrl);\n if (url.protocol !== 'file:') throw new Error(`Help module URL must use file:, received ${url.protocol}`);\n modulePath = fs.realpathSync(fileURLToPath(url));\n } catch (error) {\n throw new Error(\n `Invalid Help contributor module URL '${moduleUrl}': ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n if (!fs.lstatSync(modulePath).isFile())\n throw new Error(`Help contributor module is not a regular file: ${modulePath}`);\n\n let directory = path.dirname(modulePath);\n while (true) {\n const manifestPath = path.join(directory, PACKAGE_MANIFEST);\n if (fs.existsSync(manifestPath)) {\n const manifest = readManifest(manifestPath);\n const source = manifest.name;\n const version = manifest.version;\n if (source !== expectedSource) {\n throw new Error(`Help source '${expectedSource}' does not match nearest package '${String(source)}'.`);\n }\n if (typeof version !== 'string' || !EXACT_SEMVER_PATTERN.test(version)) {\n throw new Error(`Help package '${expectedSource}' must declare an exact semantic version.`);\n }\n const packageRoot = fs.realpathSync(directory);\n if (!isContained(packageRoot, modulePath))\n throw new Error('Help contributor module escapes its resolved package root.');\n return { source: expectedSource, version, packageRoot, modulePath };\n }\n const parent = path.dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n throw new Error(`Cannot find a package manifest for Help contributor ${modulePath}.`);\n}\n\nexport function defaultHelpCacheRoot(homeDirectory = os.homedir()): string {\n return path.join(poHomeDirectory(homeDirectory), 'llms-cache');\n}\n\nexport function sha256Hex(bytes: Uint8Array | string): string {\n return createHash('sha256').update(bytes).digest('hex');\n}\n\nfunction parseCacheMetadata(value: unknown, identity: HelpPackageIdentity): CacheMetadata | undefined {\n if (!isRecord(value)) return undefined;\n if (\n value.schemaVersion !== CACHE_SCHEMA_VERSION ||\n value.source !== identity.source ||\n value.version !== identity.version ||\n value.path !== HELP_INDEX_PATH ||\n typeof value.integrity !== 'string' ||\n typeof value.digest !== 'string' ||\n typeof value.referenceBase !== 'string'\n ) {\n return undefined;\n }\n return value as unknown as CacheMetadata;\n}\n\nfunction regularFile(filePath: string): boolean {\n try {\n const metadata = fs.lstatSync(filePath);\n return metadata.isFile() && !metadata.isSymbolicLink();\n } catch {\n return false;\n }\n}\n\nexport class HelpIndexCache {\n readonly root: string;\n\n constructor(root = defaultHelpCacheRoot()) {\n this.root = root;\n }\n\n entryDirectory(identity: HelpPackageIdentity): string {\n const key = sha256Hex(`${identity.source}\\0${identity.version}\\0${HELP_INDEX_PATH}`);\n return path.join(this.root, key);\n }\n\n discard(identity: HelpPackageIdentity): void {\n fs.rmSync(this.entryDirectory(identity), { recursive: true, force: true });\n }\n\n read(identity: HelpPackageIdentity): CachedHelpIndex | undefined {\n const directory = this.entryDirectory(identity);\n const completionPath = path.join(directory, COMPLETION_FILE);\n const indexPath = path.join(directory, HELP_INDEX_PATH);\n const metadataPath = path.join(directory, CACHE_METADATA_FILE);\n if (!regularFile(completionPath) || !regularFile(indexPath) || !regularFile(metadataPath)) return undefined;\n try {\n const metadata = parseCacheMetadata(JSON.parse(fs.readFileSync(metadataPath, 'utf8')) as unknown, identity);\n if (!metadata) return undefined;\n const bytes = fs.readFileSync(indexPath);\n if (sha256Hex(bytes) !== metadata.digest) return undefined;\n if (fs.readFileSync(completionPath, 'utf8').trim() !== metadata.digest) return undefined;\n return {\n bytes,\n filePath: indexPath,\n integrity: metadata.integrity,\n digest: metadata.digest,\n referenceBase: metadata.referenceBase,\n };\n } catch {\n return undefined;\n }\n }\n\n publish(\n identity: HelpPackageIdentity,\n bytes: Uint8Array,\n integrity: string,\n referenceBase: string,\n signal: AbortSignal,\n ): CachedHelpIndex {\n assertNotAborted(signal);\n const existing = this.read(identity);\n if (existing) return existing;\n const directory = this.entryDirectory(identity);\n fs.mkdirSync(this.root, { mode: PRIVATE_DIRECTORY_MODE, recursive: true });\n if (fs.existsSync(directory)) fs.rmSync(directory, { recursive: true, force: true });\n const temporary = `${directory}.${process.pid}.${randomUUID()}.tmp`;\n const digest = sha256Hex(bytes);\n const metadata: CacheMetadata = {\n schemaVersion: CACHE_SCHEMA_VERSION,\n source: identity.source,\n version: identity.version,\n path: HELP_INDEX_PATH,\n integrity,\n digest,\n referenceBase,\n };\n try {\n fs.mkdirSync(temporary, { mode: PRIVATE_DIRECTORY_MODE });\n fs.writeFileSync(path.join(temporary, HELP_INDEX_PATH), bytes, { mode: PRIVATE_FILE_MODE });\n fs.writeFileSync(path.join(temporary, CACHE_METADATA_FILE), `${JSON.stringify(metadata, null, 2)}\\n`, {\n mode: PRIVATE_FILE_MODE,\n });\n assertNotAborted(signal);\n fs.writeFileSync(path.join(temporary, COMPLETION_FILE), `${digest}\\n`, { mode: PRIVATE_FILE_MODE });\n try {\n fs.renameSync(temporary, directory);\n } catch (error) {\n const winner = this.read(identity);\n if (winner) return winner;\n throw error;\n }\n return {\n bytes: Uint8Array.from(bytes),\n filePath: path.join(directory, HELP_INDEX_PATH),\n integrity,\n digest,\n referenceBase,\n };\n } finally {\n fs.rmSync(temporary, { recursive: true, force: true });\n }\n }\n}\n\nexport class DefaultHelpSkillMaterializer implements HelpSkillMaterializer {\n constructor(private readonly cacheRoot = defaultHelpCacheRoot()) {}\n\n async materialize(\n contribution: PoHelpContribution,\n index: ResolvedHelpIndex,\n signal: AbortSignal,\n ): Promise<readonly PoHelpSkill[]> {\n const skills: PoHelpSkill[] = [];\n for (const descriptor of contribution.skills) {\n assertNotAborted(signal);\n const key = sha256Hex(\n `${index.identity.source}\\0${index.identity.version}\\0${descriptor.name}\\0${descriptor.description}\\0${index.digest}`,\n );\n const directory = path.join(this.cacheRoot, WRAPPER_DIRECTORY, key);\n const filePath = path.join(directory, SKILL_FILE);\n const content = renderHelpSkillWrapper(descriptor, index);\n if (!regularFile(filePath) || fs.readFileSync(filePath, 'utf8') !== content) {\n fs.mkdirSync(path.dirname(directory), { mode: PRIVATE_DIRECTORY_MODE, recursive: true });\n if (fs.existsSync(directory)) fs.rmSync(directory, { recursive: true, force: true });\n const temporary = `${directory}.${process.pid}.${randomUUID()}.tmp`;\n try {\n fs.mkdirSync(temporary, { mode: PRIVATE_DIRECTORY_MODE });\n fs.writeFileSync(path.join(temporary, SKILL_FILE), content, { mode: PRIVATE_FILE_MODE });\n assertNotAborted(signal);\n try {\n fs.renameSync(temporary, directory);\n } catch (error) {\n if (!regularFile(filePath) || fs.readFileSync(filePath, 'utf8') !== content) throw error;\n }\n } finally {\n fs.rmSync(temporary, { recursive: true, force: true });\n }\n }\n skills.push({\n source: contribution.source,\n name: descriptor.name,\n description: descriptor.description,\n filePath,\n baseDir: directory,\n });\n }\n return skills;\n }\n}\n","import { createHash } from 'node:crypto';\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nimport type { PoHelpContribution } from '@agimon-ai/po-core/help';\n\nimport type { HelpFetch, HelpFetchResponse, HelpIndexResolver, ResolvedHelpIndex } from '../../types/help';\nimport { HelpIndexCache, resolveHelpPackageIdentity, sha256Hex } from '../helpStorage';\nimport { MAX_LLMS_BYTES, validateLlmsBytes } from '../llmsContent';\n\nconst HELP_INDEX_PATH = 'llms.txt';\nconst UNPKG_ORIGIN = 'https://unpkg.com';\nconst DEFAULT_FETCH_TIMEOUT_MS = 5_000;\nconst MAX_METADATA_BYTES = 512 * 1024;\nconst MAX_REDIRECTS = 3;\nconst SRI_PATTERN = /^sha256-([A-Za-z0-9+/]+={0,2})$/u;\n\ninterface UnpkgMetadataFile {\n path: string;\n size?: number;\n integrity: string;\n}\n\nexport interface DefaultHelpIndexResolverOptions {\n cache?: HelpIndexCache;\n fetch?: HelpFetch;\n timeoutMs?: number;\n}\n\nfunction defaultFetch(input: string, init: { signal: AbortSignal; redirect: 'manual' }): Promise<HelpFetchResponse> {\n return fetch(input, init) as unknown as Promise<HelpFetchResponse>;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction isRegularFile(filePath: string): boolean {\n try {\n const metadata = fs.lstatSync(filePath);\n return metadata.isFile() && !metadata.isSymbolicLink();\n } catch {\n return false;\n }\n}\n\nfunction unpkgPackagePath(source: string, version: string): string {\n const encoded = source\n .split('/')\n .map((segment) =>\n segment.startsWith('@') ? `@${encodeURIComponent(segment.slice(1))}` : encodeURIComponent(segment),\n )\n .join('/');\n return `${encoded}@${encodeURIComponent(version)}`;\n}\n\nfunction exactUnpkgBase(source: string, version: string): string {\n return `${UNPKG_ORIGIN}/${unpkgPackagePath(source, version)}/`;\n}\n\nfunction contentLength(response: HelpFetchResponse): number | undefined {\n const raw = response.headers.get('content-length');\n if (!raw) return undefined;\n const parsed = Number.parseInt(raw, 10);\n return Number.isFinite(parsed) && parsed >= 0 ? parsed : undefined;\n}\n\nfunction timeoutSignal(parent: AbortSignal, timeoutMs: number): { signal: AbortSignal; dispose(): void } {\n const controller = new AbortController();\n const abort = () => controller.abort(parent.reason);\n parent.addEventListener('abort', abort, { once: true });\n const timer = setTimeout(() => controller.abort(new Error('Help download timed out.')), timeoutMs);\n if (parent.aborted) abort();\n return {\n signal: controller.signal,\n dispose() {\n clearTimeout(timer);\n parent.removeEventListener('abort', abort);\n },\n };\n}\n\nasync function fetchExact(fetcher: HelpFetch, initialUrl: string, signal: AbortSignal): Promise<HelpFetchResponse> {\n let url = initialUrl;\n const expected = new URL(initialUrl);\n for (let redirect = 0; redirect <= MAX_REDIRECTS; redirect += 1) {\n const response = await fetcher(url, { signal, redirect: 'manual' });\n if (response.status < 300 || response.status >= 400) return response;\n const location = response.headers.get('location');\n if (!location) throw new Error(`Unpkg redirected ${url} without a location.`);\n const next = new URL(location, url);\n if (next.origin !== UNPKG_ORIGIN || next.pathname !== expected.pathname || next.search !== expected.search) {\n throw new Error(`Unpkg redirect escaped the exact package/version path: ${next.href}`);\n }\n url = next.href;\n }\n throw new Error(`Unpkg exceeded ${MAX_REDIRECTS} redirects.`);\n}\n\nfunction parseMetadata(text: string): UnpkgMetadataFile {\n let parsed: unknown;\n try {\n parsed = JSON.parse(text) as unknown;\n } catch {\n throw new Error('Unpkg metadata is not valid JSON.');\n }\n if (!isRecord(parsed) || !Array.isArray(parsed.files)) throw new Error('Unpkg metadata has no files list.');\n const match = parsed.files.find((entry) => isRecord(entry) && entry.path === `/${HELP_INDEX_PATH}`);\n if (!isRecord(match) || typeof match.integrity !== 'string') {\n throw new Error(`Unpkg package does not publish /${HELP_INDEX_PATH}.`);\n }\n const size = typeof match.size === 'number' ? match.size : undefined;\n if (size !== undefined && (!Number.isSafeInteger(size) || size < 0 || size > MAX_LLMS_BYTES)) {\n throw new Error(`Unpkg /${HELP_INDEX_PATH} exceeds the Help size limit.`);\n }\n if (!SRI_PATTERN.test(match.integrity)) throw new Error('Unpkg llms.txt metadata does not contain SHA-256 SRI.');\n return { path: match.path as string, ...(size === undefined ? {} : { size }), integrity: match.integrity };\n}\n\nfunction verifySri(bytes: Uint8Array, integrity: string): void {\n const expected = SRI_PATTERN.exec(integrity)?.[1];\n if (!expected) throw new Error('Invalid llms.txt SRI metadata.');\n const actual = createHash('sha256').update(bytes).digest('base64');\n if (actual !== expected) throw new Error('Downloaded llms.txt failed SRI verification.');\n}\n\nexport class DefaultHelpIndexResolver implements HelpIndexResolver {\n private readonly cache: HelpIndexCache;\n private readonly fetcher: HelpFetch;\n private readonly timeoutMs: number;\n\n constructor(options: DefaultHelpIndexResolverOptions = {}) {\n this.cache = options.cache ?? new HelpIndexCache();\n this.fetcher = options.fetch ?? defaultFetch;\n this.timeoutMs = options.timeoutMs ?? DEFAULT_FETCH_TIMEOUT_MS;\n }\n\n async resolve(contribution: PoHelpContribution, signal: AbortSignal): Promise<ResolvedHelpIndex> {\n if (signal.aborted) throw new Error('Help activation was cancelled.');\n const identity = resolveHelpPackageIdentity(contribution.moduleUrl, contribution.source);\n const localPath = path.join(identity.packageRoot, HELP_INDEX_PATH);\n if (fs.existsSync(localPath)) {\n if (!isRegularFile(localPath)) throw new Error(`Bundled ${HELP_INDEX_PATH} must be a regular file.`);\n const bytes = fs.readFileSync(localPath);\n validateLlmsBytes(bytes);\n return {\n identity,\n location: 'local',\n filePath: localPath,\n referenceBase: identity.packageRoot,\n byteLength: bytes.byteLength,\n digest: sha256Hex(bytes),\n };\n }\n\n const cached = this.cache.read(identity);\n if (cached) {\n try {\n validateLlmsBytes(cached.bytes);\n return {\n identity,\n location: 'cache',\n filePath: cached.filePath,\n referenceBase: cached.referenceBase,\n byteLength: cached.bytes.byteLength,\n digest: cached.digest,\n };\n } catch {\n this.cache.discard(identity);\n }\n }\n\n const timed = timeoutSignal(signal, this.timeoutMs);\n try {\n const referenceBase = exactUnpkgBase(identity.source, identity.version);\n const metadataResponse = await fetchExact(this.fetcher, `${referenceBase}?meta`, timed.signal);\n const metadataLength = contentLength(metadataResponse);\n if (metadataLength !== undefined && metadataLength > MAX_METADATA_BYTES) {\n throw new Error('Unpkg metadata exceeds the Help metadata size limit.');\n }\n if (!metadataResponse.ok) throw new Error(`Unpkg metadata request failed with HTTP ${metadataResponse.status}.`);\n const metadataText = await metadataResponse.text();\n if (Buffer.byteLength(metadataText, 'utf8') > MAX_METADATA_BYTES) {\n throw new Error('Unpkg metadata exceeds the Help metadata size limit.');\n }\n const metadata = parseMetadata(metadataText);\n const indexResponse = await fetchExact(this.fetcher, `${referenceBase}${HELP_INDEX_PATH}`, timed.signal);\n const indexLength = contentLength(indexResponse);\n if (indexLength !== undefined && indexLength > MAX_LLMS_BYTES) {\n throw new Error(`Downloaded ${HELP_INDEX_PATH} exceeds ${MAX_LLMS_BYTES} bytes.`);\n }\n if (!indexResponse.ok) throw new Error(`Unpkg llms.txt request failed with HTTP ${indexResponse.status}.`);\n const bytes = new Uint8Array(await indexResponse.arrayBuffer());\n validateLlmsBytes(bytes);\n verifySri(bytes, metadata.integrity);\n const published = this.cache.publish(identity, bytes, metadata.integrity, referenceBase, timed.signal);\n return {\n identity,\n location: 'remote',\n filePath: published.filePath,\n referenceBase: published.referenceBase,\n byteLength: published.bytes.byteLength,\n digest: published.digest,\n };\n } finally {\n timed.dispose();\n }\n }\n}\n","import type { PoHelpContribution, PoHelpService } from '@agimon-ai/po-core/help';\n\nimport type { HelpFetch } from '../../types/help';\nimport { DefaultHelpActivationService } from '../helpActivation';\nimport { DefaultHelpSkillMaterializer, defaultHelpCacheRoot, HelpIndexCache } from '../helpStorage';\nimport { DefaultHelpIndexResolver } from '../llmsResolver';\n\nexport interface HelpRuntimeOptions {\n cacheRoot?: string;\n fetch?: HelpFetch;\n timeoutMs?: number;\n onBackgroundError?(error: unknown): void;\n}\n\nexport interface HelpRuntimeComposition {\n activation: DefaultHelpActivationService;\n dispose(): void;\n}\n\nfunction reportAsync(error: unknown): void {\n queueMicrotask(() => {\n throw error instanceof Error ? error : new Error(String(error));\n });\n}\n\nexport function createHelpRuntime(service: PoHelpService, options: HelpRuntimeOptions = {}): HelpRuntimeComposition {\n const cacheRoot = options.cacheRoot ?? defaultHelpCacheRoot();\n const cache = new HelpIndexCache(cacheRoot);\n const activation = new DefaultHelpActivationService({\n resolver: new DefaultHelpIndexResolver({ cache, fetch: options.fetch, timeoutMs: options.timeoutMs }),\n materializer: new DefaultHelpSkillMaterializer(cacheRoot),\n publisher: { publish: (snapshot) => service.publish(snapshot) },\n onBackgroundError(error) {\n if (options.onBackgroundError) options.onBackgroundError(error);\n else reportAsync(error);\n },\n });\n const synchronize = (contributions: readonly PoHelpContribution[]): void => {\n activation.replaceContributions(contributions);\n };\n const unsubscribe = service.subscribeContributions((contributions) => synchronize(contributions));\n synchronize(service.listContributions());\n let disposed = false;\n return {\n activation,\n dispose() {\n if (disposed) return;\n disposed = true;\n unsubscribe();\n activation.dispose();\n },\n };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zC,qBAAqB;EACnB,MAAM,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;CAChE,CAAC;AACH;AAEA,SAAgB,kBAAkB,SAAwB,UAA8B,CAAC,GAA2B;CAClH,MAAM,YAAY,QAAQ,aAAa,qBAAqB;CAE5D,MAAM,aAAa,IAAI,6BAA6B;EAClD,UAAU,IAAI,yBAAyB;GAAE,WAFzB,eAAe,SAEU;GAAO,OAAO,QAAQ;GAAO,WAAW,QAAQ;EAAU,CAAC;EACpG,cAAc,IAAI,6BAA6B,SAAS;EACxD,WAAW,EAAE,UAAU,aAAa,QAAQ,QAAQ,QAAQ,EAAE;EAC9D,kBAAkB,OAAO;GACvB,IAAI,QAAQ,mBAAmB,QAAQ,kBAAkB,KAAK;QACzD,YAAY,KAAK;EACxB;CACF,CAAC;CACD,MAAM,eAAe,kBAAuD;EAC1E,WAAW,qBAAqB,aAAa;CAC/C;CACA,MAAM,cAAc,QAAQ,wBAAwB,kBAAkB,YAAY,aAAa,CAAC;CAChG,YAAY,QAAQ,kBAAkB,CAAC;CACvC,IAAI,WAAW;CACf,OAAO;EACL;EACA,UAAU;GACR,IAAI,UAAU;GACd,WAAW;GACX,YAAY;GACZ,WAAW,QAAQ;EACrB;CACF;AACF"}
|
package/llms.txt
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po-help",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.5",
|
|
4
4
|
"description": "Activation-gated package guidance and help skills for Po and Pi extensions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-documentation",
|
|
@@ -58,24 +58,24 @@
|
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
62
|
-
"@agimon-ai/po-minor-mode": "0.0.0-alpha.
|
|
63
|
-
"@agimon-ai/po-web-components": "0.0.0-alpha.
|
|
61
|
+
"@agimon-ai/po-core": "0.0.0-alpha.5",
|
|
62
|
+
"@agimon-ai/po-minor-mode": "0.0.0-alpha.5",
|
|
63
|
+
"@agimon-ai/po-web-components": "0.0.0-alpha.5",
|
|
64
64
|
"@deepseek-ai/cordis": "4.0.4",
|
|
65
|
-
"typebox": "1.3.
|
|
65
|
+
"typebox": "1.3.37"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@agimon-ai/po-build": "0.0.0-alpha.
|
|
69
|
-
"@agimon-ai/vibe-lint-plugin-
|
|
68
|
+
"@agimon-ai/po-build": "0.0.0-alpha.5",
|
|
69
|
+
"@agimon-ai/vibe-lint-plugin-po-extension": "0.0.0-alpha.5",
|
|
70
70
|
"@earendil-works/pi-coding-agent": "1.2.0",
|
|
71
|
-
"@types/node": "
|
|
71
|
+
"@types/node": "26.6.5",
|
|
72
72
|
"@types/react": "19.3.0",
|
|
73
|
-
"@vitest/coverage-v8": "5.0.
|
|
73
|
+
"@vitest/coverage-v8": "5.0.4",
|
|
74
74
|
"react": "19.3.0",
|
|
75
75
|
"react-dom": "19.3.0",
|
|
76
76
|
"tsdown": "0.23.1",
|
|
77
77
|
"typescript": "7.0.2",
|
|
78
|
-
"vitest": "5.0.
|
|
78
|
+
"vitest": "5.0.4"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"@earendil-works/pi-coding-agent": "1.2.0"
|
|
@@ -3,13 +3,13 @@ name: po-use-help
|
|
|
3
3
|
description: Set up and debug Po agents using installed package guidance and scoped, read-only diagnostics. Diagnose missing capabilities before proposing authorized repairs.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Use
|
|
6
|
+
# Use Po Pi Help
|
|
7
7
|
|
|
8
8
|
Use Help for agent setup, configuration, missing capabilities, and debugging the current session. Start from the user's expected behavior and an observed symptom. A skill describes a workflow; it does not grant the tools or permissions mentioned in it.
|
|
9
9
|
|
|
10
10
|
## Activate and inspect
|
|
11
11
|
|
|
12
|
-
Toggle Help through the minor-mode menu, `SPC h e`, `/minor help`, or `/
|
|
12
|
+
Toggle Help through the minor-mode menu, `SPC h e`, `/minor help`, or `/po-help`. The command toggles on both Pi and the web/server host. Activation adds Help-only guidance and diagnostics without replacing the ordinary tool set or changing other modes.
|
|
13
13
|
|
|
14
14
|
Call `help_status` to inspect the applied Help capabilities and their owners. A pending skill count means discovery has not completed or its consumer is unavailable, not that every registered descriptor is usable. Report degraded contributors separately and continue with healthy contributions. Missing, shadowed, restricted, and unavailable resources are different conditions.
|
|
15
15
|
|