@agimon-ai/po-help 0.0.0-alpha.7 → 0.0.0-alpha.70
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/LICENSE +149 -21
- package/README.md +7 -5
- package/dist/apiContracts.cjs +1 -1
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.d.mts +1 -1
- package/dist/apiContracts.mjs +1 -1
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/extensions/server.cjs +236 -24
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts +2 -2
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +235 -23
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/index.cjs +109 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +108 -83
- package/dist/index.mjs.map +1 -1
- package/llms.txt +5 -3
- package/package.json +14 -14
- package/src/prompts/codemode-how-to-self-improve/SKILL.md +41 -0
- package/src/prompts/{po-use-chatgpt-instructions → help-how-to-chatgpt-instructions}/SKILL.md +1 -1
- package/src/prompts/help-how-to-codemode-plugin/SKILL.md +58 -0
- package/src/prompts/{po-use-help → help-how-to-help}/SKILL.md +2 -4
- package/src/prompts/{po-develop-native-extension → help-how-to-native-extension}/SKILL.md +3 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,149 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
2
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
3
|
+
|
|
4
|
+
Parameters
|
|
5
|
+
|
|
6
|
+
Licensor: Agimon Pty Ltd
|
|
7
|
+
Licensed Work: Po, the software in the Po source repository and the
|
|
8
|
+
packages released from it, in each version released by
|
|
9
|
+
the Licensor.
|
|
10
|
+
The Licensed Work is (c) 2026 Agimon Pty Ltd.
|
|
11
|
+
Material identified as third-party in the "Third-party
|
|
12
|
+
components" section at the end of this file or in a
|
|
13
|
+
NOTICE file, and any package or directory whose own
|
|
14
|
+
license file grants a different license, is not part of
|
|
15
|
+
the Licensed Work and remains under its own license.
|
|
16
|
+
Additional Use Grant: You may make production use of the Licensed Work if
|
|
17
|
+
your use is Eligible Use. "Eligible Use" is production use that falls
|
|
18
|
+
within at least one of the following:
|
|
19
|
+
|
|
20
|
+
(a) Personal Use. Use by an individual for their own personal purposes,
|
|
21
|
+
and not on behalf of, or for the benefit of, an employer, client, or
|
|
22
|
+
other Organization. Use by an individual in the course of employment
|
|
23
|
+
or engagement by an Organization is use by that Organization.
|
|
24
|
+
|
|
25
|
+
(b) Small Organization Use. Use by or on behalf of an Organization whose
|
|
26
|
+
Annual Revenue is less than USD 1,000,000.
|
|
27
|
+
|
|
28
|
+
(c) Non-profit, Education and Research Use. Use, regardless of Annual
|
|
29
|
+
Revenue, by (i) an Organization registered or recognized as a
|
|
30
|
+
non-profit or charitable organization under the laws of its
|
|
31
|
+
jurisdiction, for its non-profit purposes; (ii) an accredited school,
|
|
32
|
+
college, or university, for teaching, learning, or academic research;
|
|
33
|
+
or (iii) a publicly funded research institution, for its research.
|
|
34
|
+
|
|
35
|
+
(d) Service Provider Use. Use by a consultant, contractor, agency, or other
|
|
36
|
+
service provider, regardless of its own Annual Revenue, solely to
|
|
37
|
+
build, deploy, host, operate, or support the Licensed Work for a client
|
|
38
|
+
whose own use would be Eligible Use under (a), (b), or (c). A service
|
|
39
|
+
provider's use for its own purposes is Eligible Use only if the service
|
|
40
|
+
provider itself qualifies under (b) or (c).
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
Hosted services. Offering the Licensed Work to third parties as a hosted
|
|
44
|
+
or managed service whose primary value is the Licensed Work is Eligible
|
|
45
|
+
Use only if each such third party's own use would be Eligible Use.
|
|
46
|
+
|
|
47
|
+
Definitions. "Organization" means any company, partnership, sole
|
|
48
|
+
proprietorship, trust, association, government body, or other entity, and
|
|
49
|
+
includes an individual acting in a business or professional capacity.
|
|
50
|
+
"Affiliate" means any entity that directly or indirectly controls, is
|
|
51
|
+
controlled by, or is under common control with an Organization, where
|
|
52
|
+
"control" means ownership of more than 50% of the voting interests of an
|
|
53
|
+
entity or the power to direct its management and policies by contract or
|
|
54
|
+
otherwise. "Annual Revenue" means the total gross revenue of an
|
|
55
|
+
Organization and all of its Affiliates combined, from all sources and
|
|
56
|
+
whether or not related to the Licensed Work, for its most recently
|
|
57
|
+
completed fiscal year, or, if it has not completed a fiscal year, for the
|
|
58
|
+
twelve months before the use (or since its formation, if shorter),
|
|
59
|
+
converted into US dollars at the average exchange rate for that period.
|
|
60
|
+
Proceeds of equity or debt financing are not revenue.
|
|
61
|
+
|
|
62
|
+
Threshold. If an Organization stops qualifying under (b), its existing
|
|
63
|
+
production use remains Eligible Use for 90 days after it stops
|
|
64
|
+
qualifying, after which it must obtain a commercial license or stop
|
|
65
|
+
production use. Use that was Eligible Use when it occurred never requires
|
|
66
|
+
a commercial license after the fact.
|
|
67
|
+
Change Date: Four years from the date a version of the Licensed Work
|
|
68
|
+
is first publicly released by the Licensor.
|
|
69
|
+
Change License: Apache License, Version 2.0
|
|
70
|
+
|
|
71
|
+
For information about alternative licensing arrangements for the Licensed
|
|
72
|
+
Work, please visit: https://agimon.ai/licensing
|
|
73
|
+
|
|
74
|
+
Notice
|
|
75
|
+
|
|
76
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
77
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
78
|
+
under an Open Source License, as stated in this License.
|
|
79
|
+
|
|
80
|
+
-----------------------------------------------------------------------------
|
|
81
|
+
|
|
82
|
+
Business Source License 1.1
|
|
83
|
+
|
|
84
|
+
Terms
|
|
85
|
+
|
|
86
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
87
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
88
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
89
|
+
production use.
|
|
90
|
+
|
|
91
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
92
|
+
available distribution of a specific version of the Licensed Work under this
|
|
93
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
94
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
95
|
+
above terminate.
|
|
96
|
+
|
|
97
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
98
|
+
currently in effect as described in this License, you must purchase a
|
|
99
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
100
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
101
|
+
|
|
102
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
103
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
104
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
105
|
+
for each version of the Licensed Work released by Licensor.
|
|
106
|
+
|
|
107
|
+
You must conspicuously display this License on each original or modified copy
|
|
108
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
109
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
110
|
+
License apply to your use of that work.
|
|
111
|
+
|
|
112
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
113
|
+
terminate your rights under this License for the current and all other
|
|
114
|
+
versions of the Licensed Work.
|
|
115
|
+
|
|
116
|
+
This License does not grant you any right in any trademark or logo of
|
|
117
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
118
|
+
Licensor as expressly required by this License).
|
|
119
|
+
|
|
120
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
121
|
+
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
122
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
123
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
124
|
+
TITLE.
|
|
125
|
+
|
|
126
|
+
MariaDB hereby grants you permission to use this License’s text to license
|
|
127
|
+
your works, and to refer to it using the trademark “Business Source License”,
|
|
128
|
+
as long as you comply with the Covenants of Licensor below.
|
|
129
|
+
|
|
130
|
+
Covenants of Licensor
|
|
131
|
+
|
|
132
|
+
In consideration of the right to use this License’s text and the “Business
|
|
133
|
+
Source License” name and trademark, Licensor covenants to MariaDB, and to all
|
|
134
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
135
|
+
|
|
136
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
137
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
138
|
+
where “compatible” means that software provided under the Change License can
|
|
139
|
+
be included in a program with software provided under GPL Version 2.0 or a
|
|
140
|
+
later version. Licensor may specify additional Change Licenses without
|
|
141
|
+
limitation.
|
|
142
|
+
|
|
143
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
144
|
+
impose any additional restriction on the right granted in this License, as
|
|
145
|
+
the Additional Use Grant; or (b) insert the text “None”.
|
|
146
|
+
|
|
147
|
+
3. To specify a Change Date.
|
|
148
|
+
|
|
149
|
+
4. Not to modify this License in any other way.
|
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ The mode detail reports applied Help skill and diagnostic-tool counts. Pending d
|
|
|
22
22
|
| `diagnose_setup` | Distribution | Saved configuration, installed packages, and sync drift for the current workspace. |
|
|
23
23
|
| `diagnose_agent` | Log | Bounded current-session captured failure and token-usage evidence. |
|
|
24
24
|
|
|
25
|
-
Optional owners contribute only when present in the composition. The entry skill `
|
|
25
|
+
Optional owners contribute only when present in the composition. The entry skill `help-how-to-help` routes to configuration, profile, mode, domain, skill, and debugging guidance rather than loading every document eagerly. Deactivating Help withdraws it from future discovery.
|
|
26
26
|
|
|
27
27
|
Diagnostics do not install packages, change configuration, authenticate servers, clear logs, or restart processes. Existing approval and permission boundaries apply to repairs. Agent telemetry distinguishes empty or unavailable data from captured evidence and never treats absent records as proof of health.
|
|
28
28
|
|
|
@@ -46,7 +46,7 @@ import { PO_HELP_WHEN as HELP_WHEN } from '@agimon-ai/po-core/help';
|
|
|
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.
|
|
48
48
|
|
|
49
|
-
A server tool uses `when: HELP_WHEN`, remains owned by its normal
|
|
49
|
+
A server tool uses `when: HELP_WHEN`, remains owned by its normal server plugin, and checks the active host and Help selection at execution boundaries. Domain conditions can be combined with Help when both are required. Help does not bypass other restrictions.
|
|
50
50
|
|
|
51
51
|
The Log package's `diagnose_agent` routes are a first-party example. Provider replacement, late arrival, withdrawal, cancellation, and package shutdown must preserve owner cleanup. Adding Help never grants filesystem, shell, network, or remote MCP access.
|
|
52
52
|
|
|
@@ -66,8 +66,10 @@ Tests cover contribution withdrawal and rollback, the real headless prompt and t
|
|
|
66
66
|
|
|
67
67
|
## License
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
Business Source License 1.1: free for personal use, organisations under USD 1M revenue, non-profits and education. See [LICENSE](LICENSE) and https://agimon.ai/licensing.
|
|
70
70
|
|
|
71
|
-
Active Help also exposes `
|
|
71
|
+
Active Help also exposes `help-how-to-chatgpt-instructions`, which prints a paste-ready instruction of at most 8,000 characters using session tools and every root AGENTS.md rule. It writes no files and does not test connector calls.
|
|
72
72
|
|
|
73
|
-
Active Help also exposes `
|
|
73
|
+
Active Help also exposes `help-how-to-native-extension`, the workflow for adding phone UI to a Po package: `.native` routing and package setup, cockpit parity, native templates, story-first approval, and device verification.
|
|
74
|
+
|
|
75
|
+
Active Help also exposes `help-how-to-codemode-plugin`, the principles for adding code-mode support to a Po package: the namespace contract, per-run binding and ownership, one code path with the direct tool, withdrawing the tool it replaces, and the skill every code-mode package ships.
|
package/dist/apiContracts.cjs
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
//#region src/schemas/apiContracts.ts
|
|
6
|
-
/** This
|
|
6
|
+
/** This server plugin contributes agent tools, commands or lifecycle only, with no separate HTTP or socket surface. */
|
|
7
7
|
const apiContracts = (0, require("@agimon-ai/po-core/apiContracts").defineApiContract)({
|
|
8
8
|
version: 1,
|
|
9
9
|
http: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiContracts.cjs","names":["defineApiContract"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract } from '@agimon-ai/po-core/apiContracts';\n\n/** This
|
|
1
|
+
{"version":3,"file":"apiContracts.cjs","names":["defineApiContract"],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract } from '@agimon-ai/po-core/apiContracts';\n\n/** This server plugin contributes agent tools, commands or lifecycle only, with no separate HTTP or socket surface. */\nexport const apiContracts = defineApiContract({ version: 1, http: [], sockets: [], dynamic: [] });\nexport default apiContracts;\n"],"mappings":";;;;;;AAGA,MAAa,gBAAA,4CAAeA,CAAAA,CAAAA,kBAAAA,CAAkB;CAAE,SAAS;CAAG,MAAM,CAAC;CAAG,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
|
package/dist/apiContracts.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/schemas/apiContracts.d.ts
|
|
2
|
-
/** This
|
|
2
|
+
/** This server plugin contributes agent tools, commands or lifecycle only, with no separate HTTP or socket surface. */
|
|
3
3
|
export declare const apiContracts: {
|
|
4
4
|
version: 1;
|
|
5
5
|
protocols?: Record<string, string> | undefined;
|
package/dist/apiContracts.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineApiContract } from "@agimon-ai/po-core/apiContracts";
|
|
2
2
|
//#region src/schemas/apiContracts.ts
|
|
3
|
-
/** This
|
|
3
|
+
/** This server plugin contributes agent tools, commands or lifecycle only, with no separate HTTP or socket surface. */
|
|
4
4
|
const apiContracts = defineApiContract({
|
|
5
5
|
version: 1,
|
|
6
6
|
http: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract } from '@agimon-ai/po-core/apiContracts';\n\n/** This
|
|
1
|
+
{"version":3,"file":"apiContracts.mjs","names":[],"sources":["../src/schemas/apiContracts.ts"],"sourcesContent":["import { defineApiContract } from '@agimon-ai/po-core/apiContracts';\n\n/** This server plugin contributes agent tools, commands or lifecycle only, with no separate HTTP or socket surface. */\nexport const apiContracts = defineApiContract({ version: 1, http: [], sockets: [], dynamic: [] });\nexport default apiContracts;\n"],"mappings":";;;AAGA,MAAa,eAAe,kBAAkB;CAAE,SAAS;CAAG,MAAM,CAAC;CAAG,SAAS,CAAC;CAAG,SAAS,CAAC;AAAE,CAAC"}
|
|
@@ -3,8 +3,9 @@ Object.defineProperties(exports, {
|
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
5
|
let _agimon_ai_po_core_help = require("@agimon-ai/po-core/help");
|
|
6
|
-
let
|
|
6
|
+
let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
|
|
7
7
|
let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile");
|
|
8
|
+
let _agimon_ai_po_core_codemode = require("@agimon-ai/po-core/codemode");
|
|
8
9
|
let _agimon_ai_po_minor_mode = require("@agimon-ai/po-minor-mode");
|
|
9
10
|
let typebox = require("typebox");
|
|
10
11
|
//#region src/constants/help.ts
|
|
@@ -13,26 +14,35 @@ const HELP_COMMAND_DESCRIPTION = "Toggle Help guidance and read-only support dia
|
|
|
13
14
|
const HELP_MODE_ID = "help";
|
|
14
15
|
const HELP_PACKAGE_SOURCE = "@agimon-ai/po-help";
|
|
15
16
|
const HELP_SKILL = {
|
|
16
|
-
name: "
|
|
17
|
+
name: "help-how-to-help",
|
|
17
18
|
description: "Set up and debug Po agents using installed package guidance and scoped, read-only diagnostics. Diagnose missing capabilities before proposing authorized repairs."
|
|
18
19
|
};
|
|
19
|
-
const HELP_GUIDANCE = "Help mode is active. Read
|
|
20
|
+
const HELP_GUIDANCE = "Help mode is active. Read help-how-to-help, inspect the available diagnostics, and use the narrowest package guidance for the task. Diagnose before proposing changes. Help does not grant additional permissions.";
|
|
20
21
|
const HELP_STATUS_TOOL_NAME = "help_status";
|
|
21
22
|
const HELP_STATUS_TOOL_DESCRIPTION = "Inspect active Help skills, diagnostic tools, contributor ownership, and unavailable contributions in this session. Read-only; does not change selection or permissions.";
|
|
22
23
|
const HELP_CHATGPT_SKILL = {
|
|
23
|
-
name: "
|
|
24
|
+
name: "help-how-to-chatgpt-instructions",
|
|
24
25
|
description: "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."
|
|
25
26
|
};
|
|
27
|
+
const HELP_CODEMODE_SKILL = {
|
|
28
|
+
name: "help-how-to-codemode-plugin",
|
|
29
|
+
description: "Add code-mode support to a Po package: contribute a namespace to exec and discover, replace the direct tool it supersedes, and ship the skill that teaches agents to use it."
|
|
30
|
+
};
|
|
26
31
|
const HELP_NATIVE_SKILL = {
|
|
27
|
-
name: "
|
|
32
|
+
name: "help-how-to-native-extension",
|
|
28
33
|
description: "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."
|
|
29
34
|
};
|
|
35
|
+
const HELP_SELF_IMPROVE_SKILL = {
|
|
36
|
+
name: "codemode-how-to-self-improve",
|
|
37
|
+
description: "Reload Po's own packages after you edit them, without restarting Po or reopening the session. Use in Help mode after changing a plugin's source or build, or after adding or removing a package."
|
|
38
|
+
};
|
|
30
39
|
//#endregion
|
|
31
40
|
//#region src/schemas/diagnostics.ts
|
|
32
41
|
const helpStatusParameters = typebox.Type.Object({}, { additionalProperties: false });
|
|
33
42
|
//#endregion
|
|
34
43
|
//#region src/services/helpStatus/index.ts
|
|
35
|
-
|
|
44
|
+
/** `packageFailures`: the host's failed global and workspace packages; they never degrade Help itself. */
|
|
45
|
+
function serverHelpStatus(snapshot, enabled, packageFailures = []) {
|
|
36
46
|
const entries = snapshot.capabilities.filter((entry) => entry.when?.state?.["minor-mode"] === HELP_MODE_ID);
|
|
37
47
|
const skills = entries.filter((entry) => entry.kind === "skill");
|
|
38
48
|
const tools = entries.filter((entry) => entry.kind === "tool");
|
|
@@ -62,14 +72,15 @@ function serverHelpStatus(snapshot, enabled) {
|
|
|
62
72
|
...reason ? { reason } : {}
|
|
63
73
|
})),
|
|
64
74
|
diagnostics: diagnostics.slice(0, 128),
|
|
65
|
-
|
|
75
|
+
packages: enabled ? packageFailures.slice(-128) : [],
|
|
76
|
+
truncated: skills.length > 128 || tools.length > 128 || diagnostics.length > 128 || enabled && packageFailures.length > 128
|
|
66
77
|
};
|
|
67
78
|
}
|
|
68
79
|
function helpStatusDetail(report) {
|
|
69
80
|
return `${report.counts.skills ?? "pending"} Help skills, ${report.counts.tools} diagnostic tools${report.diagnostics.length ? " (diagnostics available)" : ""}`;
|
|
70
81
|
}
|
|
71
82
|
function createHelpStatusTool(inspect, authorize) {
|
|
72
|
-
return (0,
|
|
83
|
+
return (0, _agimon_ai_po_core_serverPlugin.defineTool)({
|
|
73
84
|
name: HELP_STATUS_TOOL_NAME,
|
|
74
85
|
description: HELP_STATUS_TOOL_DESCRIPTION,
|
|
75
86
|
parameters: helpStatusParameters,
|
|
@@ -91,15 +102,162 @@ function createHelpStatusTool(inspect, authorize) {
|
|
|
91
102
|
});
|
|
92
103
|
}
|
|
93
104
|
//#endregion
|
|
105
|
+
//#region src/services/selfImproveNamespace/index.ts
|
|
106
|
+
/** Finished operations kept for `operation(id)`; older ones are forgotten first. */
|
|
107
|
+
const MAX_OPERATIONS = 20;
|
|
108
|
+
const SCOPES = [
|
|
109
|
+
"session",
|
|
110
|
+
"workspace",
|
|
111
|
+
"global"
|
|
112
|
+
];
|
|
113
|
+
const AXES = [
|
|
114
|
+
"majorMode",
|
|
115
|
+
"domains",
|
|
116
|
+
"profile"
|
|
117
|
+
];
|
|
118
|
+
const OUTCOME_MESSAGE_TYPE = "po-help/self-improve";
|
|
119
|
+
/** One line the agent can pass on to the person without calling operation(). */
|
|
120
|
+
function describeOutcome(operation) {
|
|
121
|
+
const what = operation.axes ? `Refresh ${operation.operationId} (${operation.axes.join(", ")})` : `Reload ${operation.operationId} (${operation.scope} scope)`;
|
|
122
|
+
const tell = "Tell the person the outcome.";
|
|
123
|
+
if (operation.state === "failed") return `${what} failed, nothing changed: ${(operation.error ?? "unknown error").replace(/\.$/u, "")}. ${tell}`;
|
|
124
|
+
const result = operation.result;
|
|
125
|
+
const parts = [
|
|
126
|
+
result?.installed.length ? `installed ${result.installed.join(", ")}` : "",
|
|
127
|
+
result?.removed.length ? `removed ${result.removed.join(", ")}` : "",
|
|
128
|
+
result?.failed.length ? `failed ${result.failed.map((item) => `${item.packageName} (${item.reason})`).join(", ")}, which keep their previous build` : ""
|
|
129
|
+
].filter(Boolean);
|
|
130
|
+
return `${what} ${operation.state}${parts.length ? `: ${parts.join("; ")}` : ""}. ${tell}`;
|
|
131
|
+
}
|
|
132
|
+
const DECLARATIONS = `type Scope = 'session' | 'workspace' | 'global';
|
|
133
|
+
type Axis = 'majorMode' | 'domains' | 'profile';
|
|
134
|
+
interface PackageFailure { scope: string; packageName: string; stage: string; reason: string; previous?: 'restored' | 'lost' | 'none'; at: string }
|
|
135
|
+
interface Operation {
|
|
136
|
+
operationId: string; scope: Scope; axes?: Axis[];
|
|
137
|
+
/** partial: applied, but some packages failed and keep their previous build when they had one. */
|
|
138
|
+
state: 'queued' | 'applied' | 'partial' | 'failed';
|
|
139
|
+
result?: { installed: string[]; removed: string[]; failed: { packageName: string; reason: string }[] };
|
|
140
|
+
error?: string;
|
|
141
|
+
/** Why the outcome follow-up could not reach you, when it did not. */
|
|
142
|
+
undelivered?: string;
|
|
143
|
+
}
|
|
144
|
+
declare const selfImprove: {
|
|
145
|
+
/** Packages whose current build failed to load or install, by scope. */
|
|
146
|
+
plugins(): Promise<{ failures: PackageFailure[] }>;
|
|
147
|
+
/** Queues a reload of one scope's packages from disk. When it finishes you get a follow-up message with the outcome; operation() returns it too. global needs confirm: true, after the person agreed. */
|
|
148
|
+
reload(input: { scope: Scope; confirm?: boolean }): Promise<Operation>;
|
|
149
|
+
/** Queues a re-apply of this session's current major mode, domains or profile (default: all three) after editing their config; reports its outcome like reload. */
|
|
150
|
+
refresh(input?: { axes?: Axis[] }): Promise<Operation>;
|
|
151
|
+
operation(operationId: string): Promise<Operation>;
|
|
152
|
+
};`;
|
|
153
|
+
function createSelfImproveNamespace(options) {
|
|
154
|
+
const operations = /* @__PURE__ */ new Map();
|
|
155
|
+
let next = 0;
|
|
156
|
+
const remember = (operation) => {
|
|
157
|
+
operations.set(operation.operationId, operation);
|
|
158
|
+
for (const id of operations.keys()) {
|
|
159
|
+
if (operations.size <= MAX_OPERATIONS) break;
|
|
160
|
+
if (operations.get(id)?.state !== "queued") operations.delete(id);
|
|
161
|
+
}
|
|
162
|
+
return operation;
|
|
163
|
+
};
|
|
164
|
+
const finish = (operation) => {
|
|
165
|
+
remember(operation);
|
|
166
|
+
Promise.resolve(options.admitMessage?.({
|
|
167
|
+
type: OUTCOME_MESSAGE_TYPE,
|
|
168
|
+
text: describeOutcome(operation),
|
|
169
|
+
display: true
|
|
170
|
+
}, "followUp")).catch((error) => {
|
|
171
|
+
remember({
|
|
172
|
+
...operation,
|
|
173
|
+
undelivered: error instanceof Error ? error.message : String(error)
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
return {
|
|
178
|
+
name: "selfImprove",
|
|
179
|
+
summary: "Reload Po's own packages after editing them, or refresh this session's mode, domains and profile config, without restarting. Help mode, main agent only.",
|
|
180
|
+
declarations: DECLARATIONS,
|
|
181
|
+
bind(run) {
|
|
182
|
+
if (run.sessionId !== options.sessionId) throw new Error("The selfImprove namespace belongs to another session.");
|
|
183
|
+
const check = () => {
|
|
184
|
+
run.signal.throwIfAborted();
|
|
185
|
+
options.assertActive();
|
|
186
|
+
if (run.caller !== "main") throw new Error("Only the main agent may reload or refresh Po.");
|
|
187
|
+
};
|
|
188
|
+
return {
|
|
189
|
+
plugins: async () => {
|
|
190
|
+
check();
|
|
191
|
+
return { failures: JSON.parse(JSON.stringify(options.failures())) };
|
|
192
|
+
},
|
|
193
|
+
reload: async (input) => {
|
|
194
|
+
check();
|
|
195
|
+
const { scope, confirm } = input ?? {};
|
|
196
|
+
if (!SCOPES.includes(scope)) throw new Error("reload needs scope 'session', 'workspace' or 'global'.");
|
|
197
|
+
if (scope === "global" && confirm !== true) throw new Error("A global reload changes every session; ask the person, then pass confirm: true.");
|
|
198
|
+
const operationId = `reload-${String(++next)}`;
|
|
199
|
+
const queued = remember({
|
|
200
|
+
operationId,
|
|
201
|
+
scope,
|
|
202
|
+
state: "queued"
|
|
203
|
+
});
|
|
204
|
+
options.service.reload({
|
|
205
|
+
scope: queued.scope,
|
|
206
|
+
sessionId: options.sessionId
|
|
207
|
+
}).then((result) => finish({
|
|
208
|
+
...queued,
|
|
209
|
+
state: result.failed.length === 0 ? "applied" : "partial",
|
|
210
|
+
result: JSON.parse(JSON.stringify(result))
|
|
211
|
+
}), (error) => finish({
|
|
212
|
+
...queued,
|
|
213
|
+
state: "failed",
|
|
214
|
+
error: error instanceof Error ? error.message : String(error)
|
|
215
|
+
}));
|
|
216
|
+
return { ...queued };
|
|
217
|
+
},
|
|
218
|
+
refresh: async (input) => {
|
|
219
|
+
check();
|
|
220
|
+
const { axes = AXES } = input ?? {};
|
|
221
|
+
if (!Array.isArray(axes) || axes.length === 0 || !axes.every((axis) => AXES.includes(axis))) throw new Error("refresh axes are 'majorMode', 'domains' and 'profile'.");
|
|
222
|
+
const queued = remember({
|
|
223
|
+
operationId: `refresh-${String(++next)}`,
|
|
224
|
+
scope: "session",
|
|
225
|
+
axes: [...new Set(axes)],
|
|
226
|
+
state: "queued"
|
|
227
|
+
});
|
|
228
|
+
options.service.refresh({
|
|
229
|
+
sessionId: options.sessionId,
|
|
230
|
+
axes: queued.axes
|
|
231
|
+
}).then(() => finish({
|
|
232
|
+
...queued,
|
|
233
|
+
state: "applied"
|
|
234
|
+
}), (error) => finish({
|
|
235
|
+
...queued,
|
|
236
|
+
state: "failed",
|
|
237
|
+
error: error instanceof Error ? error.message : String(error)
|
|
238
|
+
}));
|
|
239
|
+
return JSON.parse(JSON.stringify(queued));
|
|
240
|
+
},
|
|
241
|
+
operation: async (operationId) => {
|
|
242
|
+
check();
|
|
243
|
+
const operation = typeof operationId === "string" ? operations.get(operationId) : void 0;
|
|
244
|
+
if (operation === void 0) throw new Error(`No operation '${String(operationId)}'.`);
|
|
245
|
+
return JSON.parse(JSON.stringify(operation));
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
//#endregion
|
|
94
252
|
//#region src/services/helpServerSession/index.ts
|
|
95
|
-
function createHelpServerSession(host) {
|
|
253
|
+
function createHelpServerSession(host, packageFailures = () => [], selfImprove) {
|
|
96
254
|
let modeOwner;
|
|
97
255
|
let pending;
|
|
98
256
|
let failure;
|
|
99
257
|
let generation = 0;
|
|
100
258
|
let disposed = false;
|
|
101
259
|
const active = () => (host.context.selection.state?.["minor-mode"] ?? []).includes(HELP_MODE_ID);
|
|
102
|
-
const inspect = () => serverHelpStatus(host.inspectCapabilities(), active());
|
|
260
|
+
const inspect = () => serverHelpStatus(host.inspectCapabilities(), active(), packageFailures());
|
|
103
261
|
const modeState = () => {
|
|
104
262
|
const report = inspect();
|
|
105
263
|
return {
|
|
@@ -128,9 +286,9 @@ function createHelpServerSession(host) {
|
|
|
128
286
|
when: _agimon_ai_po_core_help.PO_HELP_WHEN,
|
|
129
287
|
...HELP_SKILL,
|
|
130
288
|
kind: "skill",
|
|
131
|
-
path: (0,
|
|
289
|
+
path: (0, _agimon_ai_po_core_serverPlugin.packageResourcePath)(require("url").pathToFileURL(__filename).href, "src/prompts/help-how-to-help/SKILL.md"),
|
|
132
290
|
read: async () => {
|
|
133
|
-
const text = await (0,
|
|
291
|
+
const text = await (0, _agimon_ai_po_core_serverPlugin.readPackageResource)(require("url").pathToFileURL(__filename).href, "src/prompts/help-how-to-help/SKILL.md");
|
|
134
292
|
if (!text.trim()) throw new Error("The installed Help skill is missing or unreadable.");
|
|
135
293
|
return text;
|
|
136
294
|
}
|
|
@@ -139,9 +297,9 @@ function createHelpServerSession(host) {
|
|
|
139
297
|
when: _agimon_ai_po_core_help.PO_HELP_WHEN,
|
|
140
298
|
...HELP_CHATGPT_SKILL,
|
|
141
299
|
kind: "skill",
|
|
142
|
-
path: (0,
|
|
300
|
+
path: (0, _agimon_ai_po_core_serverPlugin.packageResourcePath)(require("url").pathToFileURL(__filename).href, "src/prompts/help-how-to-chatgpt-instructions/SKILL.md"),
|
|
143
301
|
read: async () => {
|
|
144
|
-
const text = await (0,
|
|
302
|
+
const text = await (0, _agimon_ai_po_core_serverPlugin.readPackageResource)(require("url").pathToFileURL(__filename).href, "src/prompts/help-how-to-chatgpt-instructions/SKILL.md");
|
|
145
303
|
if (!text.trim()) throw new Error("The installed ChatGPT instruction skill is missing or unreadable.");
|
|
146
304
|
return text;
|
|
147
305
|
}
|
|
@@ -150,13 +308,32 @@ function createHelpServerSession(host) {
|
|
|
150
308
|
when: _agimon_ai_po_core_help.PO_HELP_WHEN,
|
|
151
309
|
...HELP_NATIVE_SKILL,
|
|
152
310
|
kind: "skill",
|
|
153
|
-
path: (0,
|
|
311
|
+
path: (0, _agimon_ai_po_core_serverPlugin.packageResourcePath)(require("url").pathToFileURL(__filename).href, "src/prompts/help-how-to-native-extension/SKILL.md"),
|
|
154
312
|
read: async () => {
|
|
155
|
-
const text = await (0,
|
|
313
|
+
const text = await (0, _agimon_ai_po_core_serverPlugin.readPackageResource)(require("url").pathToFileURL(__filename).href, "src/prompts/help-how-to-native-extension/SKILL.md");
|
|
156
314
|
if (!text.trim()) throw new Error("The installed native extension skill is missing or unreadable.");
|
|
157
315
|
return text;
|
|
158
316
|
}
|
|
159
|
-
}
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
when: _agimon_ai_po_core_help.PO_HELP_WHEN,
|
|
320
|
+
...HELP_CODEMODE_SKILL,
|
|
321
|
+
kind: "skill",
|
|
322
|
+
path: (0, _agimon_ai_po_core_serverPlugin.packageResourcePath)(require("url").pathToFileURL(__filename).href, "src/prompts/help-how-to-codemode-plugin/SKILL.md"),
|
|
323
|
+
read: async () => {
|
|
324
|
+
const text = await (0, _agimon_ai_po_core_serverPlugin.readPackageResource)(require("url").pathToFileURL(__filename).href, "src/prompts/help-how-to-codemode-plugin/SKILL.md");
|
|
325
|
+
if (!text.trim()) throw new Error("The installed code-mode plugin skill is missing or unreadable.");
|
|
326
|
+
return text;
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
...selfImprove === void 0 ? [] : [{
|
|
330
|
+
when: _agimon_ai_po_core_help.PO_HELP_WHEN,
|
|
331
|
+
...HELP_SELF_IMPROVE_SKILL,
|
|
332
|
+
kind: "skill",
|
|
333
|
+
pinned: true,
|
|
334
|
+
path: (0, _agimon_ai_po_core_serverPlugin.packageResourcePath)(require("url").pathToFileURL(__filename).href, "src/prompts/codemode-how-to-self-improve/SKILL.md"),
|
|
335
|
+
read: () => (0, _agimon_ai_po_core_serverPlugin.readPackageResource)(require("url").pathToFileURL(__filename).href, "src/prompts/codemode-how-to-self-improve/SKILL.md")
|
|
336
|
+
}]
|
|
160
337
|
];
|
|
161
338
|
const selectMode = async (enabled, signal) => {
|
|
162
339
|
if (disposed) throw new Error("Help runtime is disposed.");
|
|
@@ -225,8 +402,34 @@ function createHelpServerSession(host) {
|
|
|
225
402
|
return { message: active() ? "Help mode activated." : "Help mode deactivated." };
|
|
226
403
|
}
|
|
227
404
|
}).createOwner(void 0);
|
|
405
|
+
const assertHelpActive = () => {
|
|
406
|
+
host.assertActive(HELP_PACKAGE_SOURCE);
|
|
407
|
+
if (disposed || !active()) throw new Error("Help mode is not active.");
|
|
408
|
+
};
|
|
409
|
+
const selfImproveService = (cordis) => {
|
|
410
|
+
cordis.inject([_agimon_ai_po_core_codemode.PO_CODEMODE_SERVICE], (scoped) => {
|
|
411
|
+
const codemode = (0, _agimon_ai_po_core_codemode.readPoCodemode)(scoped);
|
|
412
|
+
if (!codemode || !selfImprove) return void 0;
|
|
413
|
+
const namespace = createSelfImproveNamespace({
|
|
414
|
+
sessionId: host.context.sessionId,
|
|
415
|
+
service: selfImprove,
|
|
416
|
+
failures: packageFailures,
|
|
417
|
+
assertActive: assertHelpActive,
|
|
418
|
+
admitMessage: host.context.session.admitMessage?.bind(host.context.session)
|
|
419
|
+
});
|
|
420
|
+
const activity = host.registerActivity({
|
|
421
|
+
when: _agimon_ai_po_core_help.PO_HELP_WHEN,
|
|
422
|
+
name: "selfImprove",
|
|
423
|
+
start: () => {
|
|
424
|
+
const registration = codemode.register(HELP_PACKAGE_SOURCE, namespace);
|
|
425
|
+
return () => registration.dispose();
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
return () => activity.dispose();
|
|
429
|
+
});
|
|
430
|
+
};
|
|
228
431
|
return {
|
|
229
|
-
services: [(0, _agimon_ai_po_minor_mode.serverMinorModes)([modeOwner])],
|
|
432
|
+
services: [(0, _agimon_ai_po_minor_mode.serverMinorModes)([modeOwner]), ...selfImprove ? [selfImproveService] : []],
|
|
230
433
|
resources,
|
|
231
434
|
commands: [command],
|
|
232
435
|
tools: [createHelpStatusTool(inspect, (signal) => {
|
|
@@ -243,7 +446,7 @@ function createHelpServerSession(host) {
|
|
|
243
446
|
}
|
|
244
447
|
//#endregion
|
|
245
448
|
//#region src/extensions/workspaces/sessions/(backend)/_lib/runtime.server.ts
|
|
246
|
-
var runtime_server_default = (({ agent }) => agent ? createHelpServerSession(agent) : {});
|
|
449
|
+
var runtime_server_default = (({ agent, context }) => agent ? createHelpServerSession(agent, () => (0, _agimon_ai_po_core_help.readPoPackageHealth)(context)?.failures() ?? [], (0, _agimon_ai_po_core_help.readPoSelfImprove)(context)) : {});
|
|
247
450
|
//#endregion
|
|
248
451
|
//#region src/extensions/workspaces/sessions/(backend)/root.server.ts
|
|
249
452
|
var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)((context) => {
|
|
@@ -261,6 +464,12 @@ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)((cont
|
|
|
261
464
|
//#region src/extensions/workspaces/sessions/(backend)/command/po-help.server.ts
|
|
262
465
|
var po_help_server_default$1 = (0, _agimon_ai_po_core_extensionFile.defineRoutedContribution)((context) => context.root.commands?.[0], { cardinality: "optional" });
|
|
263
466
|
//#endregion
|
|
467
|
+
//#region src/extensions/workspaces/sessions/(backend)/resource/codemode-how-to-self-improve.server.ts
|
|
468
|
+
var codemode_how_to_self_improve_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoutedContribution)((context) => context.root.resources?.[5], { cardinality: "optional" });
|
|
469
|
+
//#endregion
|
|
470
|
+
//#region src/extensions/workspaces/sessions/(backend)/resource/po-develop-codemode-plugin.server.ts
|
|
471
|
+
var po_develop_codemode_plugin_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoutedContribution)((context) => context.root.resources?.[4], { cardinality: "optional" });
|
|
472
|
+
//#endregion
|
|
264
473
|
//#region src/extensions/workspaces/sessions/(backend)/resource/po-develop-native-extension.server.ts
|
|
265
474
|
var po_develop_native_extension_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoutedContribution)((context) => context.root.resources?.[3], { cardinality: "optional" });
|
|
266
475
|
//#endregion
|
|
@@ -284,11 +493,12 @@ const via = (identity, value) => value === void 0 ? void 0 : {
|
|
|
284
493
|
...identity,
|
|
285
494
|
...value
|
|
286
495
|
};
|
|
287
|
-
const
|
|
496
|
+
const serverPlugin = (0, _agimon_ai_po_core_serverPlugin.defineServerPlugin)({
|
|
288
497
|
name: "@agimon-ai/po-help",
|
|
289
|
-
providerOverrides: (0,
|
|
498
|
+
providerOverrides: (0, _agimon_ai_po_core_serverPlugin.composeServerProviderOverrides)(root_server_default),
|
|
499
|
+
injects: (0, _agimon_ai_po_core_extensionFile.composeRootInjects)({ session: [root_server_default] }),
|
|
290
500
|
session: async (context) => {
|
|
291
|
-
const scopeSession = await root_server_default
|
|
501
|
+
const scopeSession = await context.scopeRoot("session", root_server_default, context);
|
|
292
502
|
const contextSession = {
|
|
293
503
|
...context,
|
|
294
504
|
root: scopeSession.value
|
|
@@ -300,6 +510,8 @@ const facet = (0, _agimon_ai_po_core_serverFacet.defineServerPlugin)({
|
|
|
300
510
|
},
|
|
301
511
|
get resources() {
|
|
302
512
|
return defined([
|
|
513
|
+
at(codemode_how_to_self_improve_server_default, contextSession),
|
|
514
|
+
at(po_develop_codemode_plugin_server_default, contextSession),
|
|
303
515
|
at(po_develop_native_extension_server_default, contextSession),
|
|
304
516
|
at(po_help_server_default, contextSession),
|
|
305
517
|
at(po_use_chatgpt_instructions_server_default, contextSession),
|
|
@@ -317,7 +529,7 @@ const facet = (0, _agimon_ai_po_core_serverFacet.defineServerPlugin)({
|
|
|
317
529
|
}
|
|
318
530
|
});
|
|
319
531
|
//#endregion
|
|
320
|
-
exports.default =
|
|
321
|
-
exports.
|
|
532
|
+
exports.default = serverPlugin;
|
|
533
|
+
exports.serverPlugin = serverPlugin;
|
|
322
534
|
|
|
323
535
|
//# sourceMappingURL=server.cjs.map
|