@agimon-ai/po-workflow 0.0.0-alpha.55 → 0.0.0-alpha.57

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/README.md CHANGED
@@ -49,6 +49,101 @@ needs, and `run` and `interactiveRun` steps each get their own RMUX pane. Each r
49
49
  log in `engine.log` in its run directory. See `docs/automation.md` for the full contract and the
50
50
  CLI fallback.
51
51
 
52
+ ## Job-specific tools
53
+
54
+ Managed Po agent steps can receive a workflow-owned `jobTools` code-mode namespace and a pinned
55
+ `workflow-job-tools` skill. Select a folder at workflow level as a default, or override it per job:
56
+
57
+ ```yaml
58
+ name: summarize
59
+ runConfig:
60
+ majorMode: copilot
61
+ tools: ./tools/shared
62
+ jobs:
63
+ report:
64
+ tools: ./tools/report
65
+ steps:
66
+ - name: Summarize
67
+ customRun: Read workflow-job-tools, discover jobTools, then summarize this job.
68
+ ```
69
+
70
+ The folder must contain JavaScript `index.mjs` and a non-empty `SKILL.md`. Paths are resolved relative
71
+ to the YAML that declares them, before imports and job-template inheritance. Empty paths, control
72
+ characters and URL specifiers are rejected. Parsing, listing and inspection never execute the module.
73
+ A job's main steps, `preJob` and `postJob` use its selection or the workflow default. `repair.tools`
74
+ overrides the default for repair triage. Global phases use the workflow default.
75
+
76
+ Only trusted, managed Po `customRun` and in-process `interactiveRun` agent sessions receive these
77
+ tools, not shell steps, ordinary sessions, or external Claude/Codex CLI runners. Each session uses its
78
+ captured workflow config. Global `pre` can run before the worktree YAML is reparsed, so its tools are
79
+ not necessarily selected from that worktree. Step `cwd`, `WORKTREE_PATH` and environment variables do
80
+ not select or resolve the tools folder.
81
+
82
+ `index.mjs` default-exports a factory, called once per managed session with:
83
+
84
+ - `sessionId` and the admitted working directory `cwd`.
85
+ - `workflow`: the trusted `PoWorkflowContextService`, including the captured config, job/step identity,
86
+ admitted `jobEnvironment` and `stepEnvironment`, and workflow state reader.
87
+ - Injected `fs` and `shell` capabilities.
88
+ - `signal`: the session tools lifetime, aborted on session disposal or mounting failure.
89
+
90
+ Return the existing `PoCodemodeNamespace` contract: name `jobTools`, a non-empty one-line `summary`
91
+ (maximum 600 characters), TypeScript `declarations` for discovery, and `bind(run)`. Bind returns flat
92
+ named async methods with JSON arguments and results. Each exec gets a fresh binding; keep per-session
93
+ state inside the factory, not at module scope. Validate method inputs and honour `run.signal` in long
94
+ operations. Use `run.onDispose` for exec-owned cleanup. The host refuses foreign sessions and calls
95
+ after cancellation/disposal, and detaches JSON values in both directions. Return `null`, not
96
+ `undefined`, for no output.
97
+
98
+ A minimal runnable `tools/report/index.mjs`:
99
+
100
+ ```js
101
+ export default function createJobTools({ sessionId, workflow, signal }) {
102
+ signal.throwIfAborted();
103
+ return {
104
+ name: 'jobTools',
105
+ summary: 'Describe the current workflow job with a supplied label.',
106
+ declarations: `declare const jobTools: {
107
+ describe(input: { label: string }): Promise<{ job: string; label: string }>;
108
+ };`,
109
+ bind(run) {
110
+ if (run.sessionId !== sessionId) throw new Error('Wrong session.');
111
+ return {
112
+ async describe(input) {
113
+ run.signal.throwIfAborted();
114
+ if (!input || typeof input.label !== 'string' || !input.label.trim())
115
+ throw new Error('label must be a non-empty string.');
116
+ return { job: workflow.job, label: input.label.trim() };
117
+ },
118
+ };
119
+ },
120
+ };
121
+ }
122
+ ```
123
+
124
+ Corresponding `tools/report/SKILL.md`:
125
+
126
+ ```md
127
+ # Report tools
128
+
129
+ Use jobTools.describe to label the current job before writing its summary.
130
+ Discover jobTools for the current signature, then call it through exec.
131
+ Do not guess a label or repeat an effect after cancellation without checking its outcome.
132
+ ```
133
+
134
+ Agents read the pinned skill, call `discover({ namespace: 'jobTools' })`, then use
135
+ `exec` with `return await jobTools.describe({ label: 'Verification' });`. Keep guidance in `SKILL.md`
136
+ and signatures in `declarations`. Optional namespace `approval` policies are preserved and enforced
137
+ by the existing code-mode approval path; each policy must name a returned method. An approval request
138
+ is not permission to bypass the normal approval flow.
139
+
140
+ Tools are trusted workflow code running with the host's privileges, not sandboxed code. Review the
141
+ folder before launching. Native import caches modules by file URL; editing `index.mjs` at the same
142
+ path requires a host restart. There is no direct TypeScript loading, hot reload, or external CLI
143
+ bridge. A missing file or invalid factory fails the managed step session rather than silently
144
+ omitting its selected tools. The namespace and skill mount and dispose together; disposing them does
145
+ not stop the owning workflow or change its recovery rules.
146
+
52
147
  ## Launch and monitor
53
148
 
54
149
  Core tools are:
@@ -98,8 +193,9 @@ adopts the eligible failure, validates the evidence, and transfers ownership to
98
193
  Live controls remain scoped to the owning session. Recovery does not launch a second copy beside a
99
194
  still-running job and does not guarantee that parent-session work survives shutdown.
100
195
 
101
- The package ships two skills: pinned, ungated `codemode-how-to-workflow` for both namespaces,
102
- and unpinned, Help-gated `help-how-to-workflow` for authoring and maintenance.
196
+ The package ships two skills: pinned, ungated `codemode-how-to-workflow` for workflow code-mode
197
+ namespaces and selected job tools, and unpinned, Help-gated `help-how-to-workflow` for authoring and
198
+ maintenance. A selected tools folder also supplies the managed session's pinned `workflow-job-tools` skill.
103
199
 
104
200
  ## Workflow sessions
105
201