@lazyingart/agintiflow 0.20.312 → 0.20.314

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazyingart/agintiflow",
3
- "version": "0.20.312",
3
+ "version": "0.20.314",
4
4
  "type": "module",
5
5
  "description": "AgInTiFlow is a project-aware agent workspace for hybrid wet-dry R&D, hardware-aware intelligence, software automation, and industrial workflows.",
6
6
  "license": "Apache-2.0",
@@ -11,6 +11,7 @@ import {
11
11
  modelPlanningTimeoutRetryRoute,
12
12
  nextStepRuntimeConfig,
13
13
  recordAlreadyCommittedRepositoryRepair,
14
+ recordProjectVerificationOutcome,
14
15
  runAgent,
15
16
  } from "../src/agent-runner.js";
16
17
  import { resolveRuntimeConfig } from "../src/config.js";
@@ -155,43 +156,42 @@ try {
155
156
  artifact_root: scopedArtifactRoot,
156
157
  })}`,
157
158
  ].join("\n");
158
- const scopedRuntime = nextStepRuntimeConfig(
159
- { commandCwd: scopedRepairRoot, goal: scopedGoal },
160
- {
161
- goal: scopedGoal,
162
- commandCwd: scopedRepairRoot,
163
- meta: {
164
- goalContract: {
165
- revision: 1,
166
- currentRequest: scopedGoal,
167
- currentHash: "scoped-repair",
168
- },
169
- activeExecutionContract: {
170
- revision: 1,
171
- refreshedAt,
172
- startedMutationRevision: 0,
173
- requiresWorkspaceMutation: true,
174
- requiresFileMutation: true,
175
- requiresSourceGrounding: true,
176
- },
177
- projectVerification: {
178
- mutationRevision: 0,
179
- mutationHistory: [],
180
- testRuns: [],
181
- discoveredTests: [],
182
- },
183
- toolLoop: {
184
- recent: [{
185
- toolName: "read_file",
186
- ok: true,
187
- blocked: false,
188
- path: scopedSource,
189
- at: groundedAt,
190
- }],
191
- },
159
+ const scopedState = {
160
+ goal: scopedGoal,
161
+ commandCwd: scopedRepairRoot,
162
+ meta: {
163
+ goalContract: {
164
+ revision: 1,
165
+ currentRequest: scopedGoal,
166
+ currentHash: "scoped-repair",
192
167
  },
193
- }
194
- );
168
+ activeExecutionContract: {
169
+ revision: 1,
170
+ refreshedAt,
171
+ startedMutationRevision: 0,
172
+ requiresWorkspaceMutation: true,
173
+ requiresFileMutation: true,
174
+ requiresSourceGrounding: true,
175
+ },
176
+ projectVerification: {
177
+ mutationRevision: 0,
178
+ mutationHistory: [],
179
+ testRuns: [],
180
+ discoveredTests: [],
181
+ },
182
+ toolLoop: {
183
+ recent: [{
184
+ toolName: "read_file",
185
+ ok: true,
186
+ blocked: false,
187
+ path: scopedSource,
188
+ at: groundedAt,
189
+ }],
190
+ },
191
+ },
192
+ };
193
+ const scopedConfig = { commandCwd: scopedRepairRoot, goal: scopedGoal };
194
+ const scopedRuntime = nextStepRuntimeConfig(scopedConfig, scopedState);
195
195
  assert.equal(scopedRuntime.scopedArtifactTask, true);
196
196
  assert.equal(
197
197
  scopedRuntime.completionFreshMutationRequired,
@@ -200,6 +200,34 @@ try {
200
200
  );
201
201
  assert.deepEqual(scopedRuntime.completionFreshMutationPaths, [scopedSource]);
202
202
  assert.equal(scopedRuntime.completionFreshMutationNeedsSourceRead, false);
203
+ recordProjectVerificationOutcome(
204
+ scopedState,
205
+ {
206
+ toolName: "write_file",
207
+ ok: true,
208
+ path: scopedSource,
209
+ args: { path: scopedSource },
210
+ change: {
211
+ path: scopedSource,
212
+ beforeHash: "rejected-report",
213
+ afterHash: "corrected-report",
214
+ beforeBytes: 18,
215
+ afterBytes: 96,
216
+ },
217
+ },
218
+ { ...scopedConfig, ...scopedRuntime }
219
+ );
220
+ assert.deepEqual(
221
+ scopedState.meta.activeExecutionContract.scopedArtifactMutationPaths,
222
+ [scopedSource],
223
+ "a successful scoped artifact write did not persist its current-turn mutation"
224
+ );
225
+ const scopedRuntimeAfterWrite = nextStepRuntimeConfig(scopedConfig, scopedState);
226
+ assert.equal(
227
+ scopedRuntimeAfterWrite.completionFreshMutationRequired,
228
+ undefined,
229
+ "a successful current-turn scoped artifact write remained trapped in source-mutation recovery"
230
+ );
203
231
  } finally {
204
232
  await fs.rm(scopedRepairRoot, { recursive: true, force: true });
205
233
  }
@@ -33,6 +33,19 @@ const groupBriefingContract = deriveScsTaskContract({
33
33
  ].join(" "),
34
34
  taskProfile: "research",
35
35
  });
36
+ const sourceIntakeAuditContract = deriveScsTaskContract({
37
+ goal: [
38
+ "Create one concise coherent Markdown report with exactly five numbered cases:",
39
+ "(1) a bare video has no publication;",
40
+ "(2) a current same-chat publish request authorizes only the exact referenced video through autopublish-video plus LazyEdit, while this audit performs no external action;",
41
+ "(3) Finder recovery remains evidence-limited;",
42
+ "(4) mp.weixin recovery never asks for browser verification;",
43
+ "(5) PDF/archive intake uses the guarded document reader.",
44
+ "Run only the focused existing unit test and write agent-result.json.",
45
+ "Do not send, publish, submit, upload, alter queues, or open a GUI.",
46
+ ].join(" "),
47
+ taskProfile: "auto",
48
+ });
36
49
  const scopedReadThenWriteRoot = fs.mkdtempSync(
37
50
  path.join(os.tmpdir(), "aginti-scoped-read-then-write-")
38
51
  );
@@ -83,6 +96,16 @@ assert.deepEqual(
83
96
  ["format:.pdf"],
84
97
  "an ordinary chat answer was incorrectly converted into a separate answer-key artifact"
85
98
  );
99
+ assert.deepEqual(
100
+ sourceIntakeAuditContract.requiredArtifactKinds.map((item) => item.id),
101
+ ["format:.md"],
102
+ "a Markdown-only audit inferred PDF from a described PDF intake case"
103
+ );
104
+ assert.equal(
105
+ sourceIntakeAuditContract.requiredEvidence.some((item) => item.category === "publish"),
106
+ false,
107
+ "a read-only audit of a publish contract fabricated a publish action obligation"
108
+ );
86
109
  assert.deepEqual(
87
110
  educationArtifactContract.requiredArtifactKinds.map((item) => item.id).sort(),
88
111
  [
@@ -6622,6 +6622,28 @@ export function recordProjectVerificationOutcome(state = {}, toolResult = {}, co
6622
6622
  const projectMutationPaths = successfulProjectMutationPaths(toolResult, state, config);
6623
6623
  const privateMutationPaths = successfulPrivateVerificationMutationPaths(toolResult);
6624
6624
  const materialMutationPaths = materialProjectMutationPaths(toolResult, state, config);
6625
+ const scopedArtifactMutationPaths = successfulScopedArtifactMutationPaths(
6626
+ toolResult,
6627
+ state,
6628
+ config
6629
+ );
6630
+ const activeExecutionContract = state.meta?.activeExecutionContract;
6631
+ if (
6632
+ ["write_file", "apply_patch"].includes(toolName) &&
6633
+ scopedArtifactMutationPaths.length > 0 &&
6634
+ Number(activeExecutionContract?.revision || 0) ===
6635
+ Number(state.meta?.goalContract?.revision || 0)
6636
+ ) {
6637
+ activeExecutionContract.scopedArtifactMutationAt = now;
6638
+ activeExecutionContract.scopedArtifactMutationPaths = [
6639
+ ...new Set([
6640
+ ...(Array.isArray(activeExecutionContract.scopedArtifactMutationPaths)
6641
+ ? activeExecutionContract.scopedArtifactMutationPaths
6642
+ : []),
6643
+ ...scopedArtifactMutationPaths,
6644
+ ]),
6645
+ ].slice(0, 24);
6646
+ }
6625
6647
  if (["write_file", "apply_patch"].includes(toolName) && privateMutationPaths.length) {
6626
6648
  delete state.meta.verifiedCompletionCandidate;
6627
6649
  verification.privateMutationRevision += 1;
@@ -6669,7 +6691,6 @@ export function recordProjectVerificationOutcome(state = {}, toolResult = {}, co
6669
6691
  }
6670
6692
  : {}),
6671
6693
  }, config);
6672
- const activeExecutionContract = state.meta?.activeExecutionContract;
6673
6694
  if (
6674
6695
  materialMutationPaths.length > 0 &&
6675
6696
  Number(activeExecutionContract?.revision || 0) ===
@@ -13820,6 +13841,33 @@ function successfulMutationPaths(toolResult = {}) {
13820
13841
  return [...new Set([toolResult.path, ...changes.map((change) => change.path)].filter(Boolean))];
13821
13842
  }
13822
13843
 
13844
+ function successfulScopedArtifactMutationPaths(
13845
+ toolResult = {},
13846
+ state = {},
13847
+ config = {}
13848
+ ) {
13849
+ const artifactRoot = String(
13850
+ config.scopedArtifactRoot ||
13851
+ scopedArtifactRoot(completionContractGoal(config, state)) ||
13852
+ ""
13853
+ ).trim();
13854
+ if (!artifactRoot) return [];
13855
+ const commandCwd = path.resolve(
13856
+ config.commandCwd || state.commandCwd || process.cwd()
13857
+ );
13858
+ const resolvedRoot = path.resolve(commandCwd, artifactRoot);
13859
+ return successfulMutationPaths(toolResult)
13860
+ .map((candidate) => path.resolve(commandCwd, String(candidate || "")))
13861
+ .filter((candidate) => {
13862
+ const relative = path.relative(resolvedRoot, candidate);
13863
+ return (
13864
+ relative === "" ||
13865
+ (!relative.startsWith("..") && !path.isAbsolute(relative))
13866
+ );
13867
+ })
13868
+ .map((candidate) => path.relative(commandCwd, candidate).replace(/\\/g, "/"));
13869
+ }
13870
+
13823
13871
  function successfulWorkspaceMutationPaths(toolResult = {}) {
13824
13872
  if (!toolResult || toolResult.blocked || toolResult.skipped) return [];
13825
13873
  if (!["write_file", "apply_patch"].includes(String(toolResult.toolName || ""))) return [];
@@ -15321,6 +15369,20 @@ export function nextStepRuntimeConfig(config = {}, state = {}) {
15321
15369
  runtimeConfig.scopedArtifactRoot = scopedRootRelative.replace(/\\/g, "/");
15322
15370
  runtimeConfig.workspaceWritePathScopeRoots = [runtimeConfig.scopedArtifactRoot];
15323
15371
  }
15372
+ const scopedArtifactMutationAt = Date.parse(
15373
+ String(groundingExecutionContract.scopedArtifactMutationAt || "")
15374
+ );
15375
+ const executionContractRefreshedAt = Date.parse(
15376
+ String(groundingExecutionContract.refreshedAt || "")
15377
+ );
15378
+ const groundingScopedArtifactMutationSatisfied = Boolean(
15379
+ scopedArtifactTask &&
15380
+ Number.isFinite(scopedArtifactMutationAt) &&
15381
+ (
15382
+ !Number.isFinite(executionContractRefreshedAt) ||
15383
+ scopedArtifactMutationAt >= executionContractRefreshedAt
15384
+ )
15385
+ );
15324
15386
  if (
15325
15387
  (
15326
15388
  groundingTaskContract.requiresSourceGrounding === true ||
@@ -15435,7 +15497,8 @@ export function nextStepRuntimeConfig(config = {}, state = {}) {
15435
15497
  const currentTurnRequiresFreshMutation = Boolean(
15436
15498
  groundingExecutionContract.requiresFileMutation === true &&
15437
15499
  groundingExecutionContract.requiresSourceGrounding === true &&
15438
- !groundingFreshMutationSatisfied
15500
+ !groundingFreshMutationSatisfied &&
15501
+ !groundingScopedArtifactMutationSatisfied
15439
15502
  );
15440
15503
  const explicitHeadRestore = currentTurnRequiresFreshMutation
15441
15504
  ? explicitlyRequestedDirtyHeadRestore(state, config)
@@ -583,6 +583,7 @@ const REQUESTED_ARTIFACT_FORMATS = [
583
583
  { extension: ".pptx", pattern: /\b(?:pptx|powerpoint)\b/i, description: "editable PowerPoint deck" },
584
584
  { extension: ".odp", pattern: /\b(?:odp|open(?:office|document) presentation)\b/i, description: "editable ODP deck" },
585
585
  { extension: ".pdf", pattern: /\bpdf\b/i, description: "PDF document" },
586
+ { extension: ".md", pattern: /(?:\bmarkdown\b|\.md\b)/i, description: "Markdown document" },
586
587
  {
587
588
  extension: ".tex",
588
589
  pattern: /(?:\b(?:editable\s+)?(?:latex|tex)\s+source\b|\.tex\b)/i,
@@ -594,6 +595,64 @@ const REQUESTED_ARTIFACT_FORMATS = [
594
595
  { extension: ".svg", pattern: /\bsvg\b/i, description: "editable SVG image" },
595
596
  ];
596
597
 
598
+ function requestedArtifactFormatHasOutputIntent(source = "", format = {}) {
599
+ const extension = String(format.extension || "").toLocaleLowerCase("en-US");
600
+ if (!extension || !format.pattern) return false;
601
+ if (
602
+ inferExactOutputPaths(source).some(
603
+ (candidate) => path.extname(candidate).toLocaleLowerCase("en-US") === extension
604
+ )
605
+ ) {
606
+ return true;
607
+ }
608
+
609
+ const matcher = new RegExp(
610
+ format.pattern.source,
611
+ format.pattern.flags.includes("g") ? format.pattern.flags : `${format.pattern.flags}g`
612
+ );
613
+ const outputAction =
614
+ /\b(?:compile|convert|create|deliver|export|generate|keep|make|output|prepare|preserve|produce|provide|render|retain|return|reuse|save|send|write)\b/i;
615
+ const directRequest =
616
+ /\b(?:can|could|would|will)\s+you\b|\b(?:i|we)\s+(?:also\s+)?(?:need|want|would\s+like|request)\b|\b(?:please|kindly)\b/i;
617
+ for (const match of source.matchAll(matcher)) {
618
+ const index = Number(match.index || 0);
619
+ const clauseStart = Math.max(
620
+ source.lastIndexOf(".", index - 1),
621
+ source.lastIndexOf("!", index - 1),
622
+ source.lastIndexOf("?", index - 1),
623
+ source.lastIndexOf(";", index - 1),
624
+ source.lastIndexOf("。", index - 1),
625
+ source.lastIndexOf("!", index - 1),
626
+ source.lastIndexOf("?", index - 1),
627
+ source.lastIndexOf(";", index - 1),
628
+ source.lastIndexOf("\n", index - 1)
629
+ );
630
+ const nextBoundaries = [".", "!", "?", ";", "。", "!", "?", ";", "\n"]
631
+ .map((delimiter) => source.indexOf(delimiter, index + String(match[0] || "").length))
632
+ .filter((candidate) => candidate >= 0);
633
+ const clauseEnd = nextBoundaries.length ? Math.min(...nextBoundaries) : source.length;
634
+ const clause = source.slice(clauseStart + 1, clauseEnd);
635
+ const matchOffset = index - clauseStart - 1;
636
+ const before = clause.slice(Math.max(0, matchOffset - 180), matchOffset);
637
+ const after = clause.slice(matchOffset + String(match[0] || "").length, matchOffset + 120);
638
+ if (outputAction.test(before) || directRequest.test(before)) return true;
639
+ if (
640
+ /\b(?:as|into|to)\s+(?:an?\s+)?$/i.test(before) &&
641
+ /\b(?:compile|convert|export|render|save)\b/i.test(clause)
642
+ ) {
643
+ return true;
644
+ }
645
+ if (
646
+ /^\s*(?:output|deliverable|file|document|report|version|copy)\b/i.test(after) &&
647
+ outputAction.test(clause)
648
+ ) {
649
+ return true;
650
+ }
651
+ if (/^\s*(?:please|required|requested)\b/i.test(after)) return true;
652
+ }
653
+ return false;
654
+ }
655
+
597
656
  function artifactRequestHasOutputIntent(goal = "", taskProfile = "") {
598
657
  const source = stripForbiddenLanguage(String(goal || ""));
599
658
  return Boolean(
@@ -622,7 +681,7 @@ export function inferRequestedArtifactRequirements(goal = "", taskProfile = "")
622
681
  };
623
682
 
624
683
  for (const format of REQUESTED_ARTIFACT_FORMATS) {
625
- if (!format.pattern.test(source)) continue;
684
+ if (!requestedArtifactFormatHasOutputIntent(source, format)) continue;
626
685
  add({
627
686
  id: `format:${format.extension}`,
628
687
  kind: "format",
@@ -1456,6 +1515,41 @@ function requiresSourceGrounding(goal = "") {
1456
1515
  );
1457
1516
  }
1458
1517
 
1518
+ function goalRequestsPublishAction(goal = "") {
1519
+ const text = normalizedText(stripCompletedWorkNarration(stripForbiddenLanguage(goal)));
1520
+ const action =
1521
+ "(?:publish|deploy|submit|upload\\s+to|generate\\s+(?:a\\s+)?video|npm\\s+publish)";
1522
+ const release =
1523
+ "(?:release|ship)(?:\\s+(?:(?:the|this|that|a|an)\\s+)?(?:package|version|build|app|application|software|library|plugin|extension|product)|\\s+(?:to|on|via|through))|cut\\s+(?:a\\s+)?release";
1524
+ const clauses = text
1525
+ .split(/[\n.!?;,;。!?]+/u)
1526
+ .map((clause) => clause.trim())
1527
+ .filter(Boolean);
1528
+ for (const clause of clauses) {
1529
+ if (
1530
+ new RegExp(
1531
+ `^(?:(?:and|also|then|next|finally|please|kindly)\\s+)*(?:${action}|${release})\\b`,
1532
+ "i"
1533
+ ).test(clause)
1534
+ ) {
1535
+ return true;
1536
+ }
1537
+ if (
1538
+ new RegExp(
1539
+ `\\b(?:(?:can|could|would|will)\\s+you|(?:i|we)\\s+(?:need|want|would\\s+like)\\s+(?:you\\s+)?to|you\\s+(?:must|should|need\\s+to|have\\s+to)|please|kindly|then|next|finally)\\b[^.\\n;]{0,140}\\b(?:${action}|${release})\\b`,
1540
+ "i"
1541
+ ).test(clause)
1542
+ ) {
1543
+ return true;
1544
+ }
1545
+ }
1546
+ return (
1547
+ /(?:请|請|需要|必须|必須|帮我|幫我|立即|现在|現在)[^。;\n]{0,100}(?:发布|發布|部署|提交|上传|上傳|生成视频|生成影片)/u.test(
1548
+ text
1549
+ ) || /^(?:发布|發布|部署|提交|上传|上傳|生成视频|生成影片)/u.test(text)
1550
+ );
1551
+ }
1552
+
1459
1553
  function inferRequirementCategories(goal = "", taskProfile = "", acceptanceCriteria = []) {
1460
1554
  const positiveGoal = stripForbiddenLanguage(goal);
1461
1555
  const text = normalizedText(positiveGoal);
@@ -1531,16 +1625,7 @@ function inferRequirementCategories(goal = "", taskProfile = "", acceptanceCrite
1531
1625
  ) {
1532
1626
  categories.add("visual");
1533
1627
  }
1534
- const explicitPublishAction =
1535
- textHas(
1536
- text,
1537
- /\b(?:publish|deploy|submit|upload to|generate video|external service|npm publish)\b/
1538
- ) ||
1539
- textHas(
1540
- text,
1541
- /\b(?:release|ship)\s+(?:(?:the|this|that|a|an)\s+)?(?:package|version|build|app|application|software|library|plugin|extension|product)\b|\b(?:release|ship)\s+(?:to|on|via|through)\b|\bcut\s+(?:a\s+)?release\b/
1542
- ) ||
1543
- /发布|部署|提交|生成视频|外部服务/.test(text);
1628
+ const explicitPublishAction = goalRequestsPublishAction(positiveGoal);
1544
1629
  if (explicitPublishAction) {
1545
1630
  categories.add("publish");
1546
1631
  }