@akagilnc/pi-workflow-roles 0.1.4444 → 0.1.4489

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 (44) hide show
  1. package/README.md +2 -0
  2. package/README.zh-CN.md +2 -0
  3. package/dist/acp-host/description.js +2 -3
  4. package/dist/acp-host/production-host.js +140 -107
  5. package/dist/auditor-soul.js +8 -1
  6. package/dist/headless-host/description.js +3 -3
  7. package/dist/headless-host/production-host.js +147 -76
  8. package/dist/host-descriptions.js +3 -18
  9. package/dist/method-host-plugin/.claude-plugin/plugin.json +5 -0
  10. package/dist/method-host-plugin/skills/ak-cross-m-review/CONTEXT.md +48 -0
  11. package/dist/method-host-plugin/skills/ak-cross-m-review/LICENSE +21 -0
  12. package/dist/method-host-plugin/skills/ak-cross-m-review/SKILL.md +170 -0
  13. package/dist/method-host-plugin/skills/ak-cross-m-review/prompts/cmr-completeness.md +118 -0
  14. package/dist/method-host-plugin/skills/ak-cross-m-review/prompts/cmr-reviewer.md +128 -0
  15. package/dist/method-host-plugin/skills/ak-cross-m-review/provenance.json +41 -0
  16. package/dist/method-host-plugin/skills/diagnosing-bugs/SKILL.md +134 -0
  17. package/dist/method-host-plugin/skills/diagnosing-bugs/agents/openai.yaml +3 -0
  18. package/dist/method-host-plugin/skills/diagnosing-bugs/provenance.json +31 -0
  19. package/dist/method-host-plugin/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +41 -0
  20. package/dist/method-host-plugin/skills/resolving-merge-conflicts/SKILL.md +14 -0
  21. package/dist/method-host-plugin/skills/resolving-merge-conflicts/agents/openai.yaml +3 -0
  22. package/dist/method-host-plugin/skills/resolving-merge-conflicts/provenance.json +26 -0
  23. package/dist/method-host-plugin/skills/tdd/SKILL.md +38 -0
  24. package/dist/method-host-plugin/skills/tdd/agents/openai.yaml +3 -0
  25. package/dist/method-host-plugin/skills/tdd/mocking.md +59 -0
  26. package/dist/method-host-plugin/skills/tdd/provenance.json +36 -0
  27. package/dist/method-host-plugin/skills/tdd/tests.md +77 -0
  28. package/dist/public-cli/main.js +14 -21
  29. package/dist/session-opening-materials.js +17 -5
  30. package/extensions/role-runtime.ts +16 -6
  31. package/package.json +1 -1
  32. package/resources/method-host-plugin/.claude-plugin/plugin.json +5 -0
  33. package/scripts/build-package.mjs +6 -1
  34. package/src/acp-host/description.ts +2 -4
  35. package/src/acp-host/production-host.ts +0 -1
  36. package/src/auditor-soul.ts +10 -1
  37. package/src/headless-host/description.ts +4 -3
  38. package/src/headless-host/role-turn-host.ts +27 -4
  39. package/src/host-descriptions.ts +3 -23
  40. package/src/host-native-method.ts +67 -0
  41. package/src/role-envelope.ts +17 -47
  42. package/src/role-runtime-dependencies.ts +17 -2
  43. package/src/role-runtime.ts +12 -7
  44. package/src/session-opening-materials.ts +27 -11
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env bash
2
+ # Human-in-the-loop reproduction loop.
3
+ # Copy this file, edit the steps below, and run it.
4
+ # The agent runs the script; the user follows prompts in their terminal.
5
+ #
6
+ # Usage:
7
+ # bash hitl-loop.template.sh
8
+ #
9
+ # Two helpers:
10
+ # step "<instruction>" → show instruction, wait for Enter
11
+ # capture VAR "<question>" → show question, read response into VAR
12
+ #
13
+ # At the end, captured values are printed as KEY=VALUE for the agent to parse.
14
+
15
+ set -euo pipefail
16
+
17
+ step() {
18
+ printf '\n>>> %s\n' "$1"
19
+ read -r -p " [Enter when done] " _
20
+ }
21
+
22
+ capture() {
23
+ local var="$1" question="$2" answer
24
+ printf '\n>>> %s\n' "$question"
25
+ read -r -p " > " answer
26
+ printf -v "$var" '%s' "$answer"
27
+ }
28
+
29
+ # --- edit below ---------------------------------------------------------
30
+
31
+ step "Open the app at http://localhost:3000 and sign in."
32
+
33
+ capture ERRORED "Click the 'Export' button. Did it throw an error? (y/n)"
34
+
35
+ capture ERROR_MSG "Paste the error message (or 'none'):"
36
+
37
+ # --- edit above ---------------------------------------------------------
38
+
39
+ printf '\n--- Captured ---\n'
40
+ printf 'ERRORED=%s\n' "$ERRORED"
41
+ printf 'ERROR_MSG=%s\n' "$ERROR_MSG"
@@ -0,0 +1,14 @@
1
+ ---
2
+ name: resolving-merge-conflicts
3
+ description: "Use when you need to resolve an in-progress ordinary two-parent git merge conflict without inventing new authority."
4
+ ---
5
+
6
+ 1. **See the current state** of the ordinary two-parent merge already in progress. Use the admitted Merger assignment envelope (target/source parents, complete conflict set, resolution scope, authorized checks). Check git history and the conflicting files. This method is **merge-only**: do **not** start, abort, or continue a rebase, and do **not** treat general non-merge conflict workflows as in scope.
7
+
8
+ 2. **Find the primary sources** for each conflict. Understand deeply why each change was made, and what the original intent was. Read the commit messages, check the PRs, check original issues/tickets. Prefer admitted task/authority materials and primary sources over guesswork.
9
+
10
+ 3. **Resolve each hunk within resolution scope.** Preserve both intents where possible. Where intents are compatible, keep both. Where incompatible, or where a new product or authority decision is required, stop and submit the existing typed **escalate** outcome with a clear diagnosis — do **not** invent new behaviour, do **not** guess authority, and do **not** silently pick a side that needs a new decision. Never `--abort` (the caller owns abort). Never continue a rebase.
11
+
12
+ 4. Run **authorized checks** from the admitted assignment when present. When the assignment lists none, discover the project's automated checks within the role boundary — typically typecheck, then tests, then format — and run them. Fix anything the merge resolution broke that stays inside scope.
13
+
14
+ 5. **Finish the ordinary two-parent merge commit** within resolution scope. Stage in-scope resolutions and create the merge commit with the frozen target then source parents. Title it `ak-roles: merge: …` (factory worker prefix first). Do **not** publish, push, or route another role. Do **not** broaden into rebase or general conflict cleanup outside the admitted merge.
@@ -0,0 +1,3 @@
1
+ interface:
2
+ display_name: "Resolving Merge Conflicts"
3
+ short_description: "Resolve ordinary two-parent merge conflicts; escalate new authority"
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "resolving-merge-conflicts",
3
+ "kind": "role-method-skill",
4
+ "upstream": {
5
+ "repository": "https://github.com/mattpocock/skills",
6
+ "path": "skills/engineering/resolving-merge-conflicts",
7
+ "commit": "8b36d4fb2635b3c21998dcd8144439c9e5ba7302",
8
+ "tag": "v1.2.2",
9
+ "license": "MIT",
10
+ "copyright": "Copyright (c) 2026 Matt Pocock",
11
+ "attribution": "mattpocock/skills"
12
+ },
13
+ "packageAdaptation": "merger-merge-only-escalate-new-intent",
14
+ "files": {
15
+ "SKILL.md": {
16
+ "sha256": "a7be3300cd1457cb9b4065935271f37759531ebb366a352896a7a617d8d9c18a",
17
+ "byteLength": 2015,
18
+ "gitBlob": "b88102a6e903c2e60d3b4898552a0931a2fa4c91"
19
+ },
20
+ "agents/openai.yaml": {
21
+ "sha256": "f283f1ac11525de29d2615163fc3239b979f67c8e88560644364ca6e1a3b8100",
22
+ "byteLength": 146,
23
+ "gitBlob": "dc388c3df1d0a72ae2cfe7c78a23747f26e96822"
24
+ }
25
+ }
26
+ }
@@ -0,0 +1,38 @@
1
+ ---
2
+ name: tdd
3
+ description: Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
4
+ ---
5
+
6
+ # Test-Driven Development
7
+
8
+ TDD commonly uses a red → green loop. This skill is a reference for producing tests worth keeping: what a good test is, where tests go, the anti-patterns, and the practices of the loop. Consult the sections before and during the loop when they help; they are method guidance, not retrospective delivery gates.
9
+
10
+ When exploring the codebase, read `CONTEXT.md` (if it exists) so test names and interface vocabulary match the project's domain language, and respect ADRs in the area you're touching.
11
+
12
+ ## What a good test is
13
+
14
+ Tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't. A good test reads like a specification — "user can checkout with valid cart" tells you exactly what capability exists — and survives refactors because it doesn't care about internal structure.
15
+
16
+ See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.
17
+
18
+ ## Seams — where tests go
19
+
20
+ A **seam** is the public boundary you test at: the interface where you observe behavior without reaching inside. Tests live at seams, never against internals.
21
+
22
+ **Test only at pre-agreed seams.** Before writing any test, write down the seams under test and confirm them with the user. No test is written at an unconfirmed seam. You can't test everything — agreeing the seams up front is how testing effort lands on the critical paths and complex logic instead of every edge case.
23
+
24
+ Ask: "What's the public interface, and which seams should we test?"
25
+
26
+ When the shape of that interface is itself in question — how deep the module is, where the seam belongs, what the interface should expose — use the `/codebase-design` skill for the vocabulary. It is the shared source of the module, interface, depth, seam, adapter, leverage and locality terms, and it is a reference to consult, not a session to run.
27
+
28
+ ## Anti-patterns
29
+
30
+ - **Implementation-coupled** — mocks internal collaborators, tests private methods, or verifies through a side channel (querying the database instead of using the interface). The tell: the test breaks when you refactor but behavior hasn't changed.
31
+ - **Tautological** — the assertion recomputes the expected value the way the code does (`expect(add(a, b)).toBe(a + b)`, a snapshot derived by hand the same way, a constant asserted equal to itself), so it passes by construction and can never disagree with the code. Expected values must come from an independent source of truth — a known-good literal, a worked example, the spec.
32
+ - **Horizontal slicing** — writing all tests first, then all implementation. Bulk tests verify _imagined_ behavior: you test the _shape_ of things rather than user-facing behavior, the tests go insensitive to real changes, and you commit to test structure before understanding the implementation. Work in **vertical slices** instead — one test → one implementation → repeat, each test a **tracer bullet** that responds to what the last cycle taught you.
33
+
34
+ ## Rules of the loop
35
+
36
+ - **Prefer red before green.** When practical, write the failing test first, then only enough code to pass it. If that historical order cannot be demonstrated, disclose the deviation; assess delivery from the current code, behavior, and evidence rather than rejecting it for sequence alone. Don't anticipate future tests or add speculative features.
37
+ - **One slice at a time.** One seam, one test, one minimal implementation per cycle.
38
+ - **Refactoring is not part of the loop.** It belongs to the review stage (see the `code-review` skill), not the red → green implementation cycle.
@@ -0,0 +1,3 @@
1
+ interface:
2
+ display_name: "TDD"
3
+ short_description: "Test-driven red-green-refactor"
@@ -0,0 +1,59 @@
1
+ # When to Mock
2
+
3
+ Mock at **system boundaries** only:
4
+
5
+ - External APIs (payment, email, etc.)
6
+ - Databases (sometimes - prefer test DB)
7
+ - Time/randomness
8
+ - File system (sometimes)
9
+
10
+ Don't mock:
11
+
12
+ - Your own classes/modules
13
+ - Internal collaborators
14
+ - Anything you control
15
+
16
+ ## Designing for Mockability
17
+
18
+ At system boundaries, design interfaces that are easy to mock:
19
+
20
+ **1. Use dependency injection**
21
+
22
+ Pass external dependencies in rather than creating them internally:
23
+
24
+ ```typescript
25
+ // Easy to mock
26
+ function processPayment(order, paymentClient) {
27
+ return paymentClient.charge(order.total);
28
+ }
29
+
30
+ // Hard to mock
31
+ function processPayment(order) {
32
+ const client = new StripeClient(process.env.STRIPE_KEY);
33
+ return client.charge(order.total);
34
+ }
35
+ ```
36
+
37
+ **2. Prefer SDK-style interfaces over generic fetchers**
38
+
39
+ Create specific functions for each external operation instead of one generic function with conditional logic:
40
+
41
+ ```typescript
42
+ // GOOD: Each function is independently mockable
43
+ const api = {
44
+ getUser: (id) => fetch(`/users/${id}`),
45
+ getOrders: (userId) => fetch(`/users/${userId}/orders`),
46
+ createOrder: (data) => fetch('/orders', { method: 'POST', body: data }),
47
+ };
48
+
49
+ // BAD: Mocking requires conditional logic inside the mock
50
+ const api = {
51
+ fetch: (endpoint, options) => fetch(endpoint, options),
52
+ };
53
+ ```
54
+
55
+ The SDK approach means:
56
+ - Each mock returns one specific shape
57
+ - No conditional logic in test setup
58
+ - Easier to see which endpoints a test exercises
59
+ - Type safety per endpoint
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "tdd",
3
+ "kind": "role-method-skill",
4
+ "upstream": {
5
+ "repository": "https://github.com/mattpocock/skills",
6
+ "path": "skills/engineering/tdd",
7
+ "commit": "8b36d4fb2635b3c21998dcd8144439c9e5ba7302",
8
+ "tag": "v1.2.2",
9
+ "license": "MIT",
10
+ "copyright": "Copyright (c) 2026 Matt Pocock",
11
+ "attribution": "mattpocock/skills"
12
+ },
13
+ "packageAdaptation": "red-green-advisory-no-historical-compliance-gate",
14
+ "files": {
15
+ "SKILL.md": {
16
+ "sha256": "26c74168236078b8e43510b49f8c4b30784ec3cc7d4b1356792cbc8500d5cae6",
17
+ "byteLength": 3798,
18
+ "gitBlob": "d6b6bebaa1d1fed58812f8809b9ebc1ff9a5d1e4"
19
+ },
20
+ "tests.md": {
21
+ "sha256": "859f9e592c188fda4fc7277dd180e4ce9c7a2e13f6efe1f6f29eccc9d28c106a",
22
+ "byteLength": 2214,
23
+ "gitBlob": "7ab86479f925a1f9e8ba680af33cb3b12e015381"
24
+ },
25
+ "mocking.md": {
26
+ "sha256": "3ceb807fdf4a47d6a93d4d9a891e5ba6d362a6247bd08adc451feebfc17361ef",
27
+ "byteLength": 1481,
28
+ "gitBlob": "71cbfee674d93244ce81d1830b930ca9a69200bd"
29
+ },
30
+ "agents/openai.yaml": {
31
+ "sha256": "ea6f01cf1b8c06a4b0f5b649d74b1b8ce8685e72af1b38d70d877693e092af0b",
32
+ "byteLength": 87,
33
+ "gitBlob": "651b838a7663e027b1b8884491e867f26bb9a021"
34
+ }
35
+ }
36
+ }
@@ -0,0 +1,77 @@
1
+ # Good and Bad Tests
2
+
3
+ ## Good Tests
4
+
5
+ **Integration-style**: Test through real interfaces, not mocks of internal parts.
6
+
7
+ ```typescript
8
+ // GOOD: Tests observable behavior
9
+ test("user can checkout with valid cart", async () => {
10
+ const cart = createCart();
11
+ cart.add(product);
12
+ const result = await checkout(cart, paymentMethod);
13
+ expect(result.status).toBe("confirmed");
14
+ });
15
+ ```
16
+
17
+ Characteristics:
18
+
19
+ - Tests behavior users/callers care about
20
+ - Uses public API only
21
+ - Survives internal refactors
22
+ - Describes WHAT, not HOW
23
+ - One logical assertion per test
24
+
25
+ ## Bad Tests
26
+
27
+ **Implementation-detail tests**: Coupled to internal structure.
28
+
29
+ ```typescript
30
+ // BAD: Tests implementation details
31
+ test("checkout calls paymentService.process", async () => {
32
+ const mockPayment = jest.mock(paymentService);
33
+ await checkout(cart, payment);
34
+ expect(mockPayment.process).toHaveBeenCalledWith(cart.total);
35
+ });
36
+ ```
37
+
38
+ Red flags:
39
+
40
+ - Mocking internal collaborators
41
+ - Testing private methods
42
+ - Asserting on call counts/order
43
+ - Test breaks when refactoring without behavior change
44
+ - Test name describes HOW not WHAT
45
+ - Verifying through external means instead of interface
46
+
47
+ ```typescript
48
+ // BAD: Bypasses interface to verify
49
+ test("createUser saves to database", async () => {
50
+ await createUser({ name: "Alice" });
51
+ const row = await db.query("SELECT * FROM users WHERE name = ?", ["Alice"]);
52
+ expect(row).toBeDefined();
53
+ });
54
+
55
+ // GOOD: Verifies through interface
56
+ test("createUser makes user retrievable", async () => {
57
+ const user = await createUser({ name: "Alice" });
58
+ const retrieved = await getUser(user.id);
59
+ expect(retrieved.name).toBe("Alice");
60
+ });
61
+ ```
62
+
63
+ **Tautological tests**: Expected value restates the implementation, so the test passes by construction.
64
+
65
+ ```typescript
66
+ // BAD: Expected value is recomputed the way the code computes it
67
+ test("calculateTotal sums line items", () => {
68
+ const items = [{ price: 10 }, { price: 5 }];
69
+ const expected = items.reduce((sum, i) => sum + i.price, 0);
70
+ expect(calculateTotal(items)).toBe(expected);
71
+ });
72
+
73
+ // GOOD: Expected value is an independent, known literal
74
+ test("calculateTotal sums line items", () => {
75
+ expect(calculateTotal([{ price: 10 }, { price: 5 }])).toBe(15);
76
+ });
77
+ ```
@@ -15308,13 +15308,10 @@ function assertRegisteredHostName(host) {
15308
15308
  }
15309
15309
  throw new Error(`unregistered host: ${host}`);
15310
15310
  }
15311
- var PRIVATE_COMPAT_ENV, DEFAULT_ROLE_TURN_HOST, HOST_DESCRIPTIONS, HEADLESS_HOST_DESCRIPTIONS;
15311
+ var DEFAULT_ROLE_TURN_HOST, HOST_DESCRIPTIONS, HEADLESS_HOST_DESCRIPTIONS;
15312
15312
  var init_host_descriptions = __esm({
15313
15313
  "src/host-descriptions.ts"() {
15314
15314
  "use strict";
15315
- PRIVATE_COMPAT_ENV = Object.fromEntries(
15316
- ["CLAUDE", "CURSOR", "CODEX"].flatMap((vendor) => ["SKILLS", "RULES", "AGENTS", "MCPS", "HOOKS", "SESSIONS"].map((kind) => [`GROK_${vendor}_${kind}_ENABLED`, "false"]))
15317
- );
15318
15315
  DEFAULT_ROLE_TURN_HOST = "pi";
15319
15316
  HOST_DESCRIPTIONS = Object.freeze({
15320
15317
  /** Operator home `~/.grok`, native session/load resume, `agent [--model X] stdio`. */
@@ -15327,12 +15324,7 @@ var init_host_descriptions = __esm({
15327
15324
  }),
15328
15325
  modelPassing: "argv",
15329
15326
  boundResume: "session/load",
15330
- sessionBindingFile: "grok-acp-session.json",
15331
- childEnv: Object.freeze({
15332
- ...PRIVATE_COMPAT_ENV,
15333
- GROK_MEMORY: "0",
15334
- GROK_SUBAGENTS: "0"
15335
- })
15327
+ sessionBindingFile: "grok-acp-session.json"
15336
15328
  }),
15337
15329
  /**
15338
15330
  * Operator home `~/.hermes`, native session/load resume, `acp` subcommand.
@@ -15351,7 +15343,6 @@ var init_host_descriptions = __esm({
15351
15343
  modelPassing: "set_model",
15352
15344
  boundResume: "session/load",
15353
15345
  sessionBindingFile: "hermes-acp-session.json",
15354
- childEnv: Object.freeze({}),
15355
15346
  seatProfileSoul: Object.freeze({
15356
15347
  flag: "-p",
15357
15348
  namePrefix: "ak-",
@@ -15372,12 +15363,7 @@ var init_host_descriptions = __esm({
15372
15363
  // Intermediate assistant/tool/system events require verbose with stream-json.
15373
15364
  "--verbose",
15374
15365
  "--permission-mode",
15375
- "bypassPermissions",
15376
- // Empty sources: no user/project/local operator surface (envelope owns materials).
15377
- "--setting-sources",
15378
- "",
15379
- // With adapter-supplied --mcp-config only (AK relay); drops operator + claude.ai MCP.
15380
- "--strict-mcp-config"
15366
+ "bypassPermissions"
15381
15367
  ]),
15382
15368
  promptFlag: "-p",
15383
15369
  modelFlag: "--model",
@@ -24252,9 +24238,7 @@ async function readPackageMaterial(relativePath) {
24252
24238
  }
24253
24239
  async function joinPackageMaterials(relativePaths) {
24254
24240
  const chunks = [];
24255
- for (const relativePath of relativePaths) {
24256
- chunks.push(await readPackageMaterial(relativePath));
24257
- }
24241
+ for (const relativePath of relativePaths) chunks.push(await readPackageMaterial(relativePath));
24258
24242
  return chunks.join("\n\n");
24259
24243
  }
24260
24244
  var packageRootUrl, MAIN_ROLE_SESSION_MATERIALS, GATEKEEPER_SESSION_MATERIALS;
@@ -24285,6 +24269,8 @@ __export(auditor_soul_exports, {
24285
24269
  AUDITOR_SESSION_MATERIALS: () => AUDITOR_SESSION_MATERIALS,
24286
24270
  AUDITOR_SOUL_ROLES: () => AUDITOR_SOUL_ROLES,
24287
24271
  isAuditorSoulRole: () => isAuditorSoulRole,
24272
+ loadAuditorReferenceMaterials: () => loadAuditorReferenceMaterials,
24273
+ loadAuditorReferenceMaterialsFromSubjectInput: () => loadAuditorReferenceMaterialsFromSubjectInput,
24288
24274
  loadAuditorSoul: () => loadAuditorSoul,
24289
24275
  loadAuditorSoulFromSubjectInput: () => loadAuditorSoulFromSubjectInput,
24290
24276
  resolveAuditorSubject: () => resolveAuditorSubject
@@ -24311,11 +24297,18 @@ async function loadAuditorSoul(role) {
24311
24297
  if (soul.trim().length === 0) {
24312
24298
  throw new Error(`The ${role} auditor Soul is blank`);
24313
24299
  }
24314
- return joinPackageMaterials(materials);
24300
+ return soul;
24301
+ }
24302
+ function loadAuditorReferenceMaterials(role) {
24303
+ const soulPath = auditorSoulRelativePath(role);
24304
+ return joinPackageMaterials(AUDITOR_SESSION_MATERIALS[role].filter((path) => path !== soulPath));
24315
24305
  }
24316
24306
  async function loadAuditorSoulFromSubjectInput(raw) {
24317
24307
  return loadAuditorSoul(resolveAuditorSubject(raw));
24318
24308
  }
24309
+ function loadAuditorReferenceMaterialsFromSubjectInput(raw) {
24310
+ return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
24311
+ }
24319
24312
  var AUDITOR_SOUL_ROLES, AK_ROLE_AUDITOR_SUBJECT_ENV, AK_ROLE_AUDITOR_SOURCE_RUN_ENV, AUDITOR_SESSION_MATERIALS;
24320
24313
  var init_auditor_soul = __esm({
24321
24314
  "src/auditor-soul.ts"() {
@@ -25,18 +25,29 @@ async function readPackageMaterial(relativePath) {
25
25
  }
26
26
  async function joinPackageMaterials(relativePaths) {
27
27
  const chunks = [];
28
- for (const relativePath of relativePaths) {
29
- chunks.push(await readPackageMaterial(relativePath));
30
- }
28
+ for (const relativePath of relativePaths) chunks.push(await readPackageMaterial(relativePath));
31
29
  return chunks.join("\n\n");
32
30
  }
31
+ function roleSoulPath(role, materials) {
32
+ const suffix = `/souls/${role}.md`;
33
+ const path = materials.find((candidate) => `/${candidate}`.endsWith(suffix));
34
+ if (path === void 0) throw new Error(`session materials omit the ${role} Soul`);
35
+ return path;
36
+ }
37
+ async function loadSeparatedSessionPart(role, materials, part) {
38
+ const soul = roleSoulPath(role, materials);
39
+ return part === "soul" ? readPackageMaterial(soul) : joinPackageMaterials(materials.filter((path) => path !== soul));
40
+ }
33
41
  const MAIN_ROLE_SESSION_MATERIALS = {
34
42
  ...Object.fromEntries(
35
43
  PUBLIC_ROLE_RECORDS.map((record) => [record.role, record.sessionMaterials])
36
44
  )
37
45
  };
38
46
  function loadMainRoleSessionMaterials(role) {
39
- return joinPackageMaterials(MAIN_ROLE_SESSION_MATERIALS[role]);
47
+ return loadSeparatedSessionPart(role, MAIN_ROLE_SESSION_MATERIALS[role], "soul");
48
+ }
49
+ function loadMainRoleReferenceMaterials(role) {
50
+ return loadSeparatedSessionPart(role, MAIN_ROLE_SESSION_MATERIALS[role], "references");
40
51
  }
41
52
  const GATEKEEPER_SESSION_MATERIALS = {
42
53
  // #639: single authority — the public gatekeeper record owns the province list.
@@ -45,13 +56,14 @@ const GATEKEEPER_SESSION_MATERIALS = {
45
56
  notary: NOTARY_SESSION_MATERIALS
46
57
  };
47
58
  function loadGatekeeperSessionMaterials(role) {
48
- return joinPackageMaterials(GATEKEEPER_SESSION_MATERIALS[role]);
59
+ return loadSeparatedSessionPart(role, GATEKEEPER_SESSION_MATERIALS[role], "soul");
49
60
  }
50
61
  export {
51
62
  GATEKEEPER_SESSION_MATERIALS,
52
63
  MAIN_ROLE_SESSION_MATERIALS,
53
64
  joinPackageMaterials,
54
65
  loadGatekeeperSessionMaterials,
66
+ loadMainRoleReferenceMaterials,
55
67
  loadMainRoleSessionMaterials,
56
68
  readPackageMaterial,
57
69
  resolvePackageRootDir
@@ -31,9 +31,14 @@ import { JUDGE_OUTPUT_TOOL_NAME } from "../src/package-contracts/judge-output.ts
31
31
  import { readOAuthKeepaliveProviders } from "../src/oauth-keepalive.ts";
32
32
  import {
33
33
  formatNavigatorRoleHelp,
34
+ type RoleRuntimeDependencies,
34
35
  } from "../src/role-runtime.ts";
35
36
  import { loadAuditorSoulFromSubjectInput } from "../src/auditor-soul.ts";
36
- import { loadGatekeeperSessionMaterials, loadMainRoleSessionMaterials } from "../src/session-opening-materials.ts";
37
+ import { loadPackagedRoleReferenceMaterials } from "../src/role-runtime-dependencies.ts";
38
+ import {
39
+ loadGatekeeperSessionMaterials,
40
+ loadMainRoleSessionMaterials,
41
+ } from "../src/session-opening-materials.ts";
37
42
  const extensionPath = fileURLToPath(import.meta.url);
38
43
  const packageRoot = fileURLToPath(new URL("..", import.meta.url));
39
44
  const navigatorRoutePlaybookPath = fileURLToPath(new URL("../resources/navigator-route-playbook.md", import.meta.url));
@@ -105,12 +110,11 @@ export async function loadNavigatorWorkContext(
105
110
  });
106
111
  }
107
112
 
108
- export default function roleRuntime(pi: ExtensionAPI): void {
109
- const oauthKeepaliveProviders = readOAuthKeepaliveProviders();
110
- registerNavigatorModelCommand(pi);
113
+ export function createPiRoleRuntimeDependencies(pi: ExtensionAPI): RoleRuntimeDependencies {
111
114
  const navigatorSessionFactory = createNativeNavigatorSessionFactory();
112
- createPiRoleRuntimeExtension({
115
+ return {
113
116
  packageRoot,
117
+ loadRoleReferenceMaterials: loadPackagedRoleReferenceMaterials,
114
118
  loadJudgeSoul: () => loadMainRoleSessionMaterials("judge"),
115
119
  loadFixerSoul: () => loadMainRoleSessionMaterials("fixer"),
116
120
  loadFixPacket: (path) => readFile(path, "utf8"),
@@ -167,7 +171,13 @@ export default function roleRuntime(pi: ExtensionAPI): void {
167
171
  }
168
172
  return loadHomeCanonicalSkillBinding(name);
169
173
  },
170
- }, {
174
+ };
175
+ }
176
+
177
+ export default function roleRuntime(pi: ExtensionAPI): void {
178
+ const oauthKeepaliveProviders = readOAuthKeepaliveProviders();
179
+ registerNavigatorModelCommand(pi);
180
+ createPiRoleRuntimeExtension(createPiRoleRuntimeDependencies(pi), {
171
181
  transcriptFromContext,
172
182
  oauthKeepalive: { providers: oauthKeepaliveProviders },
173
183
  })(pi);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akagilnc/pi-workflow-roles",
3
- "version": "0.1.4444",
3
+ "version": "0.1.4489",
4
4
  "description": "Soul-bound workflow roles for Pi",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "ak-methods",
3
+ "version": "0.0.0",
4
+ "description": "ak-roles packaged role method skills"
5
+ }
@@ -1,4 +1,4 @@
1
- import { chmod, copyFile, mkdir, readFile, writeFile } from "node:fs/promises";
1
+ import { chmod, copyFile, cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
2
2
  import { dirname, join, resolve } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { build } from "esbuild";
@@ -200,6 +200,11 @@ export async function buildPackageArtifacts() {
200
200
  await buildAcpProductionHost();
201
201
  await buildHeadlessProductionHost();
202
202
  await buildMigrateBookTopology();
203
+ const pluginDir = join("dist", "method-host-plugin");
204
+ await rm(pluginDir, { recursive: true, force: true });
205
+ await mkdir(pluginDir, { recursive: true });
206
+ await cp("resources/method-host-plugin/.claude-plugin", join(pluginDir, ".claude-plugin"), { recursive: true });
207
+ await cp("resources/methods", join(pluginDir, "skills"), { recursive: true });
203
208
  }
204
209
 
205
210
  const isMain =
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * One ACP host description. Every host-specific value the generic ACP adapter
3
- * needs — binary location, argv shape, resume verb, binding filename, child env,
3
+ * needs — binary location, argv shape, resume verb, binding filename,
4
4
  * optional seat-profile soul — is data here; the lifecycle in role-turn-host.ts
5
5
  * stays one copy (#732).
6
6
  */
@@ -30,7 +30,6 @@ export type AcpHostDescription = Readonly<{
30
30
  boundResume: "session/load" | "session/new";
31
31
  /** Durable ACP binding filename written beside the session principal. */
32
32
  sessionBindingFile: string;
33
- childEnv: Readonly<Record<string, string>>;
34
33
  /**
35
34
  * When set, the production factory ensures a seat profile whose SOUL.md is a
36
35
  * symlink to the packaged role soul, and prefixes argv with `flag <name>`.
@@ -44,8 +43,7 @@ export function resolveAcpBinary(description: AcpHostDescription, operatorHome:
44
43
  return join(operatorHome, ...description.binaryFromHome);
45
44
  }
46
45
 
47
- /** Stdio argv: optional profile flag, thinking flag (before the subcommand),
48
- * prefix, optional model flag pair, suffix. */
46
+ /** Stdio argv: optional profile flag, thinking flag, prefix, model, suffix. */
49
47
  export function acpStdioArgs(
50
48
  description: AcpHostDescription,
51
49
  model?: { readonly model?: string; readonly thinking?: string },
@@ -55,7 +55,6 @@ export function createProductionAcpRoleTurnHost(options: ProductionAcpHostOption
55
55
  const { packageRoot, principalAuthority, description, hostName } = options;
56
56
  const env: NodeJS.ProcessEnv = {
57
57
  ...process.env,
58
- ...description.childEnv,
59
58
  AK_PACKAGE_ROOT: packageRoot,
60
59
  };
61
60
 
@@ -85,10 +85,19 @@ export async function loadAuditorSoul(role: AuditorSoulRole): Promise<string> {
85
85
  if (soul.trim().length === 0) {
86
86
  throw new Error(`The ${role} auditor Soul is blank`);
87
87
  }
88
- return joinPackageMaterials(materials);
88
+ return soul;
89
+ }
90
+
91
+ export function loadAuditorReferenceMaterials(role: AuditorSoulRole): Promise<string> {
92
+ const soulPath = auditorSoulRelativePath(role);
93
+ return joinPackageMaterials(AUDITOR_SESSION_MATERIALS[role].filter((path) => path !== soulPath));
89
94
  }
90
95
 
91
96
  /** Runtime loader: subject input decides which soul file to assemble. */
92
97
  export async function loadAuditorSoulFromSubjectInput(raw?: string): Promise<string> {
93
98
  return loadAuditorSoul(resolveAuditorSubject(raw));
94
99
  }
100
+
101
+ export function loadAuditorReferenceMaterialsFromSubjectInput(raw?: string): Promise<string> {
102
+ return loadAuditorReferenceMaterials(resolveAuditorSubject(raw));
103
+ }
@@ -90,6 +90,8 @@ export function headlessTurnArgs(options: {
90
90
  readonly effort?: string;
91
91
  /** Fresh session: pass as session id. Resume: pass as resume id. */
92
92
  readonly session: { readonly kind: "new"; readonly id: string } | { readonly kind: "resume"; readonly id: string };
93
+ /** Packaged method plugin dir (`--plugin-dir`). */
94
+ readonly pluginDir?: string;
93
95
  }): string[] {
94
96
  const { description } = options;
95
97
  const args: string[] = [
@@ -100,6 +102,7 @@ export function headlessTurnArgs(options: {
100
102
  description.jsonSchemaFlag,
101
103
  JSON.stringify(options.jsonSchema),
102
104
  ];
105
+ if (options.pluginDir) args.push("--plugin-dir", options.pluginDir);
103
106
  if (options.mcpConfigPath !== undefined && options.mcpConfigPath !== "") {
104
107
  args.push(description.mcpConfigFlag, options.mcpConfigPath);
105
108
  }
@@ -422,9 +425,7 @@ export function codexTurnArgs(options: {
422
425
 
423
426
  // JSONL event stream: thread_id + final agent_message + turn.completed/failed.
424
427
  args.push("--json");
425
- // Operator config/MCP off; auth still uses CODEX_HOME (official).
426
- // Project/system config and AGENTS.md have no official suppression switch.
427
- args.push("--ignore-user-config", "--ignore-rules");
428
+ // Operator config/skills stay open (#922 host-native-loader). Auth uses CODEX_HOME.
428
429
  const roots = (options.writableRoots ?? []).filter((root) => root !== "");
429
430
  if (roots.length > 0) {
430
431
  // Resume has no --add-dir; the config key keeps extra roots available on both paths.