@integrity-labs/agt-cli 0.10.2 → 0.10.4

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.
@@ -10,7 +10,7 @@ import {
10
10
  provisionStopHook,
11
11
  requireHost,
12
12
  resolveChannels
13
- } from "../chunk-VCKY6MN2.js";
13
+ } from "../chunk-CVQD6XGB.js";
14
14
  import {
15
15
  findTaskByTemplate,
16
16
  getProjectDir,
@@ -1530,7 +1530,18 @@ async function processAgent(agent, agentStates) {
1530
1530
  for (const artifact of artifacts) {
1531
1531
  const filePath = join(agentDir, artifact.relativePath);
1532
1532
  const newHash = sha256(artifact.content);
1533
- const existingHash = hashFile(filePath);
1533
+ let existingHash;
1534
+ if (artifact.relativePath === "CLAUDE.md") {
1535
+ try {
1536
+ const existing = readFileSync(filePath, "utf-8");
1537
+ const stripped = existing.replace(new RegExp(`${SKILLS_INDEX_START}[\\s\\S]*?${SKILLS_INDEX_END}`), "").trimEnd();
1538
+ existingHash = sha256(stripped);
1539
+ } catch {
1540
+ existingHash = null;
1541
+ }
1542
+ } else {
1543
+ existingHash = hashFile(filePath);
1544
+ }
1534
1545
  if (newHash !== existingHash) {
1535
1546
  changedFiles.push(artifact);
1536
1547
  }
@@ -1541,7 +1552,23 @@ async function processAgent(agent, agentStates) {
1541
1552
  const fileNames = changedFiles.map((f) => f.relativePath).join(", ");
1542
1553
  log(`${verb} '${agent.code_name}': ${fileNames}`);
1543
1554
  for (const file of changedFiles) {
1544
- writeFileSync(join(agentDir, file.relativePath), file.content);
1555
+ const filePath = join(agentDir, file.relativePath);
1556
+ mkdirSync(dirname(filePath), { recursive: true });
1557
+ writeFileSync(filePath, file.content);
1558
+ }
1559
+ try {
1560
+ const provSkillsDir = join(agentDir, ".claude", "skills");
1561
+ if (existsSync(provSkillsDir)) {
1562
+ for (const folder of readdirSync(provSkillsDir)) {
1563
+ if (folder.startsWith("knowledge-")) {
1564
+ try {
1565
+ rmSync(join(provSkillsDir, folder), { recursive: true });
1566
+ } catch {
1567
+ }
1568
+ }
1569
+ }
1570
+ }
1571
+ } catch {
1545
1572
  }
1546
1573
  lastProvisionAt = (/* @__PURE__ */ new Date()).toISOString();
1547
1574
  knownVersions.set(agent.agent_id, { charterVersion, toolsVersion });
@@ -2492,6 +2519,7 @@ async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
2492
2519
  } catch {
2493
2520
  }
2494
2521
  }
2522
+ delete childEnv.ANTHROPIC_API_KEY;
2495
2523
  const { stdout, stderr } = await execFilePromiseLong("claude", claudeArgs, {
2496
2524
  cwd: projectDir,
2497
2525
  timeout: 3e5,
@@ -2519,6 +2547,14 @@ async function executeAndProcessClaudeTask(codeName, agentId, task, prompt) {
2519
2547
  } catch (err) {
2520
2548
  const errMsg = err instanceof Error ? err.message : String(err);
2521
2549
  log(`[claude-scheduler] Task '${task.name}' failed for '${codeName}': ${errMsg}`);
2550
+ if (err instanceof ChildProcessError) {
2551
+ if (err.stdout.trim()) {
2552
+ log(`[claude-scheduler] Task '${task.name}' stdout for '${codeName}': ${err.stdout.trim().slice(0, 1e3)}`);
2553
+ }
2554
+ if (err.stderr.trim()) {
2555
+ log(`[claude-scheduler] Task '${task.name}' stderr for '${codeName}': ${err.stderr.trim().slice(0, 1e3)}`);
2556
+ }
2557
+ }
2522
2558
  const updated = markTaskFired(codeName, task.taskId, "error");
2523
2559
  claudeSchedulerStates.set(codeName, updated);
2524
2560
  }
@@ -3022,6 +3058,7 @@ async function processDirectChatMessage(agent, msg) {
3022
3058
  } catch {
3023
3059
  }
3024
3060
  }
3061
+ delete childEnv.ANTHROPIC_API_KEY;
3025
3062
  const { stdout } = await execFilePromiseLong("claude", chatArgs, { cwd: projDir, stdin: "ignore", env: childEnv });
3026
3063
  reply = stdout.trim() || "[No response from agent]";
3027
3064
  } else {
@@ -3420,6 +3457,21 @@ async function execFilePromise(cmd, args) {
3420
3457
  });
3421
3458
  });
3422
3459
  }
3460
+ var ChildProcessError = class extends Error {
3461
+ code;
3462
+ stdout;
3463
+ stderr;
3464
+ constructor(code, stdout, stderr) {
3465
+ const stderrSnippet = stderr.trim().slice(0, 500);
3466
+ const stdoutSnippet = stdout.trim().slice(0, 500);
3467
+ const detail = stderrSnippet || stdoutSnippet || "(no output)";
3468
+ super(`Exit code ${code}: ${detail}`);
3469
+ this.name = "ChildProcessError";
3470
+ this.code = code;
3471
+ this.stdout = stdout;
3472
+ this.stderr = stderr;
3473
+ }
3474
+ };
3423
3475
  async function execFilePromiseLong(cmd, args, opts) {
3424
3476
  const { spawn: sp } = await import("child_process");
3425
3477
  return new Promise((resolve, reject) => {
@@ -3442,7 +3494,7 @@ async function execFilePromiseLong(cmd, args, opts) {
3442
3494
  }, opts?.timeout ?? 12e4);
3443
3495
  child.on("close", (code) => {
3444
3496
  clearTimeout(timer);
3445
- if (code !== 0) reject(new Error(`Exit code ${code}: ${stderr.slice(0, 500)}`));
3497
+ if (code !== 0) reject(new ChildProcessError(code, stdout, stderr));
3446
3498
  else resolve({ stdout, stderr });
3447
3499
  });
3448
3500
  child.on("error", (err) => {
@@ -3731,7 +3783,8 @@ function generateArtifacts(agent, refreshData, adapter) {
3731
3783
  team: refreshData.team ?? void 0,
3732
3784
  timezone: agentTimezone,
3733
3785
  reportsTo,
3734
- personalitySeed
3786
+ personalitySeed,
3787
+ knowledge: (refreshData.knowledge ?? []).filter((k) => !!k.content)
3735
3788
  };
3736
3789
  const provisionOutput = provision(provisionInput, adapter.id);
3737
3790
  return provisionOutput.artifacts;
@@ -3975,6 +4028,7 @@ process.on("disconnect", () => {
3975
4028
  });
3976
4029
  });
3977
4030
  export {
4031
+ ChildProcessError,
3978
4032
  startManager,
3979
4033
  stopManager
3980
4034
  };