@xn-intenton-z2a/agentic-lib 7.4.25 → 7.4.26
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/package.json
CHANGED
|
@@ -43,7 +43,7 @@ function buildFileListing(dirPath, extension, maxFiles = 30) {
|
|
|
43
43
|
* @returns {Promise<Object>} Result with outcome, tokensUsed, model
|
|
44
44
|
*/
|
|
45
45
|
export async function maintainLibrary(context) {
|
|
46
|
-
const { config, instructions, writablePaths, model, logFilePath, screenshotFilePath } = context;
|
|
46
|
+
const { config, instructions, writablePaths, model, logFilePath, screenshotFilePath, octokit, repo } = context;
|
|
47
47
|
const t = config.tuning || {};
|
|
48
48
|
|
|
49
49
|
// Check mission-complete signal (skip in maintenance mode)
|
|
@@ -57,63 +57,76 @@ export async function maintainLibrary(context) {
|
|
|
57
57
|
const sourcesPath = config.paths.librarySources.path;
|
|
58
58
|
const sources = readOptionalFile(sourcesPath);
|
|
59
59
|
const mission = readOptionalFile(config.paths.mission.path);
|
|
60
|
-
const hasUrls = /https?:\/\//.test(sources);
|
|
60
|
+
const hasUrls = /https?:\/\//.test(sources); // used in prompt to guide Step 1 wording
|
|
61
61
|
|
|
62
62
|
const libraryPath = config.paths.library.path;
|
|
63
63
|
const libraryLimit = config.paths.library.limit;
|
|
64
64
|
const libraryFiles = buildFileListing(libraryPath, ".md");
|
|
65
65
|
|
|
66
|
+
// Read feature specs and open issues so library sources reflect active work
|
|
67
|
+
const featureFiles = buildFileListing(config.paths.features?.path || "features/", ".md");
|
|
68
|
+
let openIssuesSummary = [];
|
|
69
|
+
try {
|
|
70
|
+
if (octokit && repo) {
|
|
71
|
+
const { data: issues } = await octokit.rest.issues.listForRepo({
|
|
72
|
+
...repo, state: "open", labels: "automated", per_page: 10,
|
|
73
|
+
sort: "created", direction: "desc",
|
|
74
|
+
});
|
|
75
|
+
openIssuesSummary = issues
|
|
76
|
+
.filter((i) => !i.pull_request)
|
|
77
|
+
.map((i) => `#${i.number}: ${i.title}`);
|
|
78
|
+
}
|
|
79
|
+
} catch { /* no issues access */ }
|
|
80
|
+
|
|
66
81
|
const agentInstructions = instructions || "Maintain the library by updating documents from sources.";
|
|
67
82
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"Find documentation, tutorials, API references, Wikipedia articles, or npm packages related to the mission's core topic.",
|
|
85
|
-
"Use web search to discover high-quality, stable URLs (prefer official docs, Wikipedia, MDN, npm).",
|
|
86
|
-
`Write the URLs as a markdown list in ${sourcesPath}, keeping the existing header text.`,
|
|
83
|
+
const prompt = [
|
|
84
|
+
"## Instructions",
|
|
85
|
+
agentInstructions,
|
|
86
|
+
"",
|
|
87
|
+
"## Mission",
|
|
88
|
+
mission || "(no mission file found)",
|
|
89
|
+
"",
|
|
90
|
+
"## Current SOURCES.md",
|
|
91
|
+
sources || "(empty — no URLs yet)",
|
|
92
|
+
"",
|
|
93
|
+
`## Current Library Documents (${libraryFiles.length}/${libraryLimit} max)`,
|
|
94
|
+
libraryFiles.length > 0 ? libraryFiles.join(", ") : "(none — library is empty)",
|
|
95
|
+
"",
|
|
96
|
+
...(featureFiles.length > 0 ? [
|
|
97
|
+
`## Active Features (${featureFiles.length})`,
|
|
98
|
+
featureFiles.join(", "),
|
|
87
99
|
"",
|
|
88
|
-
|
|
100
|
+
] : []),
|
|
101
|
+
...(openIssuesSummary.length > 0 ? [
|
|
102
|
+
`## Open Issues (${openIssuesSummary.length})`,
|
|
103
|
+
openIssuesSummary.join("\n"),
|
|
89
104
|
"",
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"",
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
].join("\n");
|
|
116
|
-
}
|
|
105
|
+
] : []),
|
|
106
|
+
"## Your Task — Two Steps (always do both)",
|
|
107
|
+
"",
|
|
108
|
+
`**Step 1: Update ${sourcesPath}**`,
|
|
109
|
+
"Review the current SOURCES.md against the mission, features, and open issues.",
|
|
110
|
+
hasUrls
|
|
111
|
+
? "Add URLs for topics not yet covered. Remove URLs that are no longer relevant. Keep existing URLs that are still useful."
|
|
112
|
+
: "SOURCES.md has no URLs yet. Research the mission and add 3-8 relevant reference URLs.",
|
|
113
|
+
"Find documentation, tutorials, API references, Wikipedia articles, or npm packages.",
|
|
114
|
+
"Prioritise sources relevant to the active features and open issues listed above.",
|
|
115
|
+
"Use web search to discover high-quality, stable URLs (prefer official docs, Wikipedia, MDN, npm).",
|
|
116
|
+
`Write the URLs as a markdown list in ${sourcesPath}.`,
|
|
117
|
+
"",
|
|
118
|
+
`**Step 2: Update library documents in \`${libraryPath}\`**`,
|
|
119
|
+
"After updating SOURCES.md, read it back and maintain the library:",
|
|
120
|
+
"- Fetch each URL and create or update a library document with the key technical content.",
|
|
121
|
+
"- Remove library documents whose sources have been removed.",
|
|
122
|
+
"- Name documents descriptively (e.g. `MDN_ARRAY_METHODS.md`, `WIKIPEDIA_HAMMING_DISTANCE.md`).",
|
|
123
|
+
"",
|
|
124
|
+
formatPathsSection(writablePaths, config.readOnlyPaths, config),
|
|
125
|
+
"",
|
|
126
|
+
"## Constraints",
|
|
127
|
+
`- Maximum ${libraryLimit} library documents`,
|
|
128
|
+
`- Token budget: ~${maxTokens} tokens. Be concise — avoid verbose explanations or unnecessary tool calls.`,
|
|
129
|
+
].join("\n");
|
|
117
130
|
|
|
118
131
|
const systemPrompt =
|
|
119
132
|
"You are a knowledge librarian. Maintain a library of technical documents extracted from web sources." +
|
|
@@ -139,13 +152,10 @@ export async function maintainLibrary(context) {
|
|
|
139
152
|
logger: { info: core.info, warning: core.warning, error: core.error, debug: core.debug },
|
|
140
153
|
});
|
|
141
154
|
|
|
142
|
-
const
|
|
143
|
-
const detailsMsg = hasUrls
|
|
144
|
-
? `Maintained library (${libraryFiles.length} docs, limit ${libraryLimit})`
|
|
145
|
-
: `Discovered sources for SOURCES.md from mission`;
|
|
155
|
+
const detailsMsg = `Maintained sources and library (${libraryFiles.length} existing docs, limit ${libraryLimit})`;
|
|
146
156
|
|
|
147
157
|
return {
|
|
148
|
-
outcome:
|
|
158
|
+
outcome: "library-maintained",
|
|
149
159
|
tokensUsed: result.tokensIn + result.tokensOut,
|
|
150
160
|
inputTokens: result.tokensIn,
|
|
151
161
|
outputTokens: result.tokensOut,
|