@amsterdamdatalabs/adl-agent-control-linux-x64 0.1.34 → 0.1.37

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 (104) hide show
  1. package/bin/adl +2 -2
  2. package/bin/reconcile +4 -3
  3. package/package.json +1 -1
  4. package/packages/agent-hooks/README.md +14 -0
  5. package/packages/agent-hooks/assets/opencode-plugin.template.ts +140 -104
  6. package/packages/agent-hooks/deploy-profile.json +1 -1
  7. package/packages/agent-hooks/src/deploy/opencode-template.ts +5 -18
  8. package/packages/agent-hooks/src/deploy/render.ts +12 -3
  9. package/packages/agent-hooks/src/pre-tool-use/handler.ts +2 -2
  10. package/packages/agent-hooks/src/rules/impl/adl-build-run-role.ts +116 -0
  11. package/packages/agent-hooks/src/rules/impl/adl-git-user-override-block.ts +159 -0
  12. package/packages/agent-hooks/src/rules/impl/adl-mcp-cli.ts +12 -6
  13. package/packages/agent-hooks/src/rules/impl/adl-pr-complete-pending.ts +9 -9
  14. package/packages/agent-hooks/src/rules/impl/adl-pr-role.ts +6 -5
  15. package/packages/agent-hooks/src/rules/impl/agent-tamper-protection.ts +15 -14
  16. package/packages/agent-hooks/src/rules/impl/git-core.ts +4 -8
  17. package/packages/agent-hooks/src/rules/impl/mcp-tool.ts +1 -1
  18. package/packages/agent-hooks/src/rules/impl/tool-native-search.ts +8 -7
  19. package/packages/agent-hooks/src/rules/registry.ts +11 -2
  20. package/packages/agent-hooks/src/rules/shell/protected-carriers.ts +9 -5
  21. package/packages/agent-settings/README.md +10 -4
  22. package/packages/agent-settings/assets/TARUN-GLOBAL-AGENTS-INSTRUCTIONS.md +40 -0
  23. package/packages/agent-settings/src/global-agents.ts +43 -8
  24. package/packages/agent-skills/assets/adl-mechanics/SKILL.md +38 -0
  25. package/packages/agent-skills/assets/agent-search-tool-audit/scripts/audit.sh +1 -1
  26. package/packages/agent-skills/assets/code-review/SKILL.md +84 -66
  27. package/packages/agent-skills/assets/diagnosing-bugs/SKILL.md +23 -2
  28. package/packages/agent-skills/assets/diagnosing-bugs/references/FEEDBACK-LOOP-TACTICS.md +1 -1
  29. package/packages/agent-skills/assets/explore-codebase/SKILL.md +3 -2
  30. package/packages/agent-skills/assets/finalize-feature/SKILL.md +63 -0
  31. package/packages/agent-skills/assets/fix-ci/SKILL.md +58 -0
  32. package/packages/agent-skills/assets/handoff/SKILL.md +1 -1
  33. package/packages/agent-skills/assets/implement-feature/SKILL.md +153 -0
  34. package/packages/agent-skills/assets/implement-feature/references/briefs.md +94 -0
  35. package/packages/agent-skills/assets/implement-item/SKILL.md +71 -0
  36. package/packages/agent-skills/assets/mechanics/SKILL.md +38 -0
  37. package/packages/agent-skills/assets/plan-feature/SKILL.md +141 -0
  38. package/packages/agent-skills/assets/prepare-promotion/SKILL.md +91 -0
  39. package/packages/agent-skills/assets/ralplan/SKILL.md +149 -0
  40. package/packages/agent-skills/assets/refactor-safely/SKILL.md +4 -3
  41. package/packages/agent-skills/assets/report-bug/SKILL.md +72 -0
  42. package/packages/agent-skills/assets/review-change/SKILL.md +82 -0
  43. package/packages/agent-skills/assets/review-plan/SKILL.md +124 -0
  44. package/packages/agent-skills/assets/to-feature/SKILL.md +1 -1
  45. package/packages/agent-skills/assets/to-workitems/SKILL.md +1 -1
  46. package/packages/agent-skills/assets/to-workitems/references/AZURE-DEVOPS-HIERARCHY.md +3 -0
  47. package/packages/agent-skills/assets/triage-workitems/SKILL.md +99 -0
  48. package/packages/agent-skills/assets/ultragoal/SKILL.md +77 -0
  49. package/packages/agent-skills/assets/validate-design/SKILL.md +70 -0
  50. package/packages/agent-skills/assets/verify-item/SKILL.md +71 -0
  51. package/packages/agent-skills/assets/workitems-process/SKILL.md +147 -0
  52. package/packages/agent-skills/assets/workitems-process/references/ado-and-git.md +194 -0
  53. package/packages/agent-skills/assets/workitems-process/references/evidence.md +74 -0
  54. package/packages/agent-skills/assets/workitems-process/references/workitem-states.md +92 -0
  55. package/packages/agent-skills/assets/write-feature/SKILL.md +95 -0
  56. package/packages/agent-skills/dist/deploy.d.ts +7 -0
  57. package/packages/agent-skills/dist/deploy.d.ts.map +1 -1
  58. package/packages/agent-skills/dist/deploy.js +52 -5
  59. package/packages/agent-skills/dist/deploy.js.map +1 -1
  60. package/packages/agent-skills/src/deploy.ts +48 -4
  61. package/packages/azdo/scripts/probe-ado-rules.ts +1 -1
  62. package/packages/azdo/src/activity-log.ts +118 -0
  63. package/packages/azdo/src/azdo-attachments.ts +108 -0
  64. package/packages/azdo/src/azdo-pl.ts +100 -3
  65. package/packages/azdo/src/azdo-pr.ts +194 -11
  66. package/packages/azdo/src/azdo-wit.ts +329 -18
  67. package/packages/azdo/src/cli.ts +42 -2
  68. package/packages/azdo/src/lib/agent-identity.ts +1 -1
  69. package/packages/azdo/src/lib/client.ts +7 -1
  70. package/packages/azdo/src/lib/validate-pr-metadata.ts +14 -5
  71. package/packages/azdo/src/mcp-server.ts +53 -5
  72. package/packages/azdo/src/tool-dispatch.ts +53 -4
  73. package/packages/azdo/src/workflow-ladder.csv +125 -107
  74. package/packages/azdo/src/workflow-rules.ts +254 -97
  75. package/packages/repo-controls/README.md +24 -11
  76. package/packages/repo-controls/assets/scaffold/docs/AGENTS.md +5 -5
  77. package/packages/repo-controls/assets/scaffold/plans/AGENTS.md +42 -13
  78. package/packages/repo-controls/assets/scaffold/root/AGENTS.md +60 -11
  79. package/packages/repo-controls/assets/scaffold/root/CONTRIBUTING.md +28 -0
  80. package/packages/repo-controls/assets/scaffold/root/INVARIANTS.md +17 -0
  81. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/docs/closed_set/test_check.py +0 -11
  82. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/docs/filename/test_check.py +4 -6
  83. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/docs/ledger/test_check.py +15 -0
  84. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/docs/okf_profile/docs-okf-profiles.yaml +1 -17
  85. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/docs/okf_profile/test_check.py +3 -22
  86. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/layout/open_work_cap/check.py +39 -182
  87. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/layout/open_work_cap/fixtures/open-work-cap-clean/plans/features/az601-clean/intent.md +17 -0
  88. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/layout/open_work_cap/test_check.py +90 -321
  89. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/layout/plan_metadata.py +31 -5
  90. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/layout/plans_layout/check.py +282 -54
  91. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/layout/plans_layout/fixtures/plans-layout-clean/plans/features/az347-test-coverage/design.md +35 -0
  92. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/layout/plans_layout/fixtures/plans-layout-clean/plans/features/az347-test-coverage/file-map-reference.md +19 -0
  93. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/layout/plans_layout/fixtures/plans-layout-clean/plans/features/az347-test-coverage/intent.md +25 -0
  94. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/layout/plans_layout/fixtures/plans-layout-clean/plans/features/az347-test-coverage/items/az351-restore-entrypoint.md +25 -0
  95. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/layout/plans_layout/fixtures/plans-layout-clean/plans/features/az347-test-coverage/requirements.md +44 -0
  96. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/layout/plans_layout/fixtures/plans-layout-violation/plans/features/az347-test-coverage/requirements.md +44 -0
  97. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/checks/layout/plans_layout/test_check.py +646 -53
  98. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/cli.py +3 -3
  99. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/policy/docs_shape.py +1 -12
  100. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/policy/gate-registry.alt.yaml +1 -1
  101. package/packages/repo-controls/package/adl-compliance/src/adl_compliance/policy/gate-registry.yaml +1 -1
  102. package/packages/repo-controls/src/cli.ts +23 -5
  103. package/packages/repo-controls/src/constants.ts +2 -15
  104. package/packages/repo-controls/src/install.ts +15 -6
@@ -1,16 +1,16 @@
1
1
  /**
2
- * Deploy the canonical `packages/agent-settings/assets/GLOBAL-AGENTS.md` out
2
+ * Deploy the canonical `packages/agent-settings/assets/TARUN-GLOBAL-AGENTS-INSTRUCTIONS.md` out
3
3
  * to every AI-agent host's own global instruction file, so each host reads
4
4
  * the same content: `~/.claude/CLAUDE.md`, `~/.codex/AGENTS.md`,
5
5
  * `~/.cursor/AGENTS.md`, `~/.kimi-code/AGENTS.md`,
6
6
  * `~/.config/opencode/AGENTS.md`.
7
7
  *
8
- * The canonical source is committed in this repo (`../assets/GLOBAL-AGENTS.md`
8
+ * The canonical source is committed in this repo (`../assets/TARUN-GLOBAL-AGENTS-INSTRUCTIONS.md`
9
9
  * relative to this file), not read from any other repo's checkout at
10
10
  * runtime — two different repos fighting over the same global target file is
11
11
  * exactly the collision this replaces.
12
12
  *
13
- * Ownership model: GLOBAL-AGENTS.md is the single source of truth for every
13
+ * Ownership model: TARUN-GLOBAL-AGENTS-INSTRUCTIONS.md is the single source of truth for every
14
14
  * target. Deploy is always forced — there is no opt-out flag:
15
15
  * - missing target -> created from the source.
16
16
  * - content === source -> untouched (true no-op).
@@ -18,7 +18,7 @@
18
18
  * stale, both are drift). These exact files are
19
19
  * authoritative adl roots: replacement does
20
20
  * not retain a displaced copy.
21
- * Any change to a host's global instructions must go through GLOBAL-AGENTS.md.
21
+ * Any change to a host's global instructions must go through TARUN-GLOBAL-AGENTS-INSTRUCTIONS.md.
22
22
  * Uninstall removes those same owned files regardless of their current bytes.
23
23
  */
24
24
 
@@ -31,6 +31,7 @@ import {
31
31
  rmSync,
32
32
  writeFileSync,
33
33
  } from 'node:fs'
34
+ import { hostname as osHostname } from 'node:os'
34
35
  import { dirname, isAbsolute, join, resolve } from 'node:path'
35
36
  import { fileURLToPath } from 'node:url'
36
37
 
@@ -47,7 +48,29 @@ export const AGENT_TARGETS: readonly AgentTarget[] = [
47
48
  { relativeDir: '.config/opencode', file: 'AGENTS.md' },
48
49
  ]
49
50
 
50
- export const DEFAULT_SOURCE_PATH = fileURLToPath(new URL('../assets/GLOBAL-AGENTS.md', import.meta.url))
51
+ export const DEFAULT_SOURCE_PATH = fileURLToPath(new URL('../assets/TARUN-GLOBAL-AGENTS-INSTRUCTIONS.md', import.meta.url))
52
+
53
+ export const DEFAULT_MANIFEST_PATH = fileURLToPath(new URL('../../fleet/manifest.json', import.meta.url))
54
+
55
+ export type FleetScope = { readonly inFleet: true; readonly device: string } | { readonly inFleet: false; readonly note: string }
56
+
57
+ export function deviceNameOf(hostname: string): string {
58
+ return hostname.split('.')[0] ?? hostname
59
+ }
60
+
61
+ // Fleet-only deploy rule and its rationale: README "Global agent instructions".
62
+ export function resolveFleetScope(hostname: string, manifestPath: string): FleetScope {
63
+ let manifest: { mac?: { devices?: object }; linux?: { devices?: object } }
64
+ try {
65
+ manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))
66
+ } catch (cause) {
67
+ throw new Error(`cannot read fleet manifest ${manifestPath}: ${messageOf(cause)}`)
68
+ }
69
+ const device = deviceNameOf(hostname)
70
+ const names = [...Object.keys(manifest.mac?.devices ?? {}), ...Object.keys(manifest.linux?.devices ?? {})]
71
+ if (names.includes(device)) return { inFleet: true, device }
72
+ return { inFleet: false, note: `skipped: '${device}' is not a device in packages/fleet/manifest.json, so no global file is written` }
73
+ }
51
74
 
52
75
  export type TargetState = 'missing' | 'matches' | 'drifted'
53
76
 
@@ -181,23 +204,35 @@ function readSource(sourcePath: string): string {
181
204
  }
182
205
 
183
206
  function usage(): never {
184
- throw new Error('usage: global-agents --home ABSOLUTE_PATH --mode deploy|status|uninstall')
207
+ throw new Error('usage: global-agents --home ABSOLUTE_PATH --mode deploy|status|uninstall [--host NAME] [--manifest PATH]')
185
208
  }
186
209
 
187
- export function main(argv: readonly string[]): void {
210
+ export function main(argv: readonly string[], hostname: string = osHostname()): void {
188
211
  let home = ''
189
212
  let mode = 'status'
213
+ let host = hostname
214
+ let manifest = DEFAULT_MANIFEST_PATH
190
215
 
191
216
  for (let index = 0; index < argv.length; index += 1) {
192
217
  const argument = argv[index]
193
218
  if (argument === '--home') home = argv[++index] ?? ''
194
219
  else if (argument === '--mode') mode = argv[++index] ?? ''
220
+ else if (argument === '--host') host = argv[++index] ?? ''
221
+ else if (argument === '--manifest') manifest = argv[++index] ?? ''
195
222
  else usage()
196
223
  }
197
- if (home.length === 0 || !['deploy', 'status', 'uninstall'].includes(mode)) usage()
224
+ if (home.length === 0 || host.length === 0 || manifest.length === 0 || !['deploy', 'status', 'uninstall'].includes(mode)) usage()
198
225
 
199
226
  const sourceContent = readSource(DEFAULT_SOURCE_PATH)
200
227
 
228
+ if (mode !== 'uninstall') {
229
+ const scope = resolveFleetScope(host, manifest)
230
+ if (!scope.inFleet) {
231
+ console.log(`global-agents: ${scope.note}`)
232
+ return
233
+ }
234
+ }
235
+
201
236
  if (mode === 'status') {
202
237
  const statuses = inspectGlobalAgents(home, sourceContent)
203
238
  for (const status of statuses) console.log(`${status.state}: ${status.path}`)
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: adl-mechanics
3
+ description: How agents reach Azure DevOps in an adl-controlled repository — agent identity, the git front controller, the adl MCP tools and their CLI fallback, repository-control hooks, and when `adl run` may start a sub-agent.
4
+ ---
5
+
6
+ # adl mechanics
7
+
8
+ How adl behaves on every machine and in every repository it controls.
9
+
10
+ ## Use When
11
+
12
+ - You are about to run a git network command, open or update a PR, read or write a work item, or start a build.
13
+ - A command is refused for identity, credentials or hooks, and you need to know why.
14
+ - The operator asks you to start a sub-agent session with `adl run`.
15
+
16
+ ## Agent identity
17
+
18
+ - Every Azure DevOps access (git, PRs, work items, builds, reads included) runs as an agent identity, never as the human. The default is the machine's default agent, set by fleet reconcile; it can always be overridden.
19
+ - **Override:** prefix a command with `ADL_AGENT_ID_AGENT=<agent-id>`. An MCP tool call can't carry a prefix, so it uses the session environment or the machine default; the CLI fallback (`adl mcp cli <command>`) takes the prefix like any command.
20
+ - Never read vault files. Never pass a token.
21
+ - **Never set `ADL_HUMAN_AZDO`.** It is the owner's human-terminal marker for `git-ado`'s and `adl id whoami`'s fail-closed human pass-through (stdin is a TTY and `ADL_HUMAN_AZDO=1`, exactly). An agent carrying it would let a child process forge that pass-through.
22
+
23
+ ## Git and Azure DevOps operations
24
+
25
+ - Use ordinary `git` for every Git operation. The managed `/usr/local/bin/git` front controller hands local and non-Azure DevOps work to the system Git, and routes HTTPS Azure DevOps network commands through `adl-agent-id exec --agent "$ADL_AGENT_ID_AGENT"`. `git-ado` handles the credential boundary; there is no second account or secret location.
26
+ - PRs, work items and builds go through the `adl` MCP server (`adl mcp serve`): `pr_list_or_get`, `pr_create_or_update`, `pr_review`, `build_list_or_get`, `build_run`, `workitem_list_or_get`, `workitem_create_or_update`. If the server is not working, fall back to `adl mcp cli <command>`.
27
+
28
+ ## Repository controls
29
+
30
+ - Run via `adl repo controls`. Git hooks run pre-commit (local checks) and pre-push (Azure DevOps governance).
31
+ - Each repository is reconciled on its own, with its `.agents/`, `.claude/`, `.codex/`, `.cursor/`, `.kimi-code/` and `.opencode/` projections.
32
+
33
+ ## Sub-agent sessions (`adl run`)
34
+
35
+ - Only on the operator's explicit request; an agent never starts one on its own. It is not an identity route and not a fallback for anything.
36
+ - **Headless:** `adl run <surface> --headless "<prompt>"`, surface one of `claude`, `codex`, `opencode`, `kimi`, `cursor`.
37
+ - **Identity:** add `--as <agent>`.
38
+ - **Model:** add `--model <model>`. adl passes each surface's own flag (claude and cursor `--model`; codex, opencode and kimi `-m`); a surface without one refuses it (exit 2). `--model` cannot be combined with `adl run -- <cmd>`.
@@ -92,7 +92,7 @@ run_ts = sys.argv[2]
92
92
  today = sys.argv[3]
93
93
  log_files = sys.argv[4:]
94
94
 
95
- cutoff = datetime.datetime.fromisoformat(today + "T00:00:00Z") - datetime.timedelta(days=days-1)
95
+ cutoff = datetime.datetime.fromisoformat(today + "T00:00:00+00:00") - datetime.timedelta(days=days-1)
96
96
 
97
97
  # Per (host, day), tally. Dedupe by (ts, command, rule) within each log.
98
98
  per_host_day = collections.defaultdict(lambda: collections.Counter())
@@ -1,100 +1,118 @@
1
1
  ---
2
2
  name: code-review
3
- description: Review the changes since a fixed point (commit, branch, tag, or merge-base) along two axes — Standards (does the code follow this repo's documented coding standards?) and Spec (does the code match what the originating issue/PRD asked for?). Runs both reviews in parallel sub-agents and reports them side by side. Use when the user wants to review a branch, a PR, work-in-progress changes, or asks to "review since X".
4
- disable-model-invocation: false
3
+ description: Run a comprehensive code review
5
4
  ---
6
5
 
7
- # Code Review
8
- Two-axis review of the diff between `HEAD` and a fixed point the user supplies:
6
+ # Code Review Task Card
9
7
 
10
- - **Standards** — does the code conform to this repo's documented coding standards?
11
- - **Spec** — does the code faithfully implement the originating issue / PRD / spec?
8
+ Use this explicit opt-in for a merge-readiness review. Shared operating invariants
9
+ live in `templates/AGENTS.md`; this card only defines review-specific behavior.
12
10
 
13
- Both axes run as **parallel sub-agents** so they don't pollute each other's context, then this skill aggregates their findings.
11
+ ## When to use
14
12
 
15
- ## Use When
13
+ - The user asks for a code review or quality/security assessment.
14
+ - A change is ready for review before merge, or a major feature needs an independent review.
15
+ - Do not activate this card for implementation, broad planning, or automatic cleanup.
16
16
 
17
- - The user wants to review a branch, a PR, or work-in-progress changes against a fixed point.
18
- - The user asks to "review since X" (a commit, branch, tag, or merge-base).
17
+ ## Inputs
19
18
 
20
- ## Do Not Use When
19
+ - Scope: the requested files, commit, PR, or whole diff.
20
+ - Requirements/specification, acceptance criteria, and relevant test/CI evidence.
21
+ - Existing review artifacts and known risks, if any.
22
+ - If the user says `continue`, advance the current verified review step rather than restarting discovery.
21
23
 
22
- - There is no fixed point to diff against and the user won't supply one (pin one first, see Process step 1), or the work isn't implemented yet so there's no diff to review — use `implement` first.
24
+ Start by recording the scope:
23
25
 
24
- The issue tracker should have been provided to you — run `/setup-matt-pocock-skills` if `docs/agents/issue-tracker.md` is missing.
26
+ ```sh
27
+ git status --short
28
+ git diff --stat
29
+ git diff -- <scope>
30
+ ```
25
31
 
26
- ## Process
32
+ ## Execution
27
33
 
28
- ### 1. Pin the fixed point
34
+ 1. Identify changed files and review boundaries; do not silently widen the scope.
35
+ 2. Launch the `code-reviewer` and `architect` agents in parallel. Both lanes run in parallel on a clean context with explicit scope and artifacts. If either lane cannot be launched or does not return evidence, report `independent review unavailable`; do **not** substitute the current/authoring lane, and do **not** approve or mark the review merge-ready.
36
+ 3. Respect the user's current model and reasoning/effort selection. Do not pass `model` or `reasoning_effort` overrides in review-lane calls.
29
37
 
30
- Whatever the user said is the fixed point — a commit SHA, branch name, tag, `main`, `HEAD~5`, etc. If they didn't specify one, ask for it.
38
+ ```text
39
+ task(
40
+ agent_type="code-reviewer",
41
+ prompt="CODE REVIEW TASK
31
42
 
32
- Capture the diff command once: `git diff <fixed-point>...HEAD` (three-dot, so the comparison is against the merge-base). Also note the list of commits via `git log <fixed-point>..HEAD --oneline`.
43
+ Review the supplied scope for spec compliance, security, quality, performance, and maintainability.
44
+ Return files reviewed, severity-rated findings with file:line evidence and concrete fixes,
45
+ and a recommendation: APPROVE / REQUEST CHANGES / COMMENT. Do not review architecture.
46
+ Scope: [scope and artifacts]"
47
+ )
33
48
 
34
- Before going further, confirm the fixed point resolves (`git rev-parse <fixed-point>`) and the diff is non-empty. A bad ref or empty diff should fail here — not inside two parallel sub-agents.
49
+ task(
50
+ agent_type="architect",
51
+ prompt="ARCHITECTURE / DEVIL'S-ADVOCATE REVIEW TASK
35
52
 
36
- ### 2. Identify the spec source
53
+ Review the same scope for boundaries, interfaces, hidden coupling, long-term tradeoffs,
54
+ and the strongest counterargument against approval. Return file:line evidence,
55
+ recommendations, and Architectural Status: CLEAR / WATCH / BLOCK.
56
+ Scope: [scope and artifacts]"
57
+ )
58
+ ```
37
59
 
38
- Look for the originating spec, in this order:
60
+ ## Review taxonomy
39
61
 
40
- 1. Issue references in the commit messages (`#123`, `Closes #45`, GitLab `!67`, etc.) — fetch via the workflow in `docs/agents/issue-tracker.md`.
41
- 2. A path the user passed as an argument.
42
- 3. A PRD/spec file under `docs/`, `specs/`, or `.adl/` matching the branch name or feature.
43
- 4. If nothing is found, ask the user where the spec is. If they say there isn't one, the **Spec** sub-agent will skip and report "no spec available".
62
+ - `code-reviewer` checks **Security**, **Code Quality**, **Performance**, **Best Practices**, and **Maintainability**.
63
+ - Rate each finding: **CRITICAL** (security or data-loss blocker), **HIGH** (bug/major smell), **MEDIUM** (important improvement), or **LOW** (style/suggestion).
64
+ - `architect` checks explicit boundaries/interfaces, hidden coupling, long-horizon tradeoffs, and devil's-advocate concerns. Status is **CLEAR**, **WATCH** (non-blocking concern), or **BLOCK** (merge blocker).
65
+ - Every finding names `file:line`, issue, risk, and a concrete fix; distinguish facts from suggestions.
44
66
 
45
- ### 3. Identify the standards sources
67
+ ## State/HUD Phase Contract
46
68
 
47
- Anything in the repo that documents how code should be written, such as `CODING_STANDARDS.md` or `CONTRIBUTING.md`.
69
+ - Standalone `$code-review` relies on hook-owned `skill-active-state.json` (`skill:"code-review"`, `phase:"planning"`); do not create `code-review-state.json`.
70
+ - Inside Autopilot, keep `mode:"autopilot"` active with `current_phase:"code-review"` / skill-active `phase:"code-review"`; do not activate a peer workflow.
71
+ - On clean review, persist the artifact under Autopilot `handoff_artifacts.code_review` before moving to `ultraqa`. On non-clean review, persist findings and use `rework` or `ralplan` as appropriate.
48
72
 
49
- On top of whatever the repo documents, the Standards axis always carries the **smell baseline** below — a fixed set of Fowler code smells (_Refactoring_, ch.3) that applies even when a repo documents nothing. Two rules bind it:
73
+ ```sh
74
+ adw state write --input '{"mode":"autopilot","active":true,"current_phase":"code-review"}' --json
75
+ ```
50
76
 
51
- - **The repo overrides.** A documented repo standard always wins; where it endorses something the baseline would flag, suppress the smell.
52
- - **Always a judgement call.** Each smell is a labelled heuristic ("possible Feature Envy"), never a hard violation — and, like any standard here, skip anything tooling already enforces.
77
+ ## Final Synthesis and gate
53
78
 
54
- Each smell reads *what it is* → *how to fix*; match it against the diff:
79
+ ### Architectural Status Contract
55
80
 
56
- - **Mysterious Name** — a function, variable, or type whose name doesn't reveal what it does or holds. → rename it; if no honest name comes, the design's murky.
57
- - **Duplicated Code** — the same logic shape appears in more than one hunk or file in the change. → extract the shared shape, call it from both.
58
- - **Feature Envy** — a method that reaches into another object's data more than its own. → move the method onto the data it envies.
59
- - **Data Clumps** — the same few fields or params keep travelling together (a type wanting to be born). → bundle them into one type, pass that.
60
- - **Primitive Obsession** — a primitive or string standing in for a domain concept that deserves its own type. → give the concept its own small type.
61
- - **Repeated Switches** — the same `switch`/`if`-cascade on the same type recurs across the change. → replace with polymorphism, or one map both sites share.
62
- - **Shotgun Surgery** — one logical change forces scattered edits across many files in the diff. → gather what changes together into one module.
63
- - **Divergent Change** — one file or module is edited for several unrelated reasons. → split so each module changes for one reason.
64
- - **Speculative Generality** — abstraction, parameters, or hooks added for needs the spec doesn't have. → delete it; inline back until a real need shows.
65
- - **Message Chains** — long `a.b().c().d()` navigation the caller shouldn't depend on. → hide the walk behind one method on the first object.
66
- - **Middle Man** — a class or function that mostly just delegates onward. → cut it, call the real target direct.
67
- - **Refused Bequest** — a subclass or implementer that ignores or overrides most of what it inherits. → drop the inheritance, use composition.
81
+ Combine the `code-reviewer` recommendation and architect status. Approval requires explicit evidence from both independent lanes; missing or failed delegation is a blocking unavailable-review state, not an approval fallback. The final report must make architect blockers impossible to miss.
68
82
 
69
- ### 4. Spawn both sub-agents in parallel
83
+ - If architect status is **BLOCK**, final recommendation is **REQUEST CHANGES**.
84
+ - Else if `code-reviewer` recommendation is **REQUEST CHANGES**, final recommendation is **REQUEST CHANGES**.
85
+ - Else if architect status is **WATCH**, final recommendation is **COMMENT**.
86
+ - Else final recommendation follows the `code-reviewer` lane.
70
87
 
71
- Send a single message with two `Agent` tool calls. Use the `general-purpose` subagent for both.
88
+ Approval criteria: **APPROVE** only when `code-reviewer` returns APPROVE, architect status is `CLEAR`, and both independent lanes returned evidence. **REQUEST CHANGES** for a blocker, unresolved high/critical finding, or unavailable lane. **COMMENT** may record non-blocking findings.
72
89
 
73
- **Standards sub-agent prompt** — include:
90
+ Do not self-review as a fallback. If the `code-reviewer` or `architect` path is missing, unavailable, skipped, or fails, block approval until independent lane evidence exists. Plain `code-review` itself remains read-only and does **not** promise auto-fix.
74
91
 
75
- - The full diff command and commit list.
76
- - The list of standards-source files you found in step 3, **plus the smell baseline from step 3** pasted in full — the sub-agent has no other access to it.
77
- - The brief: "Report — per file/hunk where relevant — (a) every place the diff violates a documented standard: cite the standard (file + the rule); and (b) any baseline smell you spot: name it and quote the hunk. Distinguish hard violations from judgement calls — documented-standard breaches can be hard, but baseline smells are always judgement calls, and a documented repo standard overrides the baseline. Skip anything tooling enforces. Under 400 words."
92
+ ## Evidence/output contract
78
93
 
79
- **Spec sub-agent prompt** — include:
94
+ Return a concise report containing:
80
95
 
81
- - The diff command and commit list.
82
- - The path or fetched contents of the spec.
83
- - The brief: "Report: (a) requirements the spec asked for that are missing or partial; (b) behaviour in the diff that wasn't asked for (scope creep); (c) requirements that look implemented but where the implementation looks wrong. Quote the spec line for each finding. Under 400 words."
96
+ ```text
97
+ CODE REVIEW REPORT
98
+ Files Reviewed: <count>
99
+ Total Issues: 0
100
+ Architectural Status: CLEAR | WATCH | BLOCK
101
+ CRITICAL (0) | HIGH (0) | MEDIUM (0) | LOW (0)
102
+ Findings: file:line -> issue, risk, concrete fix (or none)
103
+ ARCHITECTURE WATCHLIST: concern, status, recommendation (or none)
104
+ - code-reviewer recommendation: COMMENT
105
+ - architect status: WATCH
106
+ - final recommendation: COMMENT
107
+ RECOMMENDATION: COMMENT
108
+ ```
84
109
 
85
- If the spec is missing, skip the Spec sub-agent and note this in the final report.
110
+ Replace the illustrative counts and verdict with observed values. Include scope,
111
+ lane evidence/artifact references, unresolved risks, and validation gaps.
86
112
 
87
- ### 5. Aggregate
113
+ ## Exit condition
88
114
 
89
- Present the two reports under `## Standards` and `## Spec` headings, verbatim or lightly cleaned. Do **not** merge or rerank findings — the two axes are deliberately separate (see _Why two axes_).
90
-
91
- End with a one-line summary: total findings per axis, and the worst issue _within each axis_ (if any). Don't pick a single winner across axes — that's the reranking the separation exists to prevent.
92
-
93
- ## Why two axes
94
-
95
- A change can pass one axis and fail the other:
96
-
97
- - Code that follows every standard but implements the wrong thing → **Standards pass, Spec fail.**
98
- - Code that does exactly what the issue asked but breaks the project's conventions → **Spec pass, Standards fail.**
99
-
100
- Reporting them separately stops one axis from masking the other.
115
+ Stop when the scoped diff has two independent lane results and a deterministic final
116
+ recommendation. Report `APPROVE` only under the approval criteria; otherwise leave a
117
+ bounded `REQUEST CHANGES`, `COMMENT`, or unavailable-review result. Never claim
118
+ merge-ready without the required evidence.
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: diagnosing-bugs
3
- description: Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.
3
+ description: Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", reports something broken/throwing/failing/slow, or asks to trace a crash or root cause through the call chain.
4
+ keywords: trace crash root cause call chain execution flow callers callees failing throwing regression diagnose debug
4
5
  disable-model-invocation: false
5
6
  ---
6
7
 
@@ -53,6 +54,24 @@ Once it's red, shrink the repro to the **smallest scenario that still goes red**
53
54
 
54
55
  Done when **every remaining element is load-bearing** — removing any one of them makes the loop go green. Do not proceed until you have reproduced **and** minimised.
55
56
 
57
+ ## Trace with the knowledge graph
58
+
59
+ When the symptom names a code area, or a recent change is the suspect, trace
60
+ the call structure with the knowledge graph instead of reading file by file —
61
+ this is how Phase 3 hypotheses get built fast:
62
+
63
+ 1. Run `crg search "<query>"` to find code related to the issue.
64
+ 2. Run `crg query callers_of <target>` and `crg query callees_of <target>` to trace call chains.
65
+ 3. Run `crg flow --name <n>` to see full execution paths through suspected areas.
66
+ 4. Run `crg detect-changes --base <ref>` to check if recent changes caused the issue.
67
+ 5. Run `crg impact --files <f…>` on suspected files to see what else is affected.
68
+
69
+ - Check both callers and callees to understand the full context.
70
+ - Look at affected flows to find the entry point that triggers the bug.
71
+ - Recent changes are the most common source of new issues.
72
+ - Trace efficiently: capped output (`--limit`, `--brief`), a handful of commands,
73
+ then verify the suspected cause against real source before proposing a fix.
74
+
56
75
  ## Phase 3 — Hypothesise
57
76
 
58
77
  Generate **3–5 ranked hypotheses** before testing any of them. Single-hypothesis generation anchors on the first plausible idea.
@@ -99,10 +118,12 @@ Required before declaring done:
99
118
 
100
119
  **Then ask: what would have prevented this bug?** If the answer involves architectural change (no good test seam, tangled callers, hidden coupling) hand off to the `/improve-codebase-architecture` skill with the specifics. Make the recommendation **after** the fix is in, not before — you have more information now than when you started.
101
120
 
102
- ## HITL loop script
121
+ ## HITL loop script — live sessions only
103
122
 
104
123
  `scripts/hitl-loop.template.sh` is the human-in-the-loop reproduction loop (usage notes moved out of the script so the deployed copy has no multi-line comment run).
105
124
 
125
+ **Live sessions only** — a session where the human is present (`write-feature`-style live work, or this skill invoked interactively). Never inside a dispatched run: No block forbids waiting on a person, and run evidence must be machine-checkable. In a dispatched run a human-only repro is automated instead (Playwright drives the clicks — tactic 4) or, if that genuinely fails, the lead posts the attempt as a finding and parks the item with proof. In a live session the captured `KEY=VALUE` pairs are the human's testimony, and the regression test built from them still lands before the fix.
126
+
106
127
  - Copy the file, edit the steps in it, and run it. The agent runs the script; the user follows prompts in their terminal.
107
128
  - Usage: `bash hitl-loop.template.sh`
108
129
  - Two helpers: `step "<instruction>"` shows the instruction and waits for Enter; `capture VAR "<question>"` shows the question and reads the response into `VAR`.
@@ -11,7 +11,7 @@
11
11
  7. **Property / fuzz loop.** If the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode.
12
12
  8. **Bisection harness.** If the bug appeared between two known states (commit, dataset, version), automate "boot at state X, check, repeat" so you can `git bisect run` it.
13
13
  9. **Differential loop.** Run the same input through old-version vs new-version (or two configs) and diff outputs.
14
- 10. **HITL bash script.** Last resort. If a human must click, drive _them_ with `scripts/hitl-loop.template.sh` so the loop is still structured. Captured output feeds back to you.
14
+ 10. **HITL bash script.** If a human must click, drive _them_ with `scripts/hitl-loop.template.sh` so the loop is still structured. **Live sessions only** — never inside a dispatched run (No block: never wait on a person; run evidence must be machine-checkable). In a run, automate the human instead (Playwright, tactic 4); if that genuinely fails, the lead parks the item with proof. Captured output feeds back to you.
15
15
 
16
16
  Build the right feedback loop, and the bug is 90% fixed.
17
17
 
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: explore-codebase
3
3
  description: Navigate and understand codebase structure using the knowledge graph
4
+ keywords: navigate orient structure understand unfamiliar get oriented modules
4
5
  disable-model-invocation: false
5
6
  ---
6
7
 
@@ -16,8 +17,8 @@ relationships before making a change, or locating where a concept lives.
16
17
  ## Do Not Use When
17
18
 
18
19
  You already know where the problem is and need to trace a bug — use
19
- `debug-issue`. You are about to refactor a known target — use
20
- `refactor-safely`. You are reviewing a pending diff — use `review-changes`.
20
+ `diagnosing-bugs`. You are about to refactor a known target — use
21
+ `refactor-safely`. You are reviewing a pending diff — use `code-review`.
21
22
 
22
23
  ## Steps
23
24
 
@@ -0,0 +1,63 @@
1
+ ---
2
+ name: finalize-feature
3
+ description: Assemble the content for the one Feature implementation PR without pushing - the five-section PR body and the implementation report for all items - and check that the design's docs impact is in the diff. Returns text to the lead. Use when the implementation lead spawns writer after the Feature-final check passed at the final head.
4
+ metadata:
5
+ step: "finalize"
6
+ role: "writer"
7
+ states: "Updating Docs"
8
+ ---
9
+
10
+ # Finalize Feature (sub-agent skill)
11
+
12
+ Load `workitems-process` first. You are a leaf sub-agent of `lead` (`implement-feature`). Evidence assembly only. Docs were written in `implement-item` and reviewed with the code; you make **no pushes, commits, file edits or board writes**, because any push voids the Feature-final evidence. The lead raises the PR; `pr_create_or_update` links the items, moves them and attaches the report **[pending P1/P2/P4]**. You supply content only.
13
+
14
+ ## When to use
15
+
16
+ - The lead holds a Feature-final verify `PASS` and both review lanes passing at the final head `H`, and items are code-complete (Updating Docs or about to be).
17
+ - Also on a CI round: the lead asks you to append that round to the report.
18
+ - Not for writing docs, fixing code or resolving conflicts.
19
+
20
+ ## Inputs (from the brief)
21
+
22
+ - Final head `H`, `base_sha`, all per-item sub-agent reports (implement, verify, review) and their finding resolutions, the Feature-final reports, design-update commits, CI rounds so far.
23
+ - Plan folder: `requirements.md`, `design.md` (`## Docs impact`), item files.
24
+
25
+ ## Preconditions
26
+
27
+ 1. `git rev-parse HEAD` equals `H` and the worktree is clean; else return it to the lead as a finding and stop ([No block](../workitems-process/SKILL.md#no-block)).
28
+ 2. The Feature-final verify is `PASS` and code is `APPROVE` and architecture `CLEAR`/`WATCH`, all at `H`; else return it to the lead as a finding and stop ([No block](../workitems-process/SKILL.md#no-block)).
29
+
30
+ ## Procedure
31
+
32
+ 1. **Docs check.** For each entry in `design.md` `## Docs impact` (per-Bug run: the docs the fix touches), find the matching path in `git diff --name-only origin/integration...H` and read the hunk, not just the filename. "No docs impact" counts as covered. Any missing entry: verdict `REWORK`, finding `docs-missing` (`where`: doc path or section; `fix`: what to write). Stop.
33
+ 2. **PR body.** The five non-empty sections in [ado-and-git.md](../workitems-process/references/ado-and-git.md#7-git), filled as below. Every claim links to evidence (a report, a commit, a run); no unverified statements.
34
+ - `## Summary`: what the Feature delivers, by item (id, title).
35
+ - `## Why`: from `intent.md` and `requirements.md`, in the plan's words, not new claims.
36
+ - `## Changes`: per item, the files and behaviour changed; design updates made during the run; docs touched.
37
+ - `## Test plan`: per `AC-n`, the test and its result; Feature-final verify run at `H`; CI status as known.
38
+ - `## Security impact considered`: what the code reviewer examined and found; "none" only with the reviewer's report as the source.
39
+ The title is `<type>(<scope>): <lowercase subject>`.
40
+ 3. **Implementation report** (becomes `impl-report-pr<id>.md`). Per item: changes, tests (`AC-n` → test, red then green), review findings (id, severity, resolution or accepted WATCH), rounds used. Then: design updates, Feature-final heads and results, CI rounds. Facts only, from the reports.
41
+ 4. **Return** `lane: finalize`, `head_sha` = `H`, `verdict`, and in the reply the PR body, the report text and the docs-impact table (entry → doc path), each in its own fenced block. Write them nowhere.
42
+
43
+ ## Verdicts
44
+
45
+ | Verdict | When | Lead does |
46
+ |---|---|---|
47
+ | `DONE` | Docs covered; body and report complete | Pushes and raises the PR |
48
+ | `REWORK` + `docs-missing` | Docs impact not in the diff | Executor writes it; Feature-final repeats |
49
+
50
+ ## Stop rules
51
+
52
+ - One pass, against the `head_sha` recorded at start. If HEAD moves while you work, finish against that `head_sha` and say so; never restart. The lead re-runs you at the new head ([Evidence and reports](../workitems-process/SKILL.md#evidence-and-reports), the head rule).
53
+
54
+ ## Never
55
+
56
+ - Never push, commit, rebase or edit files. Never write the body or report to disk.
57
+ - Never call `pr_create_or_update` or any board tool; never link items, set auto-complete, vote or merge.
58
+ - Never include a claim without a source, or a PR link that does not resolve.
59
+ - Never write the docs yourself.
60
+
61
+ ## Parked
62
+
63
+ `prepare-promotion` (integration to main, G2) is parked: no target fires it. It stays with `writer`, for later.
@@ -0,0 +1,58 @@
1
+ ---
2
+ name: fix-ci
3
+ description: Make the smallest fix for a red CI run on the run's implementation PR (a Feature's, or a Fixes Bug's) - read the failing job, reproduce it locally, fix at the cause, commit on the run's branch, no skips and no masking. Use when the implementation lead spawns executor for the CI stage after the PR checks went red.
4
+ metadata:
5
+ step: "fix-ci"
6
+ role: "executor"
7
+ states: "CI stage"
8
+ ---
9
+
10
+ # Fix CI (sub-agent skill)
11
+
12
+ Load `workitems-process` first. You are a leaf sub-agent of `lead` (`implement-feature`), the fix lane of the CI stage (ADR-019). CI is the last gate before the implementation PR (the Feature's, or the Fixes Bug's) merges to `integration`. A hard cut: the fix is the smallest change that makes the real check pass.
13
+
14
+ ## When to use
15
+
16
+ - The PR's required check failed at head `H`. The lead names the PR id, the failed build and job ids, and the related item.
17
+ - A merge-conflict round is not yours; the lead sends an executor with `implement-item`.
18
+
19
+ ## Inputs (from the brief)
20
+
21
+ - PR id, build id, failed job(s), head SHA, related item id (the item whose commits touch the failing paths; else the lowest-id item; in a per-Bug run, the Bug), plan folder (in a per-Bug run, the Bug's item file).
22
+
23
+ ## Preconditions
24
+
25
+ 1. Worktree toplevel and HEAD equal the brief's; tree is clean; branch is the run's branch (the Feature branch, or `fix/az<bug id>-<slug>` in a per-Bug run).
26
+ 2. The failing job log is readable (`build_list_or_get --build-id <id>`, with `--tail`). Unreadable: return it to the lead as a finding and stop ([No block](../workitems-process/SKILL.md#no-block)).
27
+
28
+ ## Procedure
29
+
30
+ 1. **Read the log.** Find the first failing step, its command and its error. Quote the failing line.
31
+ 2. **Classify.**
32
+ - Code or test failure: continue.
33
+ - Infrastructure failure (agent lost, cancelled, network, queue timeout) with log proof and no code cause: return `INFRA` with the proof. The lead may re-queue the PR's own validation (pending H1). Do not change code.
34
+ 3. **Reproduce locally** with the same command. A failure you cannot reproduce is reported with both outputs, not "fixed" by guessing.
35
+ 4. **Fix at the cause.** Test first when the failure exposes a missing test. Smallest change; no unrelated cleanup; no new abstraction.
36
+ 5. **Checks.** Run the failing command and the repo's lint, typecheck, build and the relevant tests locally. Green.
37
+ 6. **Commit** on the run's branch: `fix(ci): <lowercase subject>`, `AB#<item id>` in the body (the Bug's id in a per-Bug run), naming the build and job. Do not push.
38
+ 7. **Return the report**: `lane: fix-ci`, `head_sha` = your commit, `verdict`, `findings` (the cause: `where`, `what`, `fix`), `artifacts` = failing log line, local red and green runs, commit SHA.
39
+
40
+ ## Verdicts
41
+
42
+ | Verdict | When |
43
+ |---|---|
44
+ | `FIXED` | Reproduced, fixed at the cause, local checks green, committed |
45
+ | `INFRA` | Not a code failure; log proof included; nothing changed |
46
+
47
+ The lead then has `verifier` and `code-reviewer` re-check the delta at the new head. A fix is not done until they pass.
48
+
49
+ ## Stop rules
50
+
51
+ - The same check fails after three distinct fixes: return it to the lead as a finding and stop ([No block](../workitems-process/SKILL.md#no-block)).
52
+
53
+ ## Never
54
+
55
+ - Never skip, disable, quarantine or loosen a test or check. Never `|| true`. Never `--no-verify`. Never delete a failing test.
56
+ - Never re-run until green and call it fixed; a flaky result is reported with both runs.
57
+ - Never push, force-push, re-queue a build, move an item or touch the PR.
58
+ - Never edit `requirements.md` or `design.md`.
@@ -21,7 +21,7 @@ Write a handoff document summarising the current conversation so a fresh agent c
21
21
 
22
22
  Include a "suggested skills" section in the document, which suggests skills that the agent should invoke.
23
23
 
24
- Do not duplicate content already captured in other artifacts (specs, plans, ADRs, issues, commits, diffs). Reference them by path or URL instead.
24
+ Do not duplicate content already captured in other artifacts (docs, plans, ADRs, commits, diffs). Reference them by path or URL instead.
25
25
 
26
26
  Redact any sensitive information, such as API keys, passwords, or personally identifiable information.
27
27