@lazyingart/agintiflow 0.20.228 → 0.20.229

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.228",
3
+ "version": "0.20.229",
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",
@@ -32,7 +32,11 @@ import {
32
32
  import { createPlan } from "../src/model-client.js";
33
33
  import { selectModelRoute } from "../src/model-routing.js";
34
34
  import { listParallelScouts, runParallelScouts, shouldRunParallelScouts } from "../src/parallel-scouts.js";
35
- import { buildFailedCommandAdvice, buildPermissionAdvice } from "../src/permission-advice.js";
35
+ import {
36
+ buildFailedCommandAdvice,
37
+ buildPermissionAdvice,
38
+ isOptionalGeneratedPreviewCleanup,
39
+ } from "../src/permission-advice.js";
36
40
  import { runJsonSpecialist } from "../src/json-specialist.js";
37
41
  import { SessionStore } from "../src/session-store.js";
38
42
  import { getTaskProfile } from "../src/task-profiles.js";
@@ -1203,6 +1207,38 @@ try {
1203
1207
  destructiveAdvice.destructiveApprovalCommand.includes("--allow-destructive"),
1204
1208
  "destructive advice did not provide an explicit approval command"
1205
1209
  );
1210
+ const optionalPreviewCleanupArgs = {
1211
+ command:
1212
+ "rm -f build/verification/page-1.png build/verification/page-2.png; git status --short",
1213
+ };
1214
+ assert(
1215
+ isOptionalGeneratedPreviewCleanup("run_command", optionalPreviewCleanupArgs),
1216
+ "bounded generated verification-preview cleanup was not recognized"
1217
+ );
1218
+ const optionalPreviewCleanupAdvice = buildPermissionAdvice({
1219
+ toolName: "run_command",
1220
+ args: optionalPreviewCleanupArgs,
1221
+ guard: {
1222
+ category: "destructive",
1223
+ reason: "Destructive shell commands require Allow destructive actions.",
1224
+ },
1225
+ config: dockerWorkspacePolicy,
1226
+ state: { sessionId: "coding-optional-preview-cleanup-smoke" },
1227
+ });
1228
+ assert(
1229
+ optionalPreviewCleanupAdvice.autoRecover === true,
1230
+ "optional generated-preview cleanup should retain evidence and recover without pausing"
1231
+ );
1232
+ assert(
1233
+ /leave the ignored preview files in place/i.test(optionalPreviewCleanupAdvice.instruction),
1234
+ "optional generated-preview cleanup advice did not tell the agent to retain evidence"
1235
+ );
1236
+ assert(
1237
+ !isOptionalGeneratedPreviewCleanup("run_command", {
1238
+ command: "rm -f output/final-report.pdf",
1239
+ }),
1240
+ "a requested final artifact was misclassified as optional preview cleanup"
1241
+ );
1206
1242
  const failedNetworkAdvice = buildFailedCommandAdvice({
1207
1243
  args: { command: "git clone https://github.com/lazyingart/AgInTiFlow.git" },
1208
1244
  commandPolicy: clonePolicy,
@@ -270,8 +270,8 @@ const wordDocumentContract = deriveScsTaskContract({
270
270
  });
271
271
  assert.deepEqual(
272
272
  wordDocumentContract.requiredEvidence.map((item) => item.category).sort(),
273
- ["artifact", "command", "file"],
274
- "Word document production must require written files, validation, and durable artifacts"
273
+ ["artifact", "command", "file", "visual"],
274
+ "Word document production must require written files, validation, durable artifacts, and visual evidence"
275
275
  );
276
276
 
277
277
  const groundingRoot = fs.mkdtempSync(path.join(os.tmpdir(), "aginti-source-grounding-"));
@@ -23,6 +23,50 @@ const DOCKER_WORKSPACE_PATH_FAILURE_PATTERNS = [
23
23
  /cannot statx? ['"][^'"]+['"]:\s+No such file or directory/i,
24
24
  ];
25
25
 
26
+ function unquoteShellToken(value = "") {
27
+ const text = String(value || "").trim();
28
+ if (
29
+ text.length >= 2 &&
30
+ ((text.startsWith("'") && text.endsWith("'")) ||
31
+ (text.startsWith('"') && text.endsWith('"')))
32
+ ) {
33
+ return text.slice(1, -1);
34
+ }
35
+ return text;
36
+ }
37
+
38
+ function isGeneratedVerificationPreviewPath(value = "") {
39
+ const target = unquoteShellToken(value).replace(/\\/g, "/");
40
+ if (
41
+ !target ||
42
+ target.startsWith("/") ||
43
+ target.includes("..") ||
44
+ /[*?\[\]{}$`]/.test(target)
45
+ ) {
46
+ return false;
47
+ }
48
+ return (
49
+ /^(?:build|artifacts)\/verification\/[A-Za-z0-9._/-]+\.(?:png|jpe?g|webp)$/i.test(target) ||
50
+ /^output\/preview[-_][A-Za-z0-9._-]+\.(?:png|jpe?g|webp)$/i.test(target)
51
+ );
52
+ }
53
+
54
+ export function isOptionalGeneratedPreviewCleanup(toolName = "", args = {}) {
55
+ if (toolName !== "run_command") return false;
56
+ const firstSegment = String(args.command || args.text || "")
57
+ .trim()
58
+ .split(/(?:&&|;|\n)/, 1)[0]
59
+ .trim();
60
+ const match = firstSegment.match(/^rm\s+-f\s+(.+)$/);
61
+ if (!match) return false;
62
+ const targets = match[1].trim().split(/\s+/).filter(Boolean);
63
+ return (
64
+ targets.length > 0 &&
65
+ targets.length <= 20 &&
66
+ targets.every((target) => isGeneratedVerificationPreviewPath(target))
67
+ );
68
+ }
69
+
26
70
  function quoteShell(value = "") {
27
71
  const text = String(value || "");
28
72
  return `'${text.replace(/'/g, `'\\''`)}'`;
@@ -214,6 +258,21 @@ function adviceForCategory(category = "", { toolName = "", args = {}, config = {
214
258
  }
215
259
 
216
260
  if (category === "destructive") {
261
+ if (isOptionalGeneratedPreviewCleanup(toolName, args)) {
262
+ return {
263
+ ...base,
264
+ autoRecover: true,
265
+ summary:
266
+ "Optional generated-preview cleanup was blocked safely; the verification evidence can remain ignored and the task should continue.",
267
+ instruction:
268
+ "Do not retry, rename, or seek approval for this cleanup. Leave the ignored preview files in place, run any remaining read-only checks in a separate call, and finish the requested task when its substantive evidence passes.",
269
+ options: [
270
+ "Retain the generated previews as private verification evidence.",
271
+ "Run source hashes, artifact checks, and git status separately without a delete command.",
272
+ "Continue to a real content or layout repair if validation still reports a defect.",
273
+ ],
274
+ };
275
+ }
217
276
  return {
218
277
  ...base,
219
278
  summary:
@@ -259,7 +259,7 @@ const PROFILE_REQUIREMENTS = {
259
259
  design: ["artifact", "visual"],
260
260
  image: ["artifact", "visual"],
261
261
  slides: ["artifact"],
262
- word: ["file", "command", "artifact"],
262
+ word: ["file", "command", "artifact", "visual"],
263
263
  data: ["file", "command", "artifact"],
264
264
  qa: ["command"],
265
265
  review: ["command"],
@@ -276,7 +276,7 @@ export const TASK_PROFILES = {
276
276
  id: "word",
277
277
  label: "Word documents",
278
278
  prompt:
279
- "Bias toward Word/docx/document workflows while still using writing, conversion, LaTeX, or scripts when useful. Preserve source material byte-for-byte and synthesize a reader-facing document from the current corrected facts instead of concatenating notes, logs, schemas, task IDs, private paths, or delivery instructions. Prefer mature editable-document tooling already available in the workspace, such as python-docx, pandoc, or LibreOffice, over hand-written OOXML; when direct OOXML is genuinely necessary, validate its package parts and openability. Keep one maintainable source of truth and a reproducible project-local build command. Verify the DOCX is structurally editable, render or convert it for visual inspection, compile the PDF, inspect every rendered page, and run pdftotext or an equivalent extraction check that rejects replacement characters and unexpected control glyphs. Resolve stale-versus-current facts explicitly, use clear descriptive filenames, exclude caches and generated debris from commits, inspect git status/diff before committing, and report success only after the editable source, reader-facing content, visual layout, searchable text, and requested artifacts all pass.",
279
+ "Bias toward Word/docx/document workflows while still using writing, conversion, LaTeX, or scripts when useful. Preserve source material byte-for-byte and synthesize a reader-facing document from the authoritative current facts instead of concatenating notes, logs, schemas, task IDs, private paths, or delivery instructions. Reconcile conflicting or superseded source facts before drafting; publish only the current state unless history is explicitly requested or necessary to explain a live decision. Prefer mature editable-document tooling already available in the workspace, such as python-docx, pandoc, or LibreOffice, over hand-written OOXML; when direct OOXML is genuinely necessary, validate its package parts and openability. Keep one maintainable source of truth and a reproducible project-local build command. Verify the DOCX is structurally editable, compile the PDF, run pdftotext or an equivalent extraction check that rejects replacement characters and unexpected control glyphs, and render every PDF page to a separate image under an ignored build/verification directory. Inspect every rendered page individually and repair orphaned headings, near-empty spill pages, awkward table or paragraph breaks, overlaps, clipping, excessive whitespace, weak hierarchy, and inconsistent number formatting before finishing. Retain ignored verification renders as evidence; optional cleanup must never block completion. Use clear descriptive filenames, exclude caches and generated debris from commits, inspect git status/diff before committing, and report success only after the editable source, reader-facing current-state content, visual layout, searchable text, and requested artifacts all pass.",
280
280
  tools: ["files", "shell", "canvas", "sandbox"],
281
281
  },
282
282
  latex: {