Skip to content

Commit 9947ca1

Browse files
authored
feat: update flake and add setup command (#40)
## Summary - add `agent-task setup` subcommand - package `get-task` and `start-work` as `agent-utils` - include codex and goose in the `agent-task` PATH through the flake - document the new flake packages and setup command - test the setup command https://chatgpt.com/codex/tasks/task_e_6844fd1834188329a1e619dcda1c3f79
1 parent 56be136 commit 9947ca1

File tree

7 files changed

+96
-5
lines changed

7 files changed

+96
-5
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ The primary goal of this workflow is to:
6969
- `--prompt-file=FILE`read the task description from `FILE`.
7070
- `--devshell=NAME` (`-s`) – record the given Nix dev shell in the initial commit message.
7171

72+
The command also provides a `setup` subcommand that prints the versions of `codex` and `goose` available in the current `PATH`.
73+
7274
2. **Retrieving a Task (Coding Agent):**
7375

7476
Once the developer has set up the task, they instruct the agent to
@@ -152,12 +154,28 @@ This will provide the `agent-task`, `get-task`, and `download-internet-resources
152154
153155
To enable bash completion for `agent-task`, source the script `scripts/agent-task-completion.bash` in your shell profile.
154156
157+
### Installing with Nix
158+
159+
This repository also provides a Nix flake. The default package installs the `agent-task` binary with `codex` and `goose` available in its `PATH`. An additional `agent-utils` package bundles the `get-task` and `start-work` binaries.
160+
161+
```bash
162+
nix run github:metacraft-labs/agents-workflow
163+
```
164+
165+
Or install the utilities package:
166+
167+
```bash
168+
nix profile install github:metacraft-labs/agents-workflow#agent-utils
169+
```
170+
155171
### What's included?
156172

157173
The core components include:
158174
- `codex-setup`: A script to initialize the workspace, download necessary internet resources, and run project-specific setup.
159175
- `agent-task`: A script for developers to begin a new task, automatically creating a dedicated branch and storing the task description.
176+
- `agent-task setup`: Prints the versions of `codex` and `goose` available in `PATH`.
160177
- `get-task`: A script for the coding agent to retrieve its current task instructions.
178+
- `start-work`: A helper that configures a freshly checked-out repository for development.
161179
- `download-internet-resources`: A helper script that scans task descriptions for URLs and downloads them (or clones Git repositories) for offline access.
162180

163181
## Future Direction

bin/agent-task

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22
# frozen_string_literal: true
33

44
require_relative '../lib/agent_task/cli'
5-
AgentTask::CLI.start_task(ARGV)
5+
6+
if ARGV.first == 'setup'
7+
ARGV.shift
8+
AgentTask::CLI.run_setup(ARGV)
9+
else
10+
AgentTask::CLI.start_task(ARGV)
11+
end

flake.nix

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,23 @@
1313
packages = forAllSystems (
1414
system: let
1515
pkgs = import nixpkgs {inherit system;};
16-
in {
17-
agent-task = pkgs.writeShellScriptBin "agent-task" ''
18-
exec ${pkgs.ruby}/bin/ruby ${./bin/agent-task} "$@"
16+
agent-task-script = pkgs.writeShellScriptBin "agent-task" ''
17+
PATH=${pkgs.lib.makeBinPath [ pkgs.ruby pkgs.codex pkgs.goose ]}:$PATH
18+
exec ruby ${./bin/agent-task} "$@"
19+
'';
20+
get-task = pkgs.writeShellScriptBin "get-task" ''
21+
exec ${pkgs.ruby}/bin/ruby ${./bin/get-task} "$@"
1922
'';
23+
start-work = pkgs.writeShellScriptBin "start-work" ''
24+
exec ${pkgs.ruby}/bin/ruby ${./bin/start-work} "$@"
25+
'';
26+
agent-utils = pkgs.symlinkJoin {
27+
name = "agent-utils";
28+
paths = [ get-task start-work ];
29+
};
30+
in {
31+
agent-task = agent-task-script;
32+
agent-utils = agent-utils;
2033
}
2134
);
2235

lib/agent_task/cli.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,5 +335,21 @@ def run_start_work(_args = [])
335335
puts e.message
336336
exit 1
337337
end
338+
339+
def run_setup(_args = [])
340+
require 'English'
341+
342+
codex_version = `codex --version 2>&1`
343+
codex_version = $CHILD_STATUS.success? ? codex_version.strip : 'not found'
344+
345+
goose_version = `goose --version 2>&1`
346+
goose_version = $CHILD_STATUS.success? ? goose_version.strip : 'not found'
347+
348+
puts "codex: #{codex_version}"
349+
puts "goose: #{goose_version}"
350+
rescue StandardError => e
351+
puts e.message
352+
exit 1
353+
end
338354
end
339355
end

scripts/gem_agent_task.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@
33

44
require 'agent_task'
55

6-
AgentTask::CLI.start_task(ARGV)
6+
if ARGV.first == 'setup'
7+
ARGV.shift
8+
AgentTask::CLI.run_setup(ARGV)
9+
else
10+
AgentTask::CLI.start_task(ARGV)
11+
end

test/test_helper.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,15 @@ def run_start_work(working_dir, tool: START_WORK)
198198
end
199199
[status, output]
200200
end
201+
202+
def run_agent_task_setup(working_dir, tool: AGENT_TASK)
203+
output = nil
204+
status = nil
205+
Dir.chdir(working_dir) do
206+
cmd = windows? ? ['ruby', tool, 'setup'] : [tool, 'setup']
207+
output = IO.popen(GEM_ENV, cmd, &:read)
208+
status = $CHILD_STATUS
209+
end
210+
[status, output]
211+
end
201212
end

test/test_setup_command.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
require 'minitest/autorun'
4+
require 'tmpdir'
5+
require_relative 'test_helper'
6+
7+
class SetupCommandTest < Minitest::Test
8+
include RepoTestHelper
9+
10+
def test_setup_prints_versions
11+
RepoTestHelper::ALL_AGENT_TASK_BINARIES.each do |bin|
12+
Dir.mktmpdir('work') do |dir|
13+
status, output = run_agent_task_setup(dir, tool: bin)
14+
# setup command should succeed
15+
assert_equal 0, status.exitstatus
16+
# output should mention codex and goose versions
17+
assert_match(/codex:/, output)
18+
assert_match(/goose:/, output)
19+
end
20+
end
21+
end
22+
end

0 commit comments

Comments
 (0)