@xn-intenton-z2a/agentic-lib 7.1.41 → 7.1.43
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/bin/agentic-lib.js +46 -0
- package/package.json +1 -1
- package/src/actions/agentic-step/config-loader.js +20 -1
- package/src/actions/agentic-step/copilot.js +13 -3
- package/src/actions/agentic-step/tasks/discussions.js +2 -0
- package/src/actions/agentic-step/tasks/enhance-issue.js +2 -0
- package/src/actions/agentic-step/tasks/fix-code.js +1 -1
- package/src/actions/agentic-step/tasks/maintain-features.js +1 -1
- package/src/actions/agentic-step/tasks/maintain-library.js +1 -1
- package/src/actions/agentic-step/tasks/resolve-issue.js +1 -1
- package/src/actions/agentic-step/tasks/review-issue.js +3 -0
- package/src/actions/agentic-step/tasks/supervise.js +9 -0
- package/src/actions/agentic-step/tasks/transform.js +3 -3
- package/src/agents/agent-supervisor.md +1 -0
- package/src/seeds/init.yml +2 -0
- package/src/seeds/zero-package.json +1 -1
- package/src/workflows/agent-discussions-bot.yml +0 -2
- package/src/workflows/agent-flow-maintain.yml +0 -2
- package/src/workflows/agent-flow-review.yml +0 -2
- package/src/workflows/agent-flow-transform.yml +0 -2
- package/src/workflows/ci-automerge.yml +0 -3
package/bin/agentic-lib.js
CHANGED
|
@@ -958,6 +958,52 @@ function initPurgeGitHub() {
|
|
|
958
958
|
} catch {
|
|
959
959
|
console.log(" SKIP: Could not list discussions (feature may not be enabled)");
|
|
960
960
|
}
|
|
961
|
+
|
|
962
|
+
// Create a new "Talk to the repository" discussion
|
|
963
|
+
try {
|
|
964
|
+
// Get the repository node ID and "General" category ID
|
|
965
|
+
const repoQuery = JSON.stringify({
|
|
966
|
+
query: `{ repository(owner:"${owner}", name:"${repo}") { id discussionCategories(first:20) { nodes { id name } } } }`,
|
|
967
|
+
});
|
|
968
|
+
const repoResult = execSync(`gh api graphql --input -`, {
|
|
969
|
+
cwd: target,
|
|
970
|
+
encoding: "utf8",
|
|
971
|
+
timeout: 30000,
|
|
972
|
+
input: repoQuery,
|
|
973
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
974
|
+
});
|
|
975
|
+
const repoParsed = JSON.parse(repoResult);
|
|
976
|
+
const repoId = repoParsed?.data?.repository?.id;
|
|
977
|
+
const categories = repoParsed?.data?.repository?.discussionCategories?.nodes || [];
|
|
978
|
+
const generalCat = categories.find((c) => c.name === "General");
|
|
979
|
+
if (!repoId || !generalCat) {
|
|
980
|
+
console.log(' SKIP: Could not find repository ID or "General" discussion category');
|
|
981
|
+
} else {
|
|
982
|
+
console.log(' CREATE: discussion "Talk to the repository" in General category');
|
|
983
|
+
if (!dryRun) {
|
|
984
|
+
const createMutation = JSON.stringify({
|
|
985
|
+
query: `mutation { createDiscussion(input: { repositoryId: "${repoId}", categoryId: "${generalCat.id}", title: "Talk to the repository", body: "This discussion is the main channel for interacting with the repository's autonomous agents.\\n\\nUse this thread to:\\n- Submit feature requests or ideas\\n- Ask questions about the project\\n- Chat with the discussions bot\\n\\n---\\n*Created by init --purge*" }) { discussion { number url } } }`,
|
|
986
|
+
});
|
|
987
|
+
const createResult = execSync(`gh api graphql --input -`, {
|
|
988
|
+
cwd: target,
|
|
989
|
+
encoding: "utf8",
|
|
990
|
+
timeout: 15000,
|
|
991
|
+
input: createMutation,
|
|
992
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
993
|
+
});
|
|
994
|
+
const createParsed = JSON.parse(createResult);
|
|
995
|
+
const newDisc = createParsed?.data?.createDiscussion?.discussion;
|
|
996
|
+
if (newDisc) {
|
|
997
|
+
console.log(` CREATED: discussion #${newDisc.number} — ${newDisc.url}`);
|
|
998
|
+
initChanges++;
|
|
999
|
+
}
|
|
1000
|
+
} else {
|
|
1001
|
+
initChanges++;
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
} catch (err) {
|
|
1005
|
+
console.log(` SKIP: Could not create discussion (${err.message})`);
|
|
1006
|
+
}
|
|
961
1007
|
}
|
|
962
1008
|
|
|
963
1009
|
function runInit() {
|
package/package.json
CHANGED
|
@@ -60,6 +60,22 @@ const LIMIT_DEFAULTS = {
|
|
|
60
60
|
library: 32,
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Read package.json from the project root, returning empty string if not found.
|
|
65
|
+
* @param {string} tomlPath - Path to the TOML config (used to derive project root)
|
|
66
|
+
* @param {string} depsRelPath - Relative path to package.json (from config)
|
|
67
|
+
* @returns {string} Raw package.json content or empty string
|
|
68
|
+
*/
|
|
69
|
+
function readPackageJson(tomlPath, depsRelPath) {
|
|
70
|
+
try {
|
|
71
|
+
const projectRoot = dirname(tomlPath);
|
|
72
|
+
const pkgPath = join(projectRoot, depsRelPath);
|
|
73
|
+
return existsSync(pkgPath) ? readFileSync(pkgPath, "utf8") : "";
|
|
74
|
+
} catch {
|
|
75
|
+
return "";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
63
79
|
/**
|
|
64
80
|
* Load configuration from agentic-lib.toml.
|
|
65
81
|
*
|
|
@@ -85,7 +101,8 @@ export function loadConfig(configPath) {
|
|
|
85
101
|
throw new Error(`Config file not found: ${tomlPath}. Create agentic-lib.toml in the project root.`);
|
|
86
102
|
}
|
|
87
103
|
|
|
88
|
-
const
|
|
104
|
+
const rawToml = readFileSync(tomlPath, "utf8");
|
|
105
|
+
const toml = parseToml(rawToml);
|
|
89
106
|
|
|
90
107
|
// Merge TOML paths with defaults, normalising library-sources → librarySources
|
|
91
108
|
const rawPaths = { ...toml.paths };
|
|
@@ -136,6 +153,8 @@ export function loadConfig(configPath) {
|
|
|
136
153
|
tdd: toml.tdd === true,
|
|
137
154
|
writablePaths,
|
|
138
155
|
readOnlyPaths,
|
|
156
|
+
configToml: rawToml,
|
|
157
|
+
packageJson: readPackageJson(tomlPath, mergedPaths.dependencies),
|
|
139
158
|
};
|
|
140
159
|
}
|
|
141
160
|
|
|
@@ -171,15 +171,25 @@ export function scanDirectory(dirPath, extensions, options = {}) {
|
|
|
171
171
|
*
|
|
172
172
|
* @param {string[]} writablePaths
|
|
173
173
|
* @param {string[]} [readOnlyPaths=[]]
|
|
174
|
+
* @param {Object} [contextFiles] - Optional raw file contents to include
|
|
175
|
+
* @param {string} [contextFiles.configToml] - Raw agentic-lib.toml text
|
|
176
|
+
* @param {string} [contextFiles.packageJson] - Raw package.json text
|
|
174
177
|
* @returns {string}
|
|
175
178
|
*/
|
|
176
|
-
export function formatPathsSection(writablePaths, readOnlyPaths = []) {
|
|
177
|
-
|
|
179
|
+
export function formatPathsSection(writablePaths, readOnlyPaths = [], contextFiles) {
|
|
180
|
+
const lines = [
|
|
178
181
|
"## File Paths",
|
|
179
182
|
"### Writable (you may modify these)",
|
|
180
183
|
writablePaths.length > 0 ? writablePaths.map((p) => `- ${p}`).join("\n") : "- (none)",
|
|
181
184
|
"",
|
|
182
185
|
"### Read-Only (for context only, do NOT modify)",
|
|
183
186
|
readOnlyPaths.length > 0 ? readOnlyPaths.map((p) => `- ${p}`).join("\n") : "- (none)",
|
|
184
|
-
]
|
|
187
|
+
];
|
|
188
|
+
if (contextFiles?.configToml) {
|
|
189
|
+
lines.push("", "### Configuration (agentic-lib.toml)", "```toml", contextFiles.configToml, "```");
|
|
190
|
+
}
|
|
191
|
+
if (contextFiles?.packageJson) {
|
|
192
|
+
lines.push("", "### Dependencies (package.json)", "```json", contextFiles.packageJson, "```");
|
|
193
|
+
}
|
|
194
|
+
return lines.join("\n");
|
|
185
195
|
}
|
|
@@ -100,6 +100,8 @@ function buildPrompt(discussionUrl, discussion, context) {
|
|
|
100
100
|
contributing ? `### Contributing\n${contributing}` : "",
|
|
101
101
|
`### Current Features\n${featureNames.join(", ") || "none"}`,
|
|
102
102
|
recentActivity ? `### Recent Activity\n${recentActivity}` : "",
|
|
103
|
+
config.configToml ? `### Configuration (agentic-lib.toml)\n\`\`\`toml\n${config.configToml}\n\`\`\`` : "",
|
|
104
|
+
config.packageJson ? `### Dependencies (package.json)\n\`\`\`json\n${config.packageJson}\n\`\`\`` : "",
|
|
103
105
|
"",
|
|
104
106
|
"## Actions",
|
|
105
107
|
"Include exactly one action tag in your response. Only mention actions to the user when relevant.",
|
|
@@ -49,6 +49,8 @@ export async function enhanceIssue(context) {
|
|
|
49
49
|
"",
|
|
50
50
|
contributing ? `## Contributing Guidelines\n${contributing.substring(0, 1000)}` : "",
|
|
51
51
|
features.length > 0 ? `## Related Features\n${features.map((f) => f.content).join("\n---\n")}` : "",
|
|
52
|
+
config.configToml ? `## Configuration (agentic-lib.toml)\n\`\`\`toml\n${config.configToml}\n\`\`\`` : "",
|
|
53
|
+
config.packageJson ? `## Dependencies (package.json)\n\`\`\`json\n${config.packageJson}\n\`\`\`` : "",
|
|
52
54
|
"",
|
|
53
55
|
"## Your Task",
|
|
54
56
|
"Write an enhanced version of this issue body that includes:",
|
|
@@ -46,7 +46,7 @@ export async function fixCode(context) {
|
|
|
46
46
|
"## Failing Checks",
|
|
47
47
|
failureDetails,
|
|
48
48
|
"",
|
|
49
|
-
formatPathsSection(writablePaths, readOnlyPaths),
|
|
49
|
+
formatPathsSection(writablePaths, readOnlyPaths, config),
|
|
50
50
|
"",
|
|
51
51
|
"## Constraints",
|
|
52
52
|
`- Run \`${testCommand}\` to validate your fixes`,
|
|
@@ -55,7 +55,7 @@ export async function maintainFeatures(context) {
|
|
|
55
55
|
`2. If there are fewer than ${featureLimit} features, create new features aligned with the mission.`,
|
|
56
56
|
"3. Ensure each feature has clear, testable acceptance criteria.",
|
|
57
57
|
"",
|
|
58
|
-
formatPathsSection(writablePaths, config.readOnlyPaths),
|
|
58
|
+
formatPathsSection(writablePaths, config.readOnlyPaths, config),
|
|
59
59
|
"",
|
|
60
60
|
"## Constraints",
|
|
61
61
|
`- Maximum ${featureLimit} feature files`,
|
|
@@ -44,7 +44,7 @@ export async function maintainLibrary(context) {
|
|
|
44
44
|
"2. Create or update library documents based on the source content.",
|
|
45
45
|
"3. Remove library documents that no longer have corresponding sources.",
|
|
46
46
|
"",
|
|
47
|
-
formatPathsSection(writablePaths, config.readOnlyPaths),
|
|
47
|
+
formatPathsSection(writablePaths, config.readOnlyPaths, config),
|
|
48
48
|
"",
|
|
49
49
|
"## Constraints",
|
|
50
50
|
`- Maximum ${libraryLimit} library documents`,
|
|
@@ -71,7 +71,7 @@ export async function resolveIssue(context) {
|
|
|
71
71
|
comments.length > 0 ? "## Issue Comments" : "",
|
|
72
72
|
...comments.map((c) => `**${c.user.login}:** ${c.body}`),
|
|
73
73
|
"",
|
|
74
|
-
formatPathsSection(writablePaths, readOnlyPaths),
|
|
74
|
+
formatPathsSection(writablePaths, readOnlyPaths, config),
|
|
75
75
|
"",
|
|
76
76
|
"## Constraints",
|
|
77
77
|
`- Run \`${testCommand}\` to validate your changes`,
|
|
@@ -87,6 +87,9 @@ export async function reviewIssue(context) {
|
|
|
87
87
|
`## Current Tests (${testFiles.length} files)`,
|
|
88
88
|
...testFiles.map((f) => `### ${f.name}\n\`\`\`\n${f.content}\n\`\`\``),
|
|
89
89
|
"",
|
|
90
|
+
config.configToml ? `## Configuration (agentic-lib.toml)\n\`\`\`toml\n${config.configToml}\n\`\`\`` : "",
|
|
91
|
+
config.packageJson ? `## Dependencies (package.json)\n\`\`\`json\n${config.packageJson}\n\`\`\`` : "",
|
|
92
|
+
"",
|
|
90
93
|
"## Your Task",
|
|
91
94
|
"Determine if this issue has been resolved by the current code.",
|
|
92
95
|
"Respond with exactly one of:",
|
|
@@ -75,6 +75,8 @@ async function gatherContext(octokit, repo, config) {
|
|
|
75
75
|
prsSummary,
|
|
76
76
|
workflowsSummary,
|
|
77
77
|
supervisor: config.supervisor,
|
|
78
|
+
configToml: config.configToml,
|
|
79
|
+
packageJson: config.packageJson,
|
|
78
80
|
featureIssuesWipLimit: config.featureDevelopmentIssuesWipLimit,
|
|
79
81
|
maintenanceIssuesWipLimit: config.maintenanceIssuesWipLimit,
|
|
80
82
|
};
|
|
@@ -109,6 +111,12 @@ function buildPrompt(ctx, agentInstructions) {
|
|
|
109
111
|
"",
|
|
110
112
|
`### Supervisor: ${ctx.supervisor}`,
|
|
111
113
|
"",
|
|
114
|
+
"### Configuration (agentic-lib.toml)",
|
|
115
|
+
"```toml",
|
|
116
|
+
ctx.configToml || "",
|
|
117
|
+
"```",
|
|
118
|
+
"",
|
|
119
|
+
...(ctx.packageJson ? ["### Dependencies (package.json)", "```json", ctx.packageJson, "```", ""] : []),
|
|
112
120
|
`### Issue Limits`,
|
|
113
121
|
`Feature development WIP limit: ${ctx.featureIssuesWipLimit}`,
|
|
114
122
|
`Maintenance WIP limit: ${ctx.maintenanceIssuesWipLimit}`,
|
|
@@ -123,6 +131,7 @@ function buildPrompt(ctx, agentInstructions) {
|
|
|
123
131
|
"- `dispatch:agent-flow-review` — Close resolved issues, enhance issue criteria",
|
|
124
132
|
"- `dispatch:agent-flow-fix-code | pr-number: <N>` — Fix a failing PR",
|
|
125
133
|
"- `dispatch:agent-discussions-bot` — Proactively post in discussions",
|
|
134
|
+
"- `dispatch:ci-automerge` — Merge open PRs with the automerge label if checks pass",
|
|
126
135
|
"",
|
|
127
136
|
"### GitHub API Actions",
|
|
128
137
|
"- `github:create-issue | title: <text> | labels: <comma-separated>` — Create a new issue",
|
|
@@ -82,7 +82,7 @@ export async function transform(context) {
|
|
|
82
82
|
"Determine the single most impactful next step to transform this repository.",
|
|
83
83
|
"Then implement that step.",
|
|
84
84
|
"",
|
|
85
|
-
formatPathsSection(writablePaths, readOnlyPaths),
|
|
85
|
+
formatPathsSection(writablePaths, readOnlyPaths, config),
|
|
86
86
|
"",
|
|
87
87
|
"## Constraints",
|
|
88
88
|
`- Run \`${testCommand}\` to validate your changes`,
|
|
@@ -153,7 +153,7 @@ async function transformTdd({
|
|
|
153
153
|
`## Open Issues (${openIssues.length})`,
|
|
154
154
|
...openIssues.slice(0, 10).map((i) => `- #${i.number}: ${i.title}`),
|
|
155
155
|
"",
|
|
156
|
-
formatPathsSection(writablePaths, readOnlyPaths),
|
|
156
|
+
formatPathsSection(writablePaths, readOnlyPaths, _config),
|
|
157
157
|
"",
|
|
158
158
|
"## Constraints",
|
|
159
159
|
"- Write ONLY test code in this phase",
|
|
@@ -193,7 +193,7 @@ async function transformTdd({
|
|
|
193
193
|
`## Current Source Files (${sourceFiles.length})`,
|
|
194
194
|
...sourceFiles.map((f) => `### ${f.name}\n\`\`\`\n${f.content}\n\`\`\``),
|
|
195
195
|
"",
|
|
196
|
-
formatPathsSection(writablePaths, readOnlyPaths),
|
|
196
|
+
formatPathsSection(writablePaths, readOnlyPaths, _config),
|
|
197
197
|
"",
|
|
198
198
|
"## Output Artifacts",
|
|
199
199
|
"If your changes produce output artifacts (plots, visualizations, data files, usage examples),",
|
|
@@ -23,6 +23,7 @@ You are the supervisor of an autonomous coding repository. Your job is to advanc
|
|
|
23
23
|
- **dispatch:agent-flow-fix-code** — When a specific PR has failing checks. Always include the pr-number.
|
|
24
24
|
- **dispatch:agent-flow-maintain** — When features are below their limit AND no maintain appears in the last 3 workflow runs.
|
|
25
25
|
- **dispatch:agent-discussions-bot** — When you want to proactively engage in discussions or respond to a user request.
|
|
26
|
+
- **dispatch:ci-automerge** — When open PRs with the `automerge` label appear ready to merge but no merge activity shows in recent runs. Recovery action — ci-automerge normally fires on event triggers.
|
|
26
27
|
- **github:label-issue** — When an issue needs better categorisation for prioritisation.
|
|
27
28
|
- **github:close-issue** — When an issue is clearly resolved or no longer relevant.
|
|
28
29
|
- **respond:discussions** — When replying to a user request that came through the discussions bot. Include the discussion URL and a clear message.
|
package/src/seeds/init.yml
CHANGED
|
@@ -25,8 +25,6 @@ on:
|
|
|
25
25
|
type: string
|
|
26
26
|
required: false
|
|
27
27
|
default: "true"
|
|
28
|
-
schedule:
|
|
29
|
-
- cron: "03 8,9 * * 1"
|
|
30
28
|
|
|
31
29
|
env:
|
|
32
30
|
pullRequestLabel: "automerge"
|
|
@@ -154,7 +152,6 @@ jobs:
|
|
|
154
152
|
ls:
|
|
155
153
|
needs: label
|
|
156
154
|
if: >-
|
|
157
|
-
github.event_name == 'schedule' ||
|
|
158
155
|
github.event_name == 'workflow_dispatch' ||
|
|
159
156
|
github.event_name == 'workflow_run' ||
|
|
160
157
|
inputs.workflow == 'true' ||
|