@farmslot/agent-runtime 0.23.3 → 0.25.0

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/native/host-cleanup-recovery.d.ts.map +1 -1
  3. package/dist/native/host-cleanup-recovery.js +15 -3
  4. package/dist/native/host-cleanup-recovery.js.map +1 -1
  5. package/dist/native/process-tree.d.ts +1 -0
  6. package/dist/native/process-tree.d.ts.map +1 -1
  7. package/dist/native/process-tree.js +9 -4
  8. package/dist/native/process-tree.js.map +1 -1
  9. package/dist/task-init/execution-provenance.d.ts +47 -0
  10. package/dist/task-init/execution-provenance.d.ts.map +1 -0
  11. package/dist/task-init/execution-provenance.js +226 -0
  12. package/dist/task-init/execution-provenance.js.map +1 -0
  13. package/dist/task-init/index.d.ts +5 -0
  14. package/dist/task-init/index.d.ts.map +1 -1
  15. package/dist/task-init/index.js +25 -4
  16. package/dist/task-init/index.js.map +1 -1
  17. package/dist/task-init/pin.d.ts +6 -0
  18. package/dist/task-init/pin.d.ts.map +1 -0
  19. package/dist/task-init/pin.js +77 -0
  20. package/dist/task-init/pin.js.map +1 -0
  21. package/dist/task-init/runtime-command.d.ts +3 -1
  22. package/dist/task-init/runtime-command.d.ts.map +1 -1
  23. package/dist/task-init/runtime-command.js +7 -2
  24. package/dist/task-init/runtime-command.js.map +1 -1
  25. package/dist/task-init/task-document.d.ts +2 -0
  26. package/dist/task-init/task-document.d.ts.map +1 -1
  27. package/dist/task-init/task-document.js +12 -0
  28. package/dist/task-init/task-document.js.map +1 -1
  29. package/dist/task-init/write.d.ts +4 -2
  30. package/dist/task-init/write.d.ts.map +1 -1
  31. package/dist/task-init/write.js +7 -5
  32. package/dist/task-init/write.js.map +1 -1
  33. package/package.json +4 -4
  34. package/scripts/mark-checklist-step.cjs +60 -7
  35. package/scripts/mark-io.cjs +10 -0
  36. package/scripts/subtask-unit.cjs +5 -3
  37. package/scripts/task-init-cli.mjs +13 -8
@@ -96,10 +96,11 @@ function parseArgs(args) {
96
96
  return { opts, catalog };
97
97
  }
98
98
 
99
- function gitOutput(args) {
99
+ function gitOutput(args, cwd = process.cwd()) {
100
100
  try {
101
101
  return execFileSync('git', args, {
102
102
  encoding: 'utf8',
103
+ cwd,
103
104
  stdio: ['ignore', 'pipe', 'ignore'],
104
105
  }).trim();
105
106
  } catch {
@@ -108,21 +109,23 @@ function gitOutput(args) {
108
109
  }
109
110
  }
110
111
 
111
- async function main() {
112
- const args = process.argv.slice(2);
112
+ export async function taskInitFromArgv(args, execution, suppliedRuntime) {
113
+ args = [...args];
113
114
  if (args.length === 0 || args[0] === '-h' || args[0] === '--help') usage(0);
114
115
  const { opts, catalog } = parseArgs(args);
115
- const runtime = await loadRuntime();
116
+ const runtime = suppliedRuntime ?? (await loadRuntime());
116
117
 
117
118
  const description = opts.taskFile
118
119
  ? readFileSync(path.resolve(opts.taskFile), 'utf8').trim()
119
120
  : (opts.taskText ?? '').trim();
120
- const toplevel = gitOutput(['rev-parse', '--show-toplevel']);
121
- const originUrl = gitOutput(['remote', 'get-url', 'origin']);
121
+ const target = execution?.bindingIdentity?.target ?? process.cwd();
122
+ const toplevel = gitOutput(['rev-parse', '--show-toplevel'], target);
123
+ const originUrl = gitOutput(['remote', 'get-url', 'origin'], target);
122
124
  const repo = opts.repo ?? (originUrl ? runtime.portableRepoIdentity(originUrl) : undefined);
123
125
  const project =
124
126
  opts.project ??
125
- (repo ? repo.split('/').pop() : path.basename(toplevel || process.cwd())).toLowerCase();
127
+ execution?.bindingIdentity?.project ??
128
+ (repo ? repo.split('/').pop() : path.basename(toplevel || target)).toLowerCase();
126
129
  // Rendered inside taskInit with the same vars as the checklist, so an addendum
127
130
  // that works on the farm works here.
128
131
  const addendum = opts.addendumFile ? readFileSync(path.resolve(opts.addendumFile), 'utf8') : null;
@@ -153,6 +156,7 @@ async function main() {
153
156
  ...(opts.modePreamble ? { modePreamble: opts.modePreamble } : {}),
154
157
  addendum,
155
158
  ...(opts.markCommand ? { markCommand: opts.markCommand } : {}),
159
+ ...(execution ? { execution } : {}),
156
160
  });
157
161
 
158
162
  if (opts.json) {
@@ -160,10 +164,11 @@ async function main() {
160
164
  } else {
161
165
  process.stdout.write(`Task document: ${result.taskDocument}\nChecklist: ${result.checklist}\n`);
162
166
  }
167
+ return result;
163
168
  }
164
169
 
165
170
  if (process.argv[1] && pathToFileURL(process.argv[1]).href === import.meta.url) {
166
- main().catch((error) => {
171
+ taskInitFromArgv(process.argv.slice(2)).catch((error) => {
167
172
  console.error(error instanceof Error ? error.message : String(error));
168
173
  process.exit(1);
169
174
  });