agentflow
File-logged conversation protocol and on-demand development pipeline
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Check it deeper on your machine
Its scripts were only partly scanned.
As a Claude Code plugin, install it and then ask Claude Code:
/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/agfnow/agentflow-v8 with scanskillsafety
Or from a terminal, clone it and run it:
git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/agfnow/agentflow-v8'
It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.
Badge for your README
Markdown
[](/listings/agfnow--agentflow-v8)HTML
<a href="/listings/agfnow--agentflow-v8"><img src="/api/listings/agfnow--agentflow-v8/badge.svg" alt="findsafeskills safety rating" /></a>Install
Install instructions from the README
As written by the repo's author. findsafeskills has not verified these steps.
You need Node.js 18 or newer and a host with file and command tools. Codex and Claude provide verified hooks; a generic host uses an explicit safe ID, optional known family, and manual capture/closeout because hooks are not available. Git is needed for version history, feature workspaces, and some installation methods. Ordinary notebook work can use a folder that is not a Git repository.
Run this in a terminal and choose your assistant and installation scope:
npx skills add agfnow/agentflow-v8
For the Claude Code plugin route, add the marketplace in Claude Code:
/plugin marketplace add agfnow/agentflow-v8
Then install the `agentflow` plugin from that marketplace. Plugin updates follow your [Claude Code marketplace update settings](https://code.claude.com/docs/en/discover-plugins#configure-auto-updates). Start a new assistant session after installation or updates.
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
.claude-plugin/marketplace.json · Manifest · 13 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
- {
- "name": "agentflow",
- "owner": {
- "name": "agfnow"
- },
- "plugins": [
- {
- "name": "agentflow",
- "source": "./",
- "description": "A project notebook for Codex and Claude Code, with resumable work, optional planning, and independent review."
- }
- ]
- }
README.md · README · 115 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
- # Agentflow v8.4.15
- This repository preserves **Agentflow 8**. Stable Agentflow 9 uses [agfnow/agentflow](https://github.com/agfnow/agentflow). To keep v8, explicitly install from `agfnow/agentflow-v8`; rebind existing installations that still record the old repository URL before running updates. V8 and v9 share the `agentflow` skill/plugin name: use one active version per host/project.
- **English** · [繁體中文](README.zh-tw.md)
- Give your AI assistant a project notebook, so tomorrow’s conversation can pick up today’s work.
- Agentflow has verified integrations for **Codex and Claude Code** and a portable core for any host that provides file and command tools plus enough state retention for capture and closeout. It keeps your requests, decisions, progress, and results in a readable file. You can use it to improve a document, fix a bug, or carry a larger project across several sessions.
- - **Start simply:** Type `godev`, then describe the task in your own words.
- - **Find the result:** Open the notebook named in the assistant’s closing message, usually `.agentflow/devlog.md`.
- - **Get help quickly:** Ask your agent, “How do I use the Agentflow skill for this task?” It can explain the controls using your actual project.
- - **Discuss possible work first:** Say, “Could we replace the provider? Discuss with me first.” The assistant records the possible task and what decision it needs, discusses your options, then asks a specific question in the saved Reply. Answer in chat or its `ans:` field. Recording an idea does not authorize implementation; rejected or deferred ideas stay recorded, and already-authorized work continues.
- Automatic archiving reports when an older answer or request keeps history in the live notebook. The assistant must recover and verify complete saved answers before overriding that protection; unresolved items stay live.
- ## Install
- You need Node.js 18 or newer and a host with file and command tools. Codex and Claude provide verified hooks; a generic host uses an explicit safe ID, optional known family, and manual capture/closeout because hooks are not available. Git is needed for version history, feature workspaces, and some installation methods. Ordinary notebook work can use a folder that is not a Git repository.
- Run this in a terminal and choose your assistant and installation scope:
- ```sh
- npx skills add agfnow/agentflow-v8
- ```
- For the Claude Code plugin route, add the marketplace in Claude Code:
- ```text
- /plugin marketplace add agfnow/agentflow-v8
- ```
- Then install the `agentflow` plugin from that marketplace. Plugin updates follow your [Claude Code marketplace update settings](https://code.claude.com/docs/en/discover-plugins#configure-auto-updates). Start a new assistant session after installation or updates.
- ## Choose the main model
- For Codex, we recommend **`gpt-6.1-sol/medium` as the most stable coordinator choice in their use**: model `gpt-6.1-sol`, reasoning effort `medium`. The coordinator is the assistant you talk to; it organizes the task and checks the result. This recommendation does not change your model settings automatically. [Official model reference](https://developers.openai.com/api/docs/models/gpt-6.1-sol).
- ## Keep it updated
- If you installed through `npx skills add`, periodically run:
- ```sh
- npx skills update agentflow
- ```
- The [Skills CLI](https://github.com/vercel-labs/skills#skills-update) takes the installed skill name for updates. `agfnow/agentflow-v8` is the installation source, so `npx skills update agfnow/agentflow-v8` is not the current name-based update syntax. Add `-g` for global installs, or run from the project with `-p` for project installs.
- We recommend a weekly **crontab** job on macOS or Linux if you want automatic updates. Ask your agent to set it up for your installation. The [guide](skills/agentflow/docs/AG_GUIDE.md#keep-the-skill-up-to-date) includes a Monday-morning example, explicit paths, and logging.
- ## Try it
- Send this to your assistant:
- ```text
- godev
- Rewrite the welcome page for someone visiting for the first time.
- Keep the existing links. Let me review the result before uploading it.
- ```
- Small tasks can stay simple. `fast-lane` keeps one task with the main assistant and skips separate review while retaining necessary checks and self-review. `cross-check` requests a separate review of finished work; `review-policy: prefer-independent` permits a clearly labelled host review only after separate-review unavailability, while `require-independent` stays strict. `ag` requests the full development process when the project’s `allow-ag` setting permits it.
- `skip-ag [task]` or `/skip-ag [task]` skips the development pipeline and its advisors for the current Ask while keeping devlog records, necessary checks, normal independent review, ordinary delegation, and stream rules. It leaves project settings unchanged and expires when the Ask closes. A bare command waits for a task. Unquoted `no-ag [task]`, `no-ag: [task]` or `no-ag, [task]` skips the entire Agentflow protocol for that submitted message, including notebook capture and closeout. Quoted mentions and conditional statements do not activate it; the next ordinary message resumes the workflow; `fast-lane` also skips delegation, new streams, and independent review.
- The notebook keeps the conversation, so a fresh session can resume an unfinished request with `godev`. With Git, Agentflow normally commits completed work and pushes when a remote exists; tell it when you want local work only.
- ## Shared notebooks
- `notebook-ownership: on|off` is optional and defaults to `off`, including when omitted. On gives one session control of an active notebook round; off allows sessions to mix messages, decisions and replies. Both modes retain file locks, safe paths, current-round checks, unchanged snapshots and stream routing. Off preserves existing ownership records. Use `notebook-ownership: on` when a notebook may be shared. Turning it back on may require explicit recovery of a retained record; no noticeable startup speed gain has been proven.
- Codex records later owner messages automatically. Claude keeps startup capture and its completion-checking Stop hook, but the assistant must manually save later actual owner messages using the startup `session_id`; generated reports must not enter the Ask. Updating setup removes owned Claude prompt hooks in the selected scope. Older global installations need their own update and hook migration; restart when prompted.
- ## Check installation
- Ask your agent to run `agf setup`, or run it in a terminal if the shortcut is available. `agf setup --fix` can add missing shortcuts after backing up shell settings. An unavailable optional worker does not mean installation failed. Follow any restart notice after project hooks are installed.
- <details>
- <summary>If the agf shortcut is missing</summary>
- For a global installation at one of these locations, run the matching setup file. For another installation location, ask your agent to locate its installed skill first.
- ```sh
- node "$HOME/.codex/skills/agentflow/scripts/setup.js"
- ```
- ```sh
- node "$HOME/.claude/skills/agentflow/scripts/setup.js"
- ```
- </details>
- ## Windows and contributor tests
- - Installation does not require running the regression suite. Contributors can find the test commands in the [script reference](skills/agentflow/scripts/README.md).
- - Portable core tests are verified on native Windows with Node.js 24. Tests requiring Unix terminals or process controls are explicitly skipped. The background looper is not supported on native Windows.
- ## Read next
- - [Everyday user guide](skills/agentflow/docs/AG_GUIDE.md), with the YouTube introduction.
- - [繁體中文使用指南](skills/agentflow/docs/AG_GUIDE.zh-tw.md).
- - [Brief for a new assistant](skills/agentflow/docs/agent-brief.md), for orientation before using the installed skill.
- - [Changelog](CHANGELOG.md), newest version first.
- - [Script reference](skills/agentflow/scripts/README.md), for technical setup and recovery.
- Project settings live in `ag.json`, using the version-8 configuration format. Type `settings` to inspect them. Startup fills properties missing from the latest template and reports invalid saved values with suggestions; it asks before changing any wrong value. Unsafe invalid settings still stop startup. Existing v7 files migrate conservatively when opened. `allowed-worker` is an unordered permission list of external, internal, and host routes; its order has no execution meaning. `cli-provider` filters only external profiles. Model profiles live under `external-workers`, and advisor choices under `pipeline-roles`.
skills/agentflow/scripts/claude-live-journey.js · Bundled script · 161 lines · 2 findings marked
- #!/usr/bin/env node
- 'use strict';
- // Opt-in model-backed interactive test, retaining repositories and evidence.
- const fs = require('node:fs');
- const os = require('node:os');
- const path = require('node:path');
- const crypto = require('node:crypto');
- const assert = require('node:assert/strict');
- const { spawnSync } = require('node:child_process');
- const { parse_devlog } = require('./round-linter');
- const session_entries = session => {
- const projects = path.join(process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude'), 'projects');
- const files = fs.readdirSync(projects, { withFileTypes: true }).filter(e => e.isDirectory())
- .map(e => path.join(projects, e.name, `${session}.jsonl`)).filter(f => fs.existsSync(f));
- assert.equal(files.length, 1, 'one exact native Claude transcript');
- return fs.readFileSync(files[0], 'utf8').trim().split('\n').map(JSON.parse);
- };
- if (process.argv[2] === '--probe') {
- try {
- const [, , , repo, session, turns, rounds] = process.argv;
- const entries = session_entries(session);
- assert.ok(entries.filter(e => e.type === 'system' && e.subtype === 'turn_duration').length >= Number(turns));
- const text = fs.readFileSync(path.join(repo, '.agentflow/devlog.md'), 'utf8');
- assert.equal(parse_devlog(text).rounds.filter(r => r.reply_text.trim()).length, Number(rounds));
- } catch { process.exitCode = 1; }
- } else {
- assert.equal(process.argv[2], '--run', 'Use --run to authorize model-backed Claude PTY conversations. Optional: --codex-first.');
- const codex_first = process.argv.includes('--codex-first');
- const skill = path.resolve(__dirname, '..');
- const base = path.join(os.homedir(), 'jxtmp');
- fs.mkdirSync(base, { recursive: true });
- const repo = fs.realpathSync(fs.mkdtempSync(path.join(base, `agf-claude-${codex_first ? 'codex-first' : 'fresh'}-`)));
- const session = crypto.randomUUID();
- const env = { ...process.env, TERM: 'xterm-256color' };
- // A nested CLI must not inherit its parent's host/session identity.
- for (const name of Object.keys(env)) if (/^(?:CODEX_|CLAUDE(?:_CODE)?_SESSION_ID$|CLAUDE_PROJECT_DIR$|AGENTFLOW_SESSION_ID$|AGENTFLOW_EXTERNAL_DELEGATE$|CLAUDECODE$)/u.test(name)) delete env[name];
- const run = (command, args, input) => {
- const result = spawnSync(command, args, { cwd: repo, env, input, encoding: 'utf8', timeout: 30000 });
- assert.equal(result.status, 0, result.stderr || result.stdout);
- return result.stdout.trim();
- };
- run('git', ['init', '-q', '-b', 'main']);
- run('git', ['config', 'user.name', 'Agentflow Claude terminal test']);
- run('git', ['config', 'user.email', 'claude-pty@example.invalid']);
- fs.writeFileSync(path.join(repo, 'CLAUDE.md'), `# Disposable Claude terminal test\n\nThe active-agentflow-skill-dir is \`${skill}\`. Read its SKILL.md for godev. Work directly without delegation. No remote is configured.\n`);
- fs.writeFileSync(path.join(repo, 'wait-window.js'), "require('node:fs').writeFileSync('steering-ready', 'ready'); setTimeout(() => console.log('timer complete'), 15000);\n");
- fs.writeFileSync(path.join(repo, '.gitignore'), 'steering-ready\n');
- run('git', ['add', '.']);
- run('git', ['commit', '-qm', 'Initialize Claude terminal fixture']);
- if (codex_first) {
- const first = JSON.parse(run(process.execPath, [path.join(__dirname, 'agf.js'), 'start', '--repo', repo, '--host', 'codex', '--session', 'codex-bootstrap', '--message-stdin', '--json'], 'godev'));
- assert.equal(first.active_host, 'codex');
- assert.ok(fs.existsSync(path.join(repo, '.codex/hooks.json')));
- assert.equal(fs.existsSync(path.join(repo, '.claude')), false);
- }
- const transcript = `${repo}-terminal.log`;
- const program = String.raw`
- set timeout 300
- log_file -noappend $env(JOURNEY_LOG)
- proc submit {message} {
- global spawn_id env
- send -- "\033\[200~$message\033\[201~"
- after 500
- send -- "\r"
- }
- proc ready {turns rounds} {
- global spawn_id env
- set deadline [expr {[clock milliseconds]+300000}]
- while {1} {
- if {![catch {exec $env(JOURNEY_NODE) $env(JOURNEY_SCRIPT) --probe $env(JOURNEY_REPO) $env(JOURNEY_SESSION) $turns $rounds}]} { return }
- if {[clock milliseconds]>$deadline} { puts "JOURNEY timeout turns=$turns rounds=$rounds"; exit 81 }
- expect -timeout 1 eof { exit 82 } timeout {}
- }
- }
- proc launch {resume} {
- global spawn_id env
- if {$resume} {
- spawn claude --dangerously-skip-permissions --strict-mcp-config --resume $env(JOURNEY_SESSION)
- Note: Starts a coding agent with its permission prompts off
- Line 81 on GitHub
- } else {
- spawn claude --dangerously-skip-permissions --strict-mcp-config --session-id $env(JOURNEY_SESSION)
- Note: Starts a coding agent with its permission prompts off
- Line 83 on GitHub
- }
- stty rows 40 columns 140 < $spawn_out(slave,name)
- expect {
- -re {Yes,.*trust.*folder} { after 500; send -- "\033\[B\r"; exp_continue }
- -re {bypass.*permissions} {}
- timeout { exit 80 }
- }
- after 1000
- }
- launch 0
- submit "godev"
- ready 1 0
- puts "JOURNEY activation_ok=1"
- submit $env(JOURNEY_FIRST)
- set deadline [expr {[clock milliseconds]+180000}]
- while {![file exists $env(JOURNEY_REPO)/steering-ready]} {
- if {[clock milliseconds]>$deadline} { exit 83 }
- expect -timeout 1 eof { exit 84 } timeout {}
- }
- submit $env(JOURNEY_CORRECTION)
- ready 2 1
- puts "JOURNEY steering_close_ok=1"
- submit "/exit"
- expect eof
- set ended [wait]
- if {[lindex $ended 3] != 0} { exit 85 }
- launch 1
- submit "godev"
- ready 3 1
- puts "JOURNEY resume_ok=1"
- submit $env(JOURNEY_SECOND)
- ready 4 2
- puts "JOURNEY settings_close_ok=1"
- submit $env(JOURNEY_THIRD)
- ready 5 3
- puts "JOURNEY ownership_close_ok=1"
- submit "/exit"
- expect eof
- exit [lindex [wait] 3]
- `;
- const first = 'fast-lane Run node wait-window.js, then create greeting.txt containing green and one newline. Verify it, save the complete answer, and close with local delivery. Work directly.';
- const correction = 'Use blue instead of green. Answer this correction together with the original request.';
- const second = 'fast-lane Change inline-reply to on and log-verbosity to off using agf settings with --host claude. Change greeting.txt to violet and one newline. Verify the file and settings, then close locally with your own review.';
- const third = 'fast-lane Change notebook-ownership to on and inline-reply to off using agf settings with --host claude. Create ownership.txt containing enabled and one newline. Verify the result and close locally with your own review.';
- console.log(`Live Claude PTY: ${repo}; transcript: ${transcript}`);
- const result = spawnSync('/usr/bin/expect', ['-c', program], { cwd: repo, env: { ...env,
- JOURNEY_LOG: transcript, JOURNEY_NODE: process.execPath, JOURNEY_SCRIPT: __filename, JOURNEY_REPO: repo, JOURNEY_SESSION: session,
- JOURNEY_FIRST: first, JOURNEY_CORRECTION: correction, JOURNEY_SECOND: second, JOURNEY_THIRD: third,
- }, encoding: 'utf8', timeout: 1200000, maxBuffer: 32 * 1024 * 1024 });
- let checks = {}, diagnostic;
- try {
- const text = fs.readFileSync(path.join(repo, '.agentflow/devlog.md'), 'utf8');
- const rounds = parse_devlog(text).rounds.filter(r => r.reply_text.trim());
- const config = JSON.parse(fs.readFileSync(path.join(repo, 'ag.json'), 'utf8'));
- const entries = session_entries(session);
- const answers = entries.filter(e => e.type === 'assistant' && !e.isSidechain).flatMap(e => (e.message?.content || []).filter(b => b.type === 'text').map(b => b.text));
- checks = {
- terminal_exit: result.status === 0,
- claude_hooks: ['Stop', 'UserPromptSubmit'].every(event => JSON.parse(fs.readFileSync(path.join(repo, '.claude/settings.json'))).hooks[event].length === 1),
- codex_hooks_preserved: fs.existsSync(path.join(repo, '.codex/hooks.json')) === codex_first,
- three_completed_rounds: rounds.length === 3,
- original_and_correction: text.split(`+ ${first}`).length === 2 && text.split(`+ ${correction}`).length === 2 && rounds[0]?.ask_text.includes(correction),
- product: fs.readFileSync(path.join(repo, 'greeting.txt'), 'utf8') === 'violet\n' && fs.readFileSync(path.join(repo, 'ownership.txt'), 'utf8') === 'enabled\n',
- settings: config.switches['inline-reply'] === 'off' && config.switches['log-verbosity'] === 'off' && config.switches['notebook-ownership'] === 'on',
- no_suppressed_runs: rounds.slice(1).every(r => !/^## \[RUN-/mu.test(r.text) && !r.wip_text.trim()),
- verified_claude_stamps: rounds.every(r => /\(claude-[A-Za-z0-9._-]+\/[A-Za-z_-]+\)_/u.test(r.reply_text)),
- inline_saved_reply: answers.includes(rounds[1]?.reply_text.replace(/\r?\n---\s*$/u, '').trim()),
- receipt_only: answers.filter(t => t === '.agentflow/devlog.md updated').length >= 2,
- clean_checkout: run('git', ['status', '--porcelain']) === '',
- three_close_commits: run('git', ['log', '--format=%B']).split('Agentflow-Close-Id:').length === 4,
- hooks_without_errors: entries.filter(e => e.type === 'system' && e.subtype === 'stop_hook_summary').every(e => !(e.hookErrors || []).length),
- };
- } catch (error) { diagnostic = error.message; }
- const report = { repo, transcript, session, codex_first, process_status: result.status, checks, diagnostic, error: result.error?.message, milestones: (result.stdout || '').match(/JOURNEY [^\r\n]+/gu) || [] };
- fs.writeFileSync(`${repo}-result.json`, JSON.stringify(report, null, 2) + '\n');
- console.log(JSON.stringify(report, null, 2));
- if (diagnostic || Object.values(checks).some(v => !v) || !Object.keys(checks).length) process.exitCode = 1;
- }
skills/agentflow/scripts/looper-live-gate.js · Bundled script · 213 lines · 1 finding marked
- #!/usr/bin/env node
- 'use strict'
- const fs = require('node:fs')
- const os = require('node:os')
- const path = require('node:path')
- const { spawnSync } = require('node:child_process')
- const run = (command, args, options = {}) => spawnSync(command, args, {
- encoding: 'utf8',
- ...options,
- })
- const fail = message => {
- const error = new Error(message)
- error.name = 'LiveGateError'
- return error
- }
- const require_success = (result, label) => {
- if (result.error) throw fail(`${label} could not start: ${result.error.message}`)
- if (result.status !== 0) throw fail(`${label} exited ${result.status}: ${(result.stderr || result.stdout || '').trim()}`)
- return result
- }
- const git = (repo, args) => require_success(run('git', args, { cwd: repo }), `git ${args.join(' ')}`)
- const write = (file, text) => {
- fs.mkdirSync(path.dirname(file), { recursive: true })
- fs.writeFileSync(file, text, 'utf8')
- }
- const config = () => ({
- 'schema-version': 7,
- switches: {
- 'target-doc': '.agentflow/devlog.md',
- 'workspace-dir': '.agentflow',
- 'cli-provider': 'on',
- 'auto-reply': 'on',
- lang: 'English',
- streams: 'always',
- 'ask-names': 'off',
- 'allow-ag': 'off',
- 'large-work-minutes': 120,
- },
- 'pipeline-roles': {
- requirements: 'off', codewalk: 'off', explore: 'off', spike: 'off', spec: 'off',
- implementation: 'basic', 'security-scan': 'off', acceptance: 'off',
- 'cross-check': 'off', learn: 'off',
- },
- 'external-workers': [{
- id: 'codex-live-gate',
- command: ['codex', 'exec', '--dangerously-bypass-approvals-and-sandbox', '--ephemeral'],
- Note: Starts a coding agent with its permission prompts off
- Line 53 on GitHub
- priority: 1,
- family: 'codex',
- tiers: {
- best: process.env.AGENTFLOW_LOOPER_GATE_MODEL || 'gpt-5.4/medium',
- better: process.env.AGENTFLOW_LOOPER_GATE_MODEL || 'gpt-5.4/medium',
- basic: process.env.AGENTFLOW_LOOPER_GATE_MODEL || 'gpt-5.4/medium',
- cheap: process.env.AGENTFLOW_LOOPER_GATE_MODEL || 'gpt-5.4/medium',
- },
- }],
- })
- const initial_notebook = `# STATUS
- Project: Disposable looper live gate.
- Notebook: .agentflow/devlog.md — root.
- Current commit: initial fixture.
- Tests/scenarios: none yet.
- Configuration: ag.json — schema v7.
- Proven: none yet.
- Open: execute both plans.
- Next: run agf-looper.
- Artifacts: .agentflow/planned/.
- Archived eras: none.
- Streams: none.
- ---
- # → Ask / A-001
- +
- `
- const plan = (number, file, value) => `# Live gate plan ${number}
- This disposable fixture is already running under the parent looper, which owns validation and review. Edit its product and notebook directly with ordinary file and Git commands. Do not load skills, run agf.js or looper.js, invoke any model CLI, or launch a reviewer; these are prohibited nested workers in this fixture.
- Create \`${file}\` in the repository root with exactly \`${value}\` and one trailing newline.
- Use the active Agentflow notebook \`.agentflow/devlog.md\`. Record and finish this work as its own round. The completed round must contain the exact \`# ← Reply / A-NNN\` heading for its Ask and must end with the next sequential scaffold in exactly this form, including the bare plus line: \`# → Ask / A-NNN\n\n+\`. Before returning, read the notebook and verify the Reply heading and the full next-Ask scaffold. Commit the product and notebook changes. Do not move or edit any file under \`.agentflow/planned/\`; the parent looper owns the queue.
- `
- const inspect_notebook_rounds = text => {
- const reply_ids = [...text.matchAll(/^# ← Reply \/ A-([0-9]+)$/gmu)].map(match => Number(match[1]))
- const next_ask_id = Number((text.match(/(?:^|\n)# → Ask \/ A-([0-9]+)\n\n\+\n?$/u) || [])[1] || 0)
- return { reply_ids, next_ask_id, complete: reply_ids.includes(1) && reply_ids.includes(2) && next_ask_id === 3 }
- }
- const verify_gate = ({ repo, process_status }) => {
- const read_or_null = file => {
- try { return fs.readFileSync(file, 'utf8') } catch { return null }
- }
- const notebook = read_or_null(path.join(repo, '.agentflow', 'devlog.md')) || ''
- const rounds = inspect_notebook_rounds(notebook)
- const checks = {
- process_exit: process_status === 0,
- product_one: read_or_null(path.join(repo, 'product-one.txt')) === '1111\n',
- product_two: read_or_null(path.join(repo, 'product-two.txt')) === '2222\n',
- notebook_round_one: rounds.reply_ids.includes(1),
- notebook_round_two: rounds.complete,
- archived_plan_one: fs.existsSync(path.join(repo, '.agentflow', 'planned', 'done', 'plan-001.md')),
- archived_plan_two: fs.existsSync(path.join(repo, '.agentflow', 'planned', 'done', 'plan-002.md')),
- }
- const failures = Object.entries(checks).filter(([, passed]) => !passed).map(([name]) => name)
- return { passed: failures.length === 0, checks, failures }
- }
- const install_shortcut = ({ home, skill_dir }) => {
- const installed = path.join(home, '.codex', 'skills', 'agentflow')
- fs.mkdirSync(path.dirname(installed), { recursive: true })
- fs.symlinkSync(skill_dir, installed, 'dir')
- const setup = path.join(skill_dir, 'scripts', 'setup.js')
- require_success(run(process.execPath, [setup, '--fix'], {
- env: { ...process.env, HOME: home, SHELL: '/bin/zsh', AGF_OPEN: 'true' },
- input: 'y\n',
- }), 'real shell shortcut installation')
- const shell_file = path.join(home, '.zshrc')
- const installed_text = fs.readFileSync(shell_file, 'utf8')
- if (!/agf-looper\s*\(\s*\)/u.test(installed_text)) throw fail('setup succeeded without installing agf-looper()')
- return shell_file
- }
- const execute_gate = (options = {}) => {
- const skill_dir = path.resolve(options.skill_dir || path.join(__dirname, '..'))
- const codex_home = process.env.CODEX_HOME || path.join(os.homedir(), '.codex')
- const scratch = path.join(os.homedir(), 'tmp')
- fs.mkdirSync(scratch, { recursive: true })
- if (fs.lstatSync(scratch).isSymbolicLink()) throw fail('home scratch directory must not be a symlink')
- const temporary_root = fs.mkdtempSync(path.join(os.tmpdir(), 'agentflow-looper-live-gate-'))
- const state_root = fs.mkdtempSync(path.join(scratch, '.agentflow-looper-live-gate-state-'))
- const home = path.join(temporary_root, 'home')
- const repo = path.join(temporary_root, 'repo')
- fs.mkdirSync(home, { recursive: true })
- fs.mkdirSync(repo, { recursive: true })
- try {
- git(repo, ['init', '-q'])
- git(repo, ['config', 'user.name', 'Agentflow live gate'])
- git(repo, ['config', 'user.email', 'agentflow-live-gate@example.invalid'])
- write(path.join(repo, 'ag.json'), `${JSON.stringify(config(), null, 2)}\n`)
- write(path.join(repo, '.agentflow', 'devlog.md'), initial_notebook)
- write(path.join(repo, '.agentflow', 'planned', 'plan-001.md'), plan(1, 'product-one.txt', '1111'))
- write(path.join(repo, '.agentflow', 'planned', 'plan-002.md'), plan(2, 'product-two.txt', '2222'))
- write(path.join(repo, '.gitignore'), '.agentflow-looper-state/\n.codex/\n.claude/\n')
- git(repo, ['add', 'ag.json', '.agentflow', '.gitignore'])
- git(repo, ['commit', '-qm', 'Initialize looper live gate'])
- const shell_file = install_shortcut({ home, skill_dir })
- const result = run('/bin/zsh', ['-c', `source "$1" && agf-looper`, 'looper-live-gate', shell_file], {
- cwd: repo,
- env: { ...process.env, HOME: home, CODEX_HOME: codex_home, SHELL: '/bin/zsh', XDG_STATE_HOME: state_root },
- timeout: options.timeout_ms || 20 * 60 * 1000,
- maxBuffer: 1024 * 1024,
- })
- const verdict = verify_gate({ repo, process_status: result.status })
- const report = {
- schema_version: 1,
- gate: 'agentflow-looper-real-two-plan-v1',
- passed: verdict.passed,
- checks: verdict.checks,
- process_status: result.status,
- repository: options.keep ? repo : 'removed after verification',
- }
- if (options.report) write(path.resolve(options.report), `${JSON.stringify(report, null, 2)}\n`)
- if (!verdict.passed) throw fail(`live gate failed: ${verdict.failures.join(', ')}\n${(result.stderr || result.stdout || '').trim()}`)
- return report
- } finally {
- if (!options.keep) fs.rmSync(temporary_root, { recursive: true, force: true })
- if (!options.keep) fs.rmSync(state_root, { recursive: true, force: true })
- }
- }
- const parse_cli = argv => {
- const options = {}
- for (let index = 0; index < argv.length; index += 1) {
- if (argv[index] === '--keep') options.keep = true
- else if (argv[index] === '--report' && argv[index + 1]) options.report = argv[++index]
- else throw fail(`unknown or incomplete option: ${argv[index]}`)
- }
- return options
- }
- if (require.main === module) {
- try {
- const report = execute_gate(parse_cli(process.argv.slice(2)))
- process.stdout.write(`${JSON.stringify(report, null, 2)}\n`)
- } catch (error) {
- process.stderr.write(`HALT: ${error.message}\n`)
- process.exitCode = 1
- }
- }
- module.exports = { inspect_notebook_rounds, verify_gate }
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.