@sangyaahub/pi-marg 1.0.0

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 (71) hide show
  1. package/.mcp.json +12 -0
  2. package/.omp-plugin/marketplace.json +42 -0
  3. package/BRAND.md +25 -0
  4. package/CHANGELOG.md +11 -0
  5. package/CODE_OF_CONDUCT.md +9 -0
  6. package/CONTRIBUTING.md +11 -0
  7. package/LICENSE +21 -0
  8. package/MODEL-SETUP.md +73 -0
  9. package/PUBLISHING.md +53 -0
  10. package/README.md +191 -0
  11. package/SECURITY.md +11 -0
  12. package/SUPPORT.md +7 -0
  13. package/adapters/omp/extensions/approval-guard.ts +43 -0
  14. package/adapters/omp/extensions/model-router.ts +56 -0
  15. package/adapters/omp/extensions/runtime-capabilities.ts +24 -0
  16. package/adapters/pi/extensions/approval-guard.ts +39 -0
  17. package/adapters/pi/extensions/model-router.ts +61 -0
  18. package/adapters/pi/extensions/runtime-capabilities.ts +25 -0
  19. package/adapters/pi/extensions/workflow-bootstrap.ts +7 -0
  20. package/adapters/pi/prompts/auto-close.md +11 -0
  21. package/adapters/pi/prompts/auto-commit.md +7 -0
  22. package/adapters/pi/prompts/auto-models.md +12 -0
  23. package/adapters/pi/prompts/auto-reset.md +8 -0
  24. package/adapters/pi/prompts/auto-review.md +11 -0
  25. package/adapters/pi/prompts/auto-runtime.md +13 -0
  26. package/adapters/pi/prompts/auto-status.md +17 -0
  27. package/adapters/pi/prompts/auto.md +12 -0
  28. package/agents/auto-builder.md +10 -0
  29. package/agents/auto-business-analyst.md +9 -0
  30. package/agents/auto-debugger.md +10 -0
  31. package/agents/auto-intake.md +10 -0
  32. package/agents/auto-lessons-writer.md +10 -0
  33. package/agents/auto-qa.md +9 -0
  34. package/agents/auto-reviewer.md +9 -0
  35. package/agents/auto-security-reviewer.md +9 -0
  36. package/agents/auto-strategist.md +10 -0
  37. package/assets/brand/sangyaa-mark.png +0 -0
  38. package/assets/pi-marg-banner-source.html +106 -0
  39. package/assets/pi-marg-banner.png +0 -0
  40. package/commands/auto-close.md +11 -0
  41. package/commands/auto-commit.md +7 -0
  42. package/commands/auto-models.md +12 -0
  43. package/commands/auto-reset.md +8 -0
  44. package/commands/auto-review.md +11 -0
  45. package/commands/auto-runtime.md +13 -0
  46. package/commands/auto-status.md +17 -0
  47. package/commands/auto.md +12 -0
  48. package/core/approval-policy.ts +109 -0
  49. package/core/model-routing.ts +348 -0
  50. package/core/runtime-capabilities.ts +77 -0
  51. package/core/workflow-policy.ts +3 -0
  52. package/package.json +84 -0
  53. package/rules/auto-mode.md +32 -0
  54. package/scripts/check-prerequisites.sh +37 -0
  55. package/scripts/install.sh +74 -0
  56. package/scripts/setup-codegraph.sh +62 -0
  57. package/scripts/validate.sh +75 -0
  58. package/skills/auto-mode-addons/SKILL.md +15 -0
  59. package/skills/auto-mode-addons/references/cost-control.md +24 -0
  60. package/skills/auto-mode-addons/references/hindsight.md +54 -0
  61. package/skills/auto-mode-addons/references/language-skills.md +54 -0
  62. package/skills/auto-mode-addons/references/ponytail.md +41 -0
  63. package/skills/auto-mode-router/SKILL.md +22 -0
  64. package/skills/auto-mode-router/references/intake-and-state.md +124 -0
  65. package/skills/auto-mode-router/references/models-and-tools.md +74 -0
  66. package/skills/auto-mode-router/references/native-omp-runtime.md +88 -0
  67. package/skills/auto-mode-router/references/native-pi-runtime.md +52 -0
  68. package/skills/auto-mode-router/references/routing-matrix.md +99 -0
  69. package/skills/auto-mode-router/references/session-ledger.md +92 -0
  70. package/skills/codegraph-first/SKILL.md +34 -0
  71. package/skills/session-lessons/SKILL.md +34 -0
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ mode="dry-run"
5
+ repo_path="${PWD}"
6
+
7
+ if [[ "${1:-}" == "--apply" ]]; then
8
+ mode="apply"
9
+ shift
10
+ fi
11
+
12
+ if [[ $# -gt 1 ]]; then
13
+ echo "Usage: $0 [--apply] [repository-path]" >&2
14
+ exit 2
15
+ fi
16
+
17
+ if [[ $# -eq 1 ]]; then
18
+ repo_path="$1"
19
+ fi
20
+
21
+ if [[ ! -d "${repo_path}" ]]; then
22
+ echo "Repository path is not a directory: ${repo_path}" >&2
23
+ exit 1
24
+ fi
25
+
26
+ repo_root="$(git -C "${repo_path}" rev-parse --show-toplevel 2>/dev/null || true)"
27
+ if [[ -z "${repo_root}" ]]; then
28
+ echo "Not a Git repository: ${repo_path}" >&2
29
+ exit 1
30
+ fi
31
+
32
+ echo "Repository: ${repo_root}"
33
+
34
+ if [[ "${mode}" == "dry-run" ]]; then
35
+ if command -v codegraph >/dev/null 2>&1; then
36
+ echo "[ok] CodeGraph CLI is installed"
37
+ else
38
+ echo "[would install] npm install -g @colbymchenry/codegraph@latest"
39
+ fi
40
+ if [[ -d "${repo_root}/.codegraph" ]]; then
41
+ echo "[would verify] codegraph status \"${repo_root}\""
42
+ else
43
+ echo "[would initialize] codegraph init \"${repo_root}\""
44
+ fi
45
+ echo "Run $0 --apply \"${repo_root}\" to make these changes."
46
+ exit 0
47
+ fi
48
+
49
+ if ! command -v codegraph >/dev/null 2>&1; then
50
+ if ! command -v npm >/dev/null 2>&1; then
51
+ echo "npm is required to install CodeGraph." >&2
52
+ exit 1
53
+ fi
54
+ npm install -g @colbymchenry/codegraph@latest
55
+ fi
56
+
57
+ if [[ ! -d "${repo_root}/.codegraph" ]]; then
58
+ codegraph init "${repo_root}"
59
+ fi
60
+
61
+ codegraph status "${repo_root}"
62
+ echo "CodeGraph is ready. Restart the active Pi or OMP session if this is the first installation so its integration can be detected."
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
+ package_root="$(cd "${script_dir}/.." && pwd)"
6
+ build_dir="$(mktemp -d)"
7
+ trap 'rm -rf "${build_dir}"' EXIT
8
+
9
+ cd "${package_root}"
10
+
11
+ for script in scripts/*.sh; do
12
+ bash -n "${script}"
13
+ done
14
+
15
+ bun -e '
16
+ import { existsSync } from "node:fs";
17
+ const packageJson = await Bun.file("package.json").json();
18
+ const marketplace = await Bun.file(".omp-plugin/marketplace.json").json();
19
+ if (packageJson.name !== "@sangyaahub/pi-marg") throw new Error("Unexpected package name");
20
+ if (packageJson.version !== "1.0.0") throw new Error("package.json must be v1.0.0");
21
+ if (packageJson.license !== "MIT") throw new Error("package.json must declare MIT");
22
+ if (packageJson.author !== "Sangyaa") throw new Error("Unexpected package author");
23
+ if (!packageJson.keywords?.includes("pi-package")) throw new Error("Pi catalog keyword is missing");
24
+ if (marketplace.name !== "pi-marg-marketplace") throw new Error("Unexpected marketplace name");
25
+ if (marketplace.metadata?.version !== packageJson.version) throw new Error("Marketplace version mismatch");
26
+ if (marketplace.plugins?.[0]?.version !== packageJson.version) throw new Error("Plugin version mismatch");
27
+ if (marketplace.plugins?.[0]?.name !== packageJson.name.split("/").at(-1)) throw new Error("Plugin/package name mismatch");
28
+ if (marketplace.plugins?.[0]?.source !== "./") throw new Error("OMP local source must begin with ./");
29
+ for (const relativePath of [
30
+ ...(packageJson.pi?.extensions ?? []),
31
+ ...(packageJson.pi?.skills ?? []),
32
+ ...(packageJson.pi?.prompts ?? []),
33
+ ...(packageJson.omp?.extensions ?? []),
34
+ ]) {
35
+ if (!existsSync(relativePath)) {
36
+ throw new Error(`Manifest path does not exist: ${relativePath}`);
37
+ }
38
+ }
39
+ const license = await Bun.file("LICENSE").text();
40
+ if (!license.includes("MIT License") || !license.includes("Copyright (c) 2026 Sangyaa and PiMarg contributors")) {
41
+ throw new Error("LICENSE is not the expected MIT license");
42
+ }
43
+ const demo = await Bun.file("demo/pi-marg-v1.0.html").text();
44
+ if (!demo.includes("PiMarg") || !demo.includes("v1.0")) {
45
+ throw new Error("Demo branding/version mismatch");
46
+ }
47
+ if (!existsSync("assets/pi-marg-banner.png") || !existsSync("assets/brand/sangyaa-mark.png")) {
48
+ throw new Error("PiMarg brand assets are missing");
49
+ }
50
+ const readme = await Bun.file("README.md").text();
51
+ if (!readme.includes("# PiMarg") || !readme.includes("sangyaahub/pi-marg")) {
52
+ throw new Error("README branding or install target mismatch");
53
+ }
54
+ for await (const path of new Bun.Glob("skills/*/SKILL.md").scan(".")) {
55
+ const text = await Bun.file(path).text();
56
+ if (!text.startsWith("---\n") || !/\nname:\s*\S+/.test(text) || !/\ndescription:\s*.+/.test(text)) {
57
+ throw new Error(`Invalid skill frontmatter: ${path}`);
58
+ }
59
+ }
60
+ for await (const path of new Bun.Glob("**/*").scan({ cwd: ".", onlyFiles: true })) {
61
+ if (path === "scripts/validate.sh") continue;
62
+ if (/\.(?:png|jpe?g|gif|webp)$/i.test(path)) continue;
63
+ const text = await Bun.file(path).text();
64
+ if (text.includes("*** Begin Patch") || text.includes("*** Add File:")) {
65
+ throw new Error(`Patch marker leaked into artifact: ${path}`);
66
+ }
67
+ }
68
+ console.log("[ok] manifests, paths, MIT license, demo, and skill frontmatter");
69
+ '
70
+
71
+ bun build core/*.ts adapters/pi/extensions/*.ts adapters/omp/extensions/*.ts \
72
+ --outdir "${build_dir}" --target bun --external typebox >/dev/null
73
+
74
+ echo "[ok] TypeScript core and adapters compile"
75
+ echo "[ok] shell scripts parse"
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: auto-mode-addons
3
+ description: Route optional PiMarg support for code simplification, approved persistent memory, language-specific guidance, and cost control on Pi or OMP. Use after intake when Ponytail, Hindsight/local memory, Go/Python/TypeScript guidance, or lower-cost routing is requested or configured.
4
+ ---
5
+
6
+ # PiMarg Add-ons
7
+
8
+ Load only the reference needed for the active task:
9
+
10
+ - For minimal implementation or an over-engineering review, read [ponytail.md](references/ponytail.md).
11
+ - For runtime-specific Hindsight memory or backup policy, read [hindsight.md](references/hindsight.md).
12
+ - For Go, Python, or TypeScript guidance, read [language-skills.md](references/language-skills.md).
13
+ - For model and token budget decisions, read [cost-control.md](references/cost-control.md).
14
+
15
+ An add-on supplies constraints, memory, or evidence. The primary Compound Engineering, Superpowers, or GSD spine still owns task state and the authoritative plan. Verify the upstream capability is installed and discovered before saying it ran.
@@ -0,0 +1,24 @@
1
+ # Cost control
2
+
3
+ Spend frontier tokens where they change the decision, not on mechanical work.
4
+
5
+ ```text
6
+ A discovery frontier, bounded context, one decision artifact
7
+ C plan review different frontier model, plan + risks only
8
+ B implementation mid-layer/included model, approved plan + CodeGraph context
9
+ D code review different mid-layer model, diff + tests + acceptance criteria
10
+ ```
11
+
12
+ Rules:
13
+
14
+ - Use `auto_model_route catalog` at selection time; never maintain a static version list.
15
+ - Prefer Cursor Composer or a zero-metered/included Cursor entry for routine B execution when quality is sufficient. “Zero-metered” does not mean unlimited or free; check plan quotas.
16
+ - Use Devin for bounded, parallelizable execution with explicit acceptance criteria and an ACU/session limit. Creating a session is a `post-web` action.
17
+ - Keep C focused on the plan, decisions, and highest-cost risks. Keep D focused on the diff, affected contracts, and test evidence.
18
+ - Use CodeGraph to retrieve surgical source context instead of sending whole directories.
19
+ - Keep Hindsight recall at `low` or 512 tokens by default. Increase only when missing memory measurably causes rework.
20
+ - Use checkpoint/rewind only around a genuinely disposable research/debug branch; its report should preserve the evidence while removing noisy transcript context.
21
+ - Keep the advisor off for routine low-risk work. When enabled, use a cheaper distinct reviewer that can catch the targeted failure mode, then verify `/advisor status` usage.
22
+ - Reuse provider prompt caches when the active Pi/OMP route supports them; keep stable instructions at the front and variable task data later.
23
+ - Escalate B or D to a frontier model only after a mid-layer attempt fails a concrete check or the change is high risk.
24
+ - Record per-stage provider, model, effort, observed outcome, and—when available—usage. Tune from real task cost, not token price alone.
@@ -0,0 +1,54 @@
1
+ # Hindsight memory and backup
2
+
3
+ Use Hindsight only through an integration the active runtime actually exposes. `auto_runtime_status` must detect the relevant memory tools before the workflow claims recall or retention occurred.
4
+
5
+ ## Configure securely
6
+
7
+ ### OMP
8
+
9
+ OMP provides a native Hindsight backend. Use `/settings` or OMP configuration:
10
+
11
+ ```yaml
12
+ memory:
13
+ backend: hindsight
14
+ hindsight:
15
+ apiUrl: http://localhost:8888
16
+ scoping: per-project
17
+ autoRecall: true
18
+ autoRetain: false
19
+ recallBudget: low
20
+ recallMaxTokens: 512
21
+ ```
22
+
23
+ The default endpoint is local. When authentication is required, set `HINDSIGHT_API_TOKEN` in the user's secure environment; never put the token in this plugin, a prompt, the ledger, or a repository.
24
+
25
+ Use `per-project` for hard client/employer isolation. `per-project-tagged` may mix untagged global recall with project-tagged memory and therefore requires an explicit policy decision for sensitive work.
26
+
27
+ Run `/memory diagnose` after configuration. If `auto_runtime_status` does not show the native memory context plus the expected recall/retain/reflect tools, treat Hindsight as unavailable.
28
+
29
+ ### Pi
30
+
31
+ Pi does not receive OMP's native Hindsight backend from this package. Install or create a trusted Pi memory extension that exposes explicit `recall` and `retain` tools, configure it according to Hindsight's current documentation, and verify it with `auto_runtime_status`. Until those tools appear, keep memory off and use the local Markdown lesson only.
32
+
33
+ ## Session policy
34
+
35
+ - Job/client: default memory to off. Enable recall or retention only after confidentiality and retention policy allow the selected service and bank.
36
+ - Personal: recommend recall-only first; enable retention after the first successful diagnostic.
37
+ - At session start, recall only facts relevant to the confirmed context and repository.
38
+ - Treat recalled memory as heuristic and verify it against the current repository.
39
+ - At close, write `lessons.md` first, then retain only verified decisions, conventions, and the reusable lesson summary.
40
+ - Never retain secrets, credentials, raw client data, personal data, large source dumps, noisy transcripts, or unvalidated hypotheses.
41
+
42
+ Do not assume a `memory_edit` tool exists. Use Hindsight's supported UI/API for server-side deletion or correction, with the applicable approval gate.
43
+
44
+ ## Backup policy
45
+
46
+ For self-hosted PostgreSQL or pg0, create a consistent full backup with:
47
+
48
+ ```bash
49
+ hindsight-admin backup /secure-backups/hindsight-YYYY-MM-DD.zip
50
+ ```
51
+
52
+ Keep at least one encrypted copy on a different device or storage provider. Prefer a versioned Backblaze B2 or S3-compatible bucket for low-cost automation, or Google Drive for a simpler manual route. Uploading the copy requires `post-web` approval. Verify the archive and periodically test restoration into a fresh disposable schema or instance.
53
+
54
+ `hindsight-admin restore` deletes the target schema before import. Show the exact target and obtain `delete-remove` approval first. Use bank export/import for portability when supported, prefer a fresh target bank, and verify counts after import.
@@ -0,0 +1,54 @@
1
+ # Language skill routing
2
+
3
+ Load language guidance only after the repository language is observed. On existing repositories, detect this from CodeGraph's file/language summary, not a grep/glob crawl.
4
+
5
+ Use the smallest relevant subset. Do not install an entire large collection merely because one language is present.
6
+
7
+ ## Go
8
+
9
+ Repository: `https://github.com/samber/cc-skills-golang`
10
+
11
+ Suggested base:
12
+
13
+ ```bash
14
+ npx skills add samber/cc-skills-golang --skill golang-code-style
15
+ npx skills add samber/cc-skills-golang --skill golang-error-handling
16
+ npx skills add samber/cc-skills-golang --skill golang-testing
17
+ ```
18
+
19
+ Add concurrency, security, performance, or gopls skills only when that concern exists.
20
+
21
+ ## Python
22
+
23
+ Repository: `https://github.com/wshobson/agents`
24
+
25
+ Suggested base:
26
+
27
+ ```bash
28
+ npx skills add wshobson/agents --skill python-code-style
29
+ npx skills add wshobson/agents --skill python-type-safety
30
+ npx skills add wshobson/agents --skill python-testing-patterns
31
+ ```
32
+
33
+ Add async, packaging, performance, or error-handling guidance only when relevant.
34
+
35
+ ## TypeScript
36
+
37
+ Repositories: `https://github.com/wshobson/agents` and `https://github.com/cursor/plugins`
38
+
39
+ Suggested base:
40
+
41
+ ```bash
42
+ npx skills add cursor/plugins --skill typescript-best-practices
43
+ npx skills add wshobson/agents --skill javascript-testing-patterns
44
+ ```
45
+
46
+ Load `typescript-advanced-types` only when the change genuinely needs non-trivial type-level design; it is not a default style guide.
47
+
48
+ ## Stage rule
49
+
50
+ - Stage A: load architecture/style guidance only when it informs a material design decision.
51
+ - Stage B: load the base style and testing skills for languages in the actual edit scope.
52
+ - Stage C/D: load the relevant language review/testing guidance, not every build skill again.
53
+
54
+ These are community skills. Review the selected `SKILL.md`, repository activity, license, requested tools, and current skills.sh security signals before global installation. After installation, verify the exact skill appears in the active Pi or OMP inventory; otherwise treat it as unavailable.
@@ -0,0 +1,41 @@
1
+ # Ponytail integration
2
+
3
+ Ponytail is a supporting minimalism filter, not the task's planner.
4
+
5
+ ## Recommended placement
6
+
7
+ ```text
8
+ Stage A: understand the real need and code flow
9
+ ↓
10
+ Ponytail lite: challenge speculative scope or a new dependency
11
+ ↓
12
+ Stage B: Ponytail full while implementing the approved slice
13
+ ↓
14
+ tests pass
15
+ ↓
16
+ Stage D: ponytail-review on the diff, then normal correctness review
17
+ ```
18
+
19
+ Use CodeGraph first on an existing repository. Ponytail's ladder runs only after the relevant flow is understood:
20
+
21
+ 1. Skip a requirement that is genuinely unnecessary.
22
+ 2. Reuse an existing repository pattern.
23
+ 3. Prefer the standard library.
24
+ 4. Prefer a native platform feature.
25
+ 5. Prefer an already-installed dependency.
26
+ 6. Write the minimum correct code.
27
+
28
+ Keep `full` as the normal build setting. Use `lite` during architecture when the user should choose between the requested design and a smaller option. Avoid `ultra` for authentication, authorization, money, personal/client data, destructive behavior, concurrency, or migrations.
29
+
30
+ Never remove trust-boundary validation, data-loss handling, security controls, accessibility, acceptance behavior, or the smallest useful regression test. `ponytail-review` finds complexity only; it does not replace correctness or security review.
31
+
32
+ ## Installation
33
+
34
+ Ponytail publishes a Claude-compatible marketplace and a Pi package. For OMP's Claude-marketplace compatibility path:
35
+
36
+ ```bash
37
+ omp plugin marketplace add DietrichGebert/ponytail
38
+ omp plugin install --scope user ponytail@ponytail
39
+ ```
40
+
41
+ Restart OMP and verify `ponytail` plus `ponytail-review` appear. If the installed OMP release does not discover the compatibility package, use Ponytail's documented Pi install for the Pi harness or copy its instruction-only `AGENTS.md` policy; do not claim the OMP skill loaded until discovery succeeds.
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: auto-mode-router
3
+ description: Classify a new work request, select one development-method skill spine, route live stage models and tools on Pi or OMP, and maintain the PiMarg session ledger. Use at the start of each new substantive task; do not restart it for ordinary follow-ups.
4
+ ---
5
+
6
+ # PiMarg Router
7
+
8
+ Turn a user request into one controlled workflow.
9
+
10
+ 1. Read [intake-and-state.md](references/intake-and-state.md) and complete the intake stages in order.
11
+ 2. After the user selects mode 1–4, read [routing-matrix.md](references/routing-matrix.md) and select exactly one primary skill spine.
12
+ 3. Read [session-ledger.md](references/session-ledger.md), create the neutral Markdown ledger, and identify the selected spine's authoritative planning artifact.
13
+ 4. Read [models-and-tools.md](references/models-and-tools.md). Call `auto_model_route` with `action: catalog` and the confirmed work type, present the live choices, and save each required A/B/C/D selection. The runtime rejects A=C and B=D.
14
+ 5. Call `auto_runtime_status`. If it reports `OMP`, read [native-omp-runtime.md](references/native-omp-runtime.md); if it reports `Pi`, read [native-pi-runtime.md](references/native-pi-runtime.md). Record which advisor, task, review, checkpoint/rewind, code-intelligence, debugger, browser/desktop, security, and memory routes are actually available.
15
+ 6. For work types 2–6, load `codegraph-first` and pass its bootstrap gate before making repository-wide architecture or impact claims. CodeGraph owns those claims when available. LSP, AST, compiler, and repository-native tools may handle precise operations; missing CodeGraph must be recorded rather than concealed behind broad grep output.
16
+ 7. Load `auto-mode-addons` only for requested or configured Ponytail, Hindsight, language-specific, or cost-control support. An add-on never becomes a second workflow spine.
17
+ 8. Before each routed stage, call `auto_model_route` with `action: activate` for that stage. Verify installed skills and tools before invoking them; never imitate a missing capability while claiming it ran.
18
+ 9. Run A → C → B → conditional verification → D, adjusted by work type. Use an advisor only as an optional watcher, task fan-out only when a compatible tool exists and work is independent, and checkpoint/rewind only when the runtime provides their documented semantics. Keep decisions and evidence current.
19
+ 10. After D and any required security review pass, offer the runtime's local commit path (`omp commit` on OMP or a repository-native local commit on Pi); never include a push. Ask only when a missing choice materially changes the result or permission.
20
+ 11. Before final completion, load `session-lessons`. Run it once and only once for this session, then retain/learn the verified summary only when memory is available and approved.
21
+
22
+ The approval extension may block protected tool calls. Treat a block as a required user checkpoint, not as a reason to bypass the guard through another tool.
@@ -0,0 +1,124 @@
1
+ # Intake and session state
2
+
3
+ ## State machine
4
+
5
+ ```text
6
+ NEW
7
+ │
8
+ ▼
9
+ CONTEXT ─► TYPE ─► SKILL MODE ─► MODELS ─► RUNTIME ─► ADD-ONS ─► READY
10
+ ▲ │
11
+ └────────────────── clarify only ◄──── ACTIVE ◄─────┘
12
+ │
13
+ ▼
14
+ CLOSED
15
+ ```
16
+
17
+ Ask one intake stage at a time. A clear user prompt can support a proposed classification, but it does not remove the required confirmation.
18
+
19
+ ## Stage 1 — work context
20
+
21
+ Ask first:
22
+
23
+ > Is this for your job/client, or is it personal work?
24
+
25
+ Record exactly one:
26
+
27
+ - `job-client`: Do not add Sangyaa branding, name, logo, metadata, footer, or promotional language. Use the employer/client/project brand already in scope.
28
+ - `personal`: Existing project branding wins. Sangyaa branding is opt-in, never automatic.
29
+
30
+ Do not start code, research, or planning before this answer unless the user is asking only how Auto Mode itself works.
31
+
32
+ ## Stage 2 — work type
33
+
34
+ Infer the most likely type, state it plainly, and ask the user to confirm. If ambiguous, show the relevant choices only.
35
+
36
+ 1. New idea or development from scratch: brainstorming and analysis.
37
+ 2. New feature for an existing repository.
38
+ 3. Improve an existing feature in an existing repository.
39
+ 4. Proactive bug discovery or bug fix in an existing repository.
40
+ 5. Security review or security fixes.
41
+ 6. Thoughts, explanation, or another question about an existing repository or feature.
42
+ 7. Business, sales, or other non-technical analysis.
43
+
44
+ If one request contains multiple types, pick the type that owns the immediate outcome and record later types as follow-on phases. Do not open multiple workflow spines.
45
+
46
+ ## Stage 3 — skill mode
47
+
48
+ Ask:
49
+
50
+ > Which method should own this task: 1) Compound Engineering, 2) Superpowers, 3) GSD Core, or 4) choose the best one for me?
51
+
52
+ - Mode 1: use the Compound Engineering mapping for the confirmed work type.
53
+ - Mode 2: use the Superpowers mapping.
54
+ - Mode 3: first verify that GSD skills and their required tools are available in the active runtime. If not, explain the incompatibility and offer a supported alternative.
55
+ - Mode 4: choose one primary spine using the routing criteria. Explain the choice in one short sentence and ask for confirmation only if the trade-off is material.
56
+
57
+ ## Stage 4 — live model choices
58
+
59
+ Call `auto_model_route` with `action: catalog` and the confirmed work type. Present only selectors returned by the tool; do not type a remembered model ID.
60
+
61
+ The four roles are:
62
+
63
+ - A — thinking/discovery using a current Claude Fable/Opus, OpenAI Astra/Sol, or Grok 4.6-or-newer frontier model.
64
+ - B — coding/execution using a current Claude or OpenAI mid-layer model, Cursor Composer, a zero-metered Cursor/Devin route, native Devin SWE, or an external Devin MCP session.
65
+ - C — plan second-eye using the A frontier pool, but not the same underlying model selected for A.
66
+ - D — implementation/code second-eye using the B execution pool, but not the same underlying model selected for B.
67
+
68
+ Ask only for stages required by the current work type. Work types 2–3 normally use A → C → B → D. Type 4 uses A → B → D and adds C only for a non-trivial plan. Types 1, 6, and 7 use A → C. Type 5 uses A → C for review and adds B → D when fixes are authorized.
69
+
70
+ Use `action: select` for each answer. The active adapter saves exact selectors in session state and immediately activates the selected runtime model. Native `devin/swe-*` selectors behave like other models. An external Devin session requires `post-web` approval before creation.
71
+
72
+ ## Stage 5 — native runtime and supporting capabilities
73
+
74
+ Call `auto_runtime_status` before making a recommendation. Distinguish `available`, `enabled`, and `used`; a tool installed but gated off did not run.
75
+
76
+ For an existing repository, CodeGraph is mandatory. Verify the CLI and graph before any source reference.
77
+
78
+ Offer a compact recommended set and let the user change it:
79
+
80
+ - Orchestration: serial, direct `task` batch, or explicit `workflowz`; recommend serial for small/overlapping changes and task fan-out only for independent units.
81
+ - Advisor: off or supplemental watcher; recommend it for moderate/high-risk work when a distinct model is configured and its extra usage is acceptable. It never replaces C/D.
82
+ - Context pruning: use checkpoint/rewind only for a long disposable research or debugging branch, and only when both tools are available.
83
+ - Ponytail: off, lite, or full; recommend full for normal B implementation and `ponytail-review` before D correctness review.
84
+ - Memory: off, detected local memory, Hindsight recall-only, or Hindsight recall-and-retain; default job/client work to off until retention is permitted.
85
+ - Language skills: automatically detect Go, Python, and TypeScript in the actual scope, then load only installed relevant skills.
86
+ - Cost posture: economy, balanced, or quality; recommend balanced unless risk or user intent says otherwise.
87
+ - Verification: infer repository checks, DAP debugging, browser/desktop QA, and security review from the work type and affected surface. Let the user remove only gates whose consequence is understood.
88
+ - Collaboration: off by default. `/collab` and `/share` require `post-web` approval.
89
+
90
+ ## Session reuse
91
+
92
+ After intake, emit a compact conversational state block and save the same facts in the ledger:
93
+
94
+ ```text
95
+ [AUTO-MODE]
96
+ context: job-client | personal
97
+ type: 1..7
98
+ mode: 1..4
99
+ spine: compound-engineering | superpowers | gsd | none
100
+ models: A=<selector> B=<selector|n/a> C=<selector> D=<selector|n/a>
101
+ runtime: advisor=<off|available|on|unavailable> orchestration=<serial|task|workflowz> checkpoint=<off|available|used>
102
+ addons: ponytail=<off|lite|full> memory=<off|local|hindsight-recall|hindsight-retain> language=<names|none> cost=<economy|balanced|quality>
103
+ verification: tests=<planned|n/a> dap=<planned|n/a> ui=<browser|desktop|n/a> security=<planned|n/a>
104
+ collaboration: off | view-approved | write-approved
105
+ commit: not-ready | offered | created | skipped
106
+ codegraph: n/a | pending | ready | blocked
107
+ status: ready | active | blocked | completed | superseded
108
+ phase: intake | analysis | plan | build | verify | review | security | lessons | commit
109
+ ledger: <path>
110
+ ```
111
+
112
+ Reuse this state for normal follow-ups. Start over only when the user explicitly resets it or introduces a materially different outcome.
113
+
114
+ ## Availability check
115
+
116
+ Before declaring the task ready:
117
+
118
+ - Confirm the chosen skill appears in the active runtime's discovered skill inventory.
119
+ - Confirm any required tool or agent exists before dispatch.
120
+ - Call `auto_runtime_status` and record the exact optional capabilities that are available now.
121
+ - Confirm the repository exists for work types 2–6.
122
+ - For work types 2–6, load `codegraph-first`, verify the CLI, initialize `.codegraph/` if needed, and record `codegraph: ready` before source work.
123
+ - If a repository is missing, ask for its path; do not create or guess one.
124
+ - If a skill family is absent, offer installation instructions or a supported family. Never silently substitute while retaining the unavailable family's name.
@@ -0,0 +1,74 @@
1
+ # Models, agents, and tools
2
+
3
+ ## Live A/B/C/D routing
4
+
5
+ `auto_model_route` builds its catalog from the active runtime every time it is called: Pi uses scoped or authenticated available models, while OMP uses `ctx.models.list()`. Exact versions come from that live registry, not this document.
6
+
7
+ | Stage | Purpose | Eligible live groups | Normal agent and tools |
8
+ |---|---|---|---|
9
+ | A | Thinking/discovery | Claude Fable/Opus; OpenAI Astra/Sol; current Grok 4.6-or-newer | strategy skill; detected CodeGraph/LSP/AST tools, web for current facts; no implementation writes |
10
+ | C | Plan second-eye | Same frontier pool, excluding A's underlying model | independent reviewer; plan, decisions, risks, read-only evidence; optional detected watcher |
11
+ | B | Plan execution/coding | Claude Sonnet; OpenAI Terra/Luna/Codex-class; Cursor Composer; zero-metered Cursor/Devin routes; native Devin SWE; external Devin | builder/debugger method; detected code intelligence, tests, shell, and bounded task fan-out |
12
+ | D | Implementation/code second-eye | Same execution pool, excluding B's underlying model | detected review command or independent reviewer; diff, impact, contracts, tests/scanners, no fixes |
13
+
14
+ The extension compares normalized provider-independent identities, so the same model reached through Cursor and a direct provider still counts as the same choice. Prefer a different provider family as well when practical.
15
+
16
+ OMP stage agents and the sequential Pi flow both inherit the model activated in the main session. Before each stage, call `auto_model_route` with `action: activate`; never assume the model remained selected after a manual model change.
17
+
18
+ Intake and lessons use the runtime's inexpensive/default model when configured. Native `devin/swe-*` entries are ordinary runtime models. A separate external Devin option appears only when a Devin tool is detected and returns a delegation instruction.
19
+
20
+ ## Cross-family review
21
+
22
+ Prefer a reviewer from a different model family than the main implementer when risk or change size justifies it:
23
+
24
+ ```text
25
+ Codex builds ──► Claude reviews
26
+ Claude builds ─► Codex reviews
27
+ Cursor/Grok builds ─► strongest available Claude or Codex reviews
28
+ ```
29
+
30
+ This is a model separation, not a second workflow spine.
31
+
32
+ ## Multi-agent use
33
+
34
+ Use multiple agents only when tasks are independently writable or purely read-only.
35
+
36
+ - Parallelize repository exploration, research, and independent reviews.
37
+ - For implementation, define file ownership and dependencies first.
38
+ - Prefer isolated worktrees for parallel writes.
39
+ - Integrate and verify each result against the advancing canonical tree.
40
+ - Fall back to serial work after repeated collisions or broad overlapping edits.
41
+ - Never use a swarm merely to make a small task look more sophisticated.
42
+
43
+ On OMP, `workflowz` and `orchestrate` may request native multi-agent behavior. On Pi, parallel work requires a compatible detected task/subagent extension. Neither route overrides the primary skill spine, model separation, evidence ledger, or approval gates.
44
+
45
+ ## Native runtime gates
46
+
47
+ Call `auto_runtime_status` during intake. Follow [native-omp-runtime.md](native-omp-runtime.md) for OMP or [native-pi-runtime.md](native-pi-runtime.md) for Pi.
48
+
49
+ - Any advisor/watcher is supplemental and read-only; C/D remain required when their stage applies.
50
+ - Checkpoint/rewind may wrap disposable exploration only when the detected runtime documents those semantics.
51
+ - `auto-qa` runs after B and before D for affected browser/desktop flows or artifact inspection.
52
+ - A detected `security_scan` is used only when relevant; otherwise record the scanner/reviewer fallback.
53
+ - Detected memory recall/retain is used only after the context retention decision.
54
+ - A local commit is offered after acceptance, D, and required security gates pass; it never includes push.
55
+
56
+ ## Tool recommendations
57
+
58
+ - Repository understanding: CodeGraph MCP/CLI is the authority for architecture, flows, candidate scope, and impact on work types 2–6 when available. Detected LSP handles exact symbols/types/renames/diagnostics; detected AST tools handle bounded structural queries or previewable rewrites. If CodeGraph is unavailable, record repository-wide impact as not verified rather than replacing it with a broad text crawl.
59
+ - Verification: the repository's own tests, type checker, linter, formatter, build, and browser/simulator tools when relevant.
60
+ - Bug discovery: detected DAP/debug tooling for supported live runtime failures, browser/desktop QA for user flows, and static/test evidence for backend or library code.
61
+ - Security: detected `security_scan` when available, otherwise repository-native dependency audit, secret scan, SAST rules, configuration review, and source-to-sink inspection. Validate findings before changing code.
62
+ - Current business/market facts: web research with source links; keep external posting disabled until approved.
63
+
64
+ ## Provider recommendation for the user's accounts
65
+
66
+ - Cursor Composer or a zero-metered Cursor route: economical B/D work when present in the live catalog.
67
+ - Claude Fable/Opus: A/C product thinking, architecture, specification, and cross-family review.
68
+ - Claude Sonnet: B/D mid-layer implementation or review.
69
+ - OpenAI Astra/Sol: A/C complex discovery and plan review.
70
+ - OpenAI Terra/Luna/Codex-class: B/D implementation and review, chosen by task risk and cost.
71
+ - Latest matching Grok 4.6-or-newer model: A/C independent frontier analysis or current web/social context.
72
+ - Native Devin SWE: B/D when exposed by the runtime. External Devin: bounded delegation with acceptance criteria and a quota limit.
73
+
74
+ Use Pi or OMP's own authentication and model UI as the authority for what the account can actually access.
@@ -0,0 +1,88 @@
1
+ # Native OMP runtime integration
2
+
3
+ Use this reference after `auto_runtime_status` reports what the active OMP session actually exposes. Optional native features must degrade cleanly; never claim a gated tool ran when it was unavailable.
4
+
5
+ ## Workflow shape
6
+
7
+ ```text
8
+ A discovery ──► C independent plan review ──► plan gate
9
+ │
10
+ ▼
11
+ B implementation
12
+ │
13
+ ▼
14
+ conditional verification
15
+ tests · DAP · browser/desktop
16
+ │
17
+ ▼
18
+ D code review
19
+ │
20
+ ▼
21
+ conditional security review
22
+ │
23
+ ▼
24
+ lessons/memory ──► optional commit
25
+ ```
26
+
27
+ The A/B/C/D models remain the authoritative separation contract. Native OMP features strengthen those stages; they do not silently replace or skip them.
28
+
29
+ ## Advisor
30
+
31
+ The native advisor is an optional continuous watcher, not approval authority and not a replacement for the final C or D verdict.
32
+
33
+ - Offer it when the `advisor` command is present and the user accepts its extra model usage.
34
+ - Use a different underlying model family from the active A or B model when practical.
35
+ - Keep advisor tools read-only. Prefer `read` and `lsp`; do not grant `write`, `edit`, `bash`, or `eval` merely for convenience.
36
+ - Use `/advisor configure` to set project/user `WATCHDOG.yml`, `/advisor on` to enable it for the session, and `/advisor status` to verify the actual model and usage.
37
+ - Do not silently rewrite the user's global `modelRoles.advisor` or existing `WATCHDOG.yml`.
38
+
39
+ ## Deterministic and parallel execution
40
+
41
+ `workflowz` is an explicit user prompt control for a deterministic multi-agent workflow. `orchestrate` is appropriate for substantial independent work whose decomposition is less fixed. The normal Auto Mode path may call `task` directly without either keyword.
42
+
43
+ For `task` fan-out:
44
+
45
+ 1. Prove the units are independent or read-only.
46
+ 2. Give the batch shared acceptance criteria and narrow per-item ownership.
47
+ 3. Use isolated worktrees for parallel writes when available.
48
+ 4. Require structured findings or patch/test evidence.
49
+ 5. Integrate into one canonical tree and rerun the affected checks before D.
50
+
51
+ Use serial execution for a small change or overlapping files. A swarm is a scaling option, not a mandatory stage.
52
+
53
+ ## Checkpoint and rewind
54
+
55
+ These tools prune disposable conversation exploration; they are not filesystem snapshots or generic stage markers.
56
+
57
+ - Use one checkpoint before a long research/debug branch whose raw transcript is not needed later.
58
+ - End it with exactly one rewind containing a concise evidence report.
59
+ - Never nest checkpoints.
60
+ - Do not rewind away an unresolved approval, security finding, required decision, or unrecorded acceptance evidence.
61
+ - If either tool is unavailable, continue normally and use the Markdown ledger for durable state.
62
+
63
+ ## Verification routing
64
+
65
+ - Every implementation: focused tests, type checks, lint/build as applicable.
66
+ - Known or reproducible runtime defect: native DAP `debug` when supported.
67
+ - Web UI: browser helpers through `eval`; test first use, primary flow, invalid input, and dependency failure when relevant.
68
+ - Native desktop UI: computer helpers through `eval` when enabled.
69
+ - Type 5 or high-risk auth/secrets/money/personal-data changes: native `security_scan` when available, otherwise repository-native scanners plus `auto-security-reviewer`.
70
+ - D review: prefer OMP `/review`; use `auto-reviewer` read-only `task` fan-out when `/review` is unavailable or the workflow needs its recorded stage model.
71
+
72
+ Record each skipped or unavailable verification surface as `not verified` with its consequence.
73
+
74
+ ## Memory and lessons
75
+
76
+ Prefer OMP's native memory backend over a separate ad-hoc MCP integration.
77
+
78
+ - Hindsight requires `memory.backend: hindsight`, a reachable service, and any token through `HINDSIGHT_API_TOKEN` or the user's secure OMP configuration.
79
+ - Use per-project isolation for client/employer repositories. Job/client retention remains off until policy permits it.
80
+ - Treat recalled memory as heuristic. Verify it against current repository evidence.
81
+ - At close, write `lessons.md` first. Then use `learn`/`retain` only when those tools are available and retention is approved.
82
+ - Never retain secrets, credentials, raw client data, personal data, or unvalidated hypotheses.
83
+
84
+ ## Commit, sharing, and publication
85
+
86
+ - After D passes and acceptance evidence is complete, offer `omp commit` to create atomic commits. Do not push as part of that step.
87
+ - Push, PR creation, main push, merge, deployments, messages, and other web publication remain protected actions.
88
+ - `/collab` and `/share` are off by default and require one-use `post-web` approval. For job/client work, confirm the participant and use view-only unless write access is explicitly needed.