@xn-intenton-z2a/agentic-lib 7.1.81 → 7.1.82

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.
@@ -32,6 +32,10 @@ on:
32
32
  type: string
33
33
  required: false
34
34
  default: ""
35
+ message:
36
+ type: string
37
+ required: false
38
+ default: ""
35
39
  model:
36
40
  type: string
37
41
  required: false
@@ -43,6 +47,11 @@ on:
43
47
  type: string
44
48
  required: false
45
49
  default: ""
50
+ message:
51
+ description: "Context message from supervisor or lifecycle event"
52
+ type: string
53
+ required: false
54
+ default: ""
46
55
  model:
47
56
  description: "Copilot SDK model to use"
48
57
  type: choice
@@ -169,6 +178,7 @@ jobs:
169
178
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
170
179
  COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
171
180
  TEST_RESULT: ${{ steps.tests.outputs.result }}
181
+ BOT_MESSAGE: ${{ inputs.message }}
172
182
  with:
173
183
  task: "discussions"
174
184
  config: ${{ env.configPath }}
@@ -61,14 +61,19 @@ jobs:
61
61
  - name: Install dependencies
62
62
  run: npm ci
63
63
 
64
- - name: Build website
65
- run: npm run build:web
66
-
67
64
  - name: Run behaviour tests
68
65
  run: npm run test:behaviour
69
66
  env:
70
67
  HOME: /root
71
68
 
69
+ - name: Upload screenshot
70
+ if: always()
71
+ uses: actions/upload-artifact@v4
72
+ with:
73
+ name: screenshot
74
+ path: SCREENSHOT_INDEX.png
75
+ if-no-files-found: ignore
76
+
72
77
  - name: Push screenshot on main
73
78
  if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
74
79
  run: |
@@ -411,6 +411,7 @@ jobs:
411
411
  env:
412
412
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
413
413
  COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
414
+ INPUT_MESSAGE: ${{ needs.params.outputs.message }}
414
415
  with:
415
416
  task: "supervise"
416
417
  config: ${{ needs.params.outputs.config-path }}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xn-intenton-z2a/agentic-lib",
3
- "version": "7.1.81",
3
+ "version": "7.1.82",
4
4
  "description": "Agentic-lib Agentic Coding Systems SDK powering automated GitHub workflows.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -104,6 +104,18 @@ function buildPrompt(discussionUrl, discussion, context, t, repoContext, trigger
104
104
  parts.push("", "### Your Last Reply (DO NOT REPEAT THIS)", lastBotReply.body.substring(0, 500));
105
105
  }
106
106
 
107
+ // Include supervisor message if dispatched with context
108
+ const botMessage = process.env.BOT_MESSAGE || "";
109
+ if (botMessage) {
110
+ parts.push(
111
+ "",
112
+ "## Triggering Request",
113
+ "The supervisor dispatched you with the following message. This is your primary request — respond to it in the discussion thread:",
114
+ "",
115
+ botMessage,
116
+ );
117
+ }
118
+
107
119
  parts.push(
108
120
  "",
109
121
  "## Repository Context",
@@ -55,7 +55,8 @@ async function dispatchBot(octokit, repo, message, discussionUrl) {
55
55
  core.info("Skipping bot dispatch — running in SDK repo");
56
56
  return;
57
57
  }
58
- const inputs = { message };
58
+ const inputs = {};
59
+ if (message) inputs.message = message;
59
60
  if (discussionUrl) inputs["discussion-url"] = discussionUrl;
60
61
  try {
61
62
  await octokit.rest.actions.createWorkflowDispatch({
@@ -64,7 +65,7 @@ async function dispatchBot(octokit, repo, message, discussionUrl) {
64
65
  ref: "main",
65
66
  inputs,
66
67
  });
67
- core.info(`Dispatched bot: ${message.substring(0, 100)}`);
68
+ core.info(`Dispatched bot: ${(message || discussionUrl || "(default)").substring(0, 100)}`);
68
69
  } catch (err) {
69
70
  core.warning(`Could not dispatch bot: ${err.message}`);
70
71
  }
@@ -234,6 +235,23 @@ async function gatherContext(octokit, repo, config, t) {
234
235
  core.warning(`Could not fetch workflow runs: ${err.message}`);
235
236
  }
236
237
 
238
+ // Scan source files for exported function/const names (Strategy E: source summary for supervisor)
239
+ let sourceExports = [];
240
+ try {
241
+ const sourcePath = config.paths.source?.path || "src/lib/";
242
+ if (existsSync(sourcePath)) {
243
+ const sourceFiles = scanDirectory(sourcePath, [".js", ".ts"], { limit: 5 });
244
+ for (const sf of sourceFiles) {
245
+ const content = readFileSync(sf.path, "utf8");
246
+ const exports = [...content.matchAll(/export\s+(?:async\s+)?(?:function|const|let|var|class)\s+(\w+)/g)]
247
+ .map((m) => m[1]);
248
+ if (exports.length > 0) {
249
+ sourceExports.push(`${sf.name}: ${exports.join(", ")}`);
250
+ }
251
+ }
252
+ }
253
+ } catch { /* ignore */ }
254
+
237
255
  return {
238
256
  mission,
239
257
  recentActivity,
@@ -260,6 +278,7 @@ async function gatherContext(octokit, repo, config, t) {
260
278
  transformationBudget,
261
279
  cumulativeTransformationCost,
262
280
  recentlyClosedSummary,
281
+ sourceExports,
263
282
  };
264
283
  }
265
284
 
@@ -287,6 +306,14 @@ function buildPrompt(ctx, agentInstructions) {
287
306
  `### Library Docs (${ctx.libraryNames.length}/${ctx.libraryLimit})`,
288
307
  ctx.libraryNames.join(", ") || "none",
289
308
  "",
309
+ ...(ctx.sourceExports?.length > 0
310
+ ? [
311
+ `### Source Exports`,
312
+ "Functions and constants exported from source files:",
313
+ ...ctx.sourceExports.map((e) => `- ${e}`),
314
+ "",
315
+ ]
316
+ : []),
290
317
  `### Recent Workflow Runs`,
291
318
  ctx.workflowsSummary.join("\n") || "none",
292
319
  "",
@@ -509,20 +536,13 @@ async function executeCloseIssue(octokit, repo, params) {
509
536
  async function executeRespondDiscussions(octokit, repo, params, ctx) {
510
537
  const message = params.message || "";
511
538
  const url = params["discussion-url"] || ctx?.activeDiscussionUrl || "";
512
- if (message) {
539
+ if (message || url) {
513
540
  if (process.env.GITHUB_REPOSITORY === "xn-intenton-z2a/agentic-lib") {
514
541
  core.info("Skipping bot dispatch — running in SDK repo");
515
542
  return `skipped:sdk-repo:respond-discussions`;
516
543
  }
517
- core.info(`Dispatching discussions bot with response: ${message.substring(0, 100)}`);
518
- const inputs = { message };
519
- if (url) inputs["discussion-url"] = url;
520
- await octokit.rest.actions.createWorkflowDispatch({
521
- ...repo,
522
- workflow_id: "agentic-lib-bot.yml",
523
- ref: "main",
524
- inputs,
525
- });
544
+ core.info(`Dispatching discussions bot: ${(message || url).substring(0, 100)}`);
545
+ await dispatchBot(octokit, repo, message, url);
526
546
  return `respond-discussions:${url || "no-url"}`;
527
547
  }
528
548
  return "skipped:respond-no-message";
@@ -648,9 +668,12 @@ export async function supervise(context) {
648
668
  // --- Deterministic lifecycle posts (before LLM) ---
649
669
 
650
670
  // Step 2: Auto-announce on first run after init
651
- // Detect first supervisor run: initTimestamp exists but no supervisor entries in activity
671
+ // Detect first supervisor run: initTimestamp exists but no prior supervisor workflow runs since init
652
672
  if (ctx.initTimestamp && !ctx.missionComplete && !ctx.missionFailed) {
653
- const hasPriorSupervisor = ctx.recentActivity.includes("supervisor");
673
+ const hasPriorSupervisor = ctx.actionsSinceInit.some(
674
+ (a) => a.name === "agentic-lib-workflow" && a.conclusion === "success" &&
675
+ a.commitMessage?.toLowerCase().includes("supervisor"),
676
+ ) || ctx.recentActivity.includes("supervised:");
654
677
  if (!hasPriorSupervisor && ctx.mission && ctx.activeDiscussionUrl) {
655
678
  core.info("First supervisor run after init — announcing mission");
656
679
  const announcement = `New mission started!\n\n**Mission:** ${ctx.mission.substring(0, 300)}\n\n**Website:** ${websiteUrl}`;
@@ -691,6 +714,28 @@ export async function supervise(context) {
691
714
 
692
715
  // --- Deterministic lifecycle posts (after LLM) ---
693
716
 
717
+ // Strategy A: Deterministic mission-complete fallback
718
+ // If the LLM didn't choose mission-complete but conditions are clearly met, auto-execute it.
719
+ if (!ctx.missionComplete && !ctx.missionFailed) {
720
+ const llmChoseMissionComplete = results.some((r) => r.startsWith("mission-complete:"));
721
+ if (!llmChoseMissionComplete) {
722
+ const resolvedCount = ctx.recentlyClosedSummary.filter((s) => s.includes("closed by review as RESOLVED")).length;
723
+ const hasNoOpenIssues = ctx.issuesSummary.length === 0;
724
+ const hasNoOpenPRs = ctx.prsSummary.length === 0;
725
+ if (hasNoOpenIssues && hasNoOpenPRs && resolvedCount >= 2) {
726
+ core.info(`Deterministic mission-complete: 0 open issues, 0 open PRs, ${resolvedCount} recently resolved — LLM did not detect completion`);
727
+ try {
728
+ const autoResult = await executeMissionComplete(octokit, repo,
729
+ { reason: `All acceptance criteria satisfied (${resolvedCount} issues closed by review as RESOLVED, 0 open issues, 0 open PRs)` },
730
+ ctx);
731
+ results.push(autoResult);
732
+ } catch (err) {
733
+ core.warning(`Deterministic mission-complete failed: ${err.message}`);
734
+ }
735
+ }
736
+ }
737
+ }
738
+
694
739
  // Step 3: Auto-respond when a message referral is present
695
740
  // If the workflow was triggered with a message (from bot's request-supervisor),
696
741
  // and the LLM didn't include a respond:discussions action, post back automatically
@@ -1,8 +1,18 @@
1
1
  You are the supervisor of an autonomous coding repository. Your job is to advance the mission by strategically choosing which workflows to dispatch and which GitHub actions to take.
2
2
 
3
+ ## MANDATORY FIRST CHECK: Is the Mission Already Complete?
4
+
5
+ **Before choosing ANY action, evaluate this:**
6
+
7
+ 1. Are there 0 open issues?
8
+ 2. Were 2+ recently-closed issues "closed by review as RESOLVED"?
9
+ 3. Do the Source Exports show the functions required by MISSION.md?
10
+
11
+ If ALL three are true → the mission is done. Choose `mission-complete | reason: <summary>`. Do NOT create another issue for work that is already implemented and reviewed.
12
+
3
13
  ## Priority Order
4
14
 
5
- 1. **Always strive for mission complete** — every action you take should aim to finish the mission. Create one comprehensive issue that targets the entire mission (all acceptance criteria, tests, website, docs, README). Only create a second issue if the first transform couldn't complete everything, and scope it to the remaining work. Do not create issues just to fill a quota.
15
+ 1. **Always strive for mission complete** — every action you take should aim to finish the mission. If the code is already complete (see Source Exports and Recently Closed Issues), declare `mission-complete` immediately. Otherwise, create one comprehensive issue that targets the entire mission (all acceptance criteria, tests, website, docs, README). Only create a second issue if the first transform couldn't complete everything, and scope it to the remaining work. Do not create issues just to fill a quota.
6
16
  2. **Dispatch transform when ready issues exist** — transform is where code gets written. Always prefer it over maintain when there are open issues with the `ready` label.
7
17
  3. **Dispatch review after transform** — when recent workflow runs show a transform completion, dispatch review to close resolved issues and add `ready` labels to new issues. This keeps the pipeline flowing.
8
18
  4. **Fix failing PRs** — dispatch fix-code for any PR with failing checks (include pr-number).
@@ -17,7 +17,7 @@
17
17
  "author": "",
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
- "@xn-intenton-z2a/agentic-lib": "^7.1.81"
20
+ "@xn-intenton-z2a/agentic-lib": "^7.1.82"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@playwright/test": "^1.58.0",