@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,61 @@
1
+ import { Type } from "typebox";
2
+
3
+ import {
4
+ MODEL_STATE_TYPE,
5
+ emptyModelRouteState,
6
+ executeModelRoute,
7
+ restoreModelRouteState,
8
+ type ModelLike,
9
+ type ModelRouteParams,
10
+ } from "../../../core/model-routing";
11
+
12
+ function toolNames(pi: any): string[] {
13
+ return (pi.getAllTools?.() ?? [])
14
+ .map((tool: any) => typeof tool === "string" ? tool : String(tool?.name ?? ""))
15
+ .filter(Boolean);
16
+ }
17
+
18
+ function hasExternalDevin(pi: any): boolean {
19
+ return toolNames(pi).some((name) => /(?:^|[_-])devin(?:[_-]|$)/i.test(name));
20
+ }
21
+
22
+ function availableModels(ctx: any): ModelLike[] {
23
+ const scoped = (ctx.scopedModels ?? []).map((entry: any) => entry.model).filter(Boolean);
24
+ return (scoped.length > 0 ? scoped : ctx.modelRegistry.getAvailable()) as ModelLike[];
25
+ }
26
+
27
+ export default function modelRouter(pi: any) {
28
+ let state = emptyModelRouteState();
29
+ pi.on("session_start", (_event: unknown, ctx: any) => {
30
+ state = restoreModelRouteState(ctx.sessionManager.getBranch());
31
+ });
32
+
33
+ pi.registerTool({
34
+ name: "auto_model_route",
35
+ label: "PiMarg Model Router",
36
+ description: "Discover, select, and activate live A/B/C/D model choices while enforcing A different from C and B different from D.",
37
+ parameters: Type.Object({
38
+ action: Type.Union([
39
+ Type.Literal("catalog"),
40
+ Type.Literal("select"),
41
+ Type.Literal("activate"),
42
+ Type.Literal("status"),
43
+ ]),
44
+ stage: Type.Optional(Type.Union([Type.Literal("A"), Type.Literal("B"), Type.Literal("C"), Type.Literal("D")])),
45
+ target: Type.Optional(Type.String()),
46
+ workType: Type.Optional(Type.Number()),
47
+ }),
48
+ async execute(_toolCallId: string, params: ModelRouteParams, _signal: unknown, _onUpdate: unknown, ctx: any) {
49
+ const models = availableModels(ctx);
50
+ const execution = await executeModelRoute(state, params, {
51
+ runtimeName: "Pi",
52
+ models,
53
+ hasExternalDevin: hasExternalDevin(pi),
54
+ activate: (model) => pi.setModel(model),
55
+ persist: (nextState) => pi.appendEntry(MODEL_STATE_TYPE, nextState),
56
+ });
57
+ state = execution.state;
58
+ return execution.response;
59
+ },
60
+ });
61
+ }
@@ -0,0 +1,25 @@
1
+ import { Type } from "typebox";
2
+
3
+ import {
4
+ buildRuntimeCapabilityReport,
5
+ normalizeCapabilityNames,
6
+ } from "../../../core/runtime-capabilities";
7
+
8
+ function response(report: unknown) {
9
+ return { content: [{ type: "text" as const, text: JSON.stringify(report, null, 2) }], details: report };
10
+ }
11
+
12
+ export default function runtimeCapabilities(pi: any) {
13
+ pi.registerTool({
14
+ name: "auto_runtime_status",
15
+ label: "PiMarg Runtime Status",
16
+ description: "Detect Pi tools, commands, and memory hooks before routing optional workflow stages.",
17
+ parameters: Type.Object({}),
18
+ async execute() {
19
+ const tools = normalizeCapabilityNames(pi.getAllTools?.() ?? []);
20
+ const commands = normalizeCapabilityNames(pi.getCommands?.() ?? []);
21
+ const memoryConfigured = tools.some((name) => ["recall", "retain", "reflect", "learn"].includes(name));
22
+ return response(buildRuntimeCapabilityReport("Pi", tools, commands, memoryConfigured));
23
+ },
24
+ });
25
+ }
@@ -0,0 +1,7 @@
1
+ import { UNIVERSAL_WORKFLOW_POLICY } from "../../../core/workflow-policy";
2
+
3
+ export default function workflowBootstrap(pi: any) {
4
+ pi.on("before_agent_start", (event: any) => ({
5
+ systemPrompt: `${String(event.systemPrompt ?? "")}\n\n${UNIVERSAL_WORKFLOW_POLICY}`,
6
+ }));
7
+ }
@@ -0,0 +1,11 @@
1
+ ---
2
+ description: Verify and close the active Auto Mode session.
3
+ ---
4
+
5
+ For the active Auto Mode session:
6
+
7
+ 1. Check the acceptance evidence, conditional verification gates, D verdict, and any required security verification. List anything not verified and its consequence.
8
+ 2. Load and run `session-lessons` unless its `run_count` is already `1`. Use native learn/retain only when available and approved.
9
+ 3. Offer `/auto-commit` only when the review verdict is `ship`; do not create a commit automatically during close.
10
+ 4. Update the session ledger to `completed` only if the requested outcome is actually complete; otherwise leave it `active` or mark it `blocked` with the reason.
11
+ 5. Do not perform any protected action as part of closing the session.
@@ -0,0 +1,7 @@
1
+ ---
2
+ description: Create local atomic commits after Auto Mode verification and review pass.
3
+ ---
4
+
5
+ Read the active ledger. Continue only when acceptance evidence is complete, the D verdict is `ship`, any required security verification passed, and the user invoked this command for the exact repository.
6
+
7
+ Use the repository's normal local Git workflow to prepare focused atomic commits and clear messages. Inspect the staged diff before each commit and record the resulting commit IDs or the failure. Do not push, open a PR, publish, merge, delete, or bypass any approval gate.
@@ -0,0 +1,12 @@
1
+ ---
2
+ description: List or change the active Auto Mode A/B/C/D model selections from Pi's live authenticated catalog.
3
+ argument-hint: [status | choose]
4
+ ---
5
+
6
+ Load `auto-mode-router` and read its model-routing reference.
7
+
8
+ - With no argument or `status`, call `auto_model_route` with `action: status`, then show the saved A/B/C/D selectors and separation checks.
9
+ - With `choose`, call `auto_model_route` with `action: catalog` and the active work type. Present only required stages and exact available selectors. Save each answer with `action: select`.
10
+ - Do not type or persist a model ID that the live catalog did not return.
11
+ - Treat any model returned by Pi's registry as a normal in-session route. Treat Devin or another external coding-agent session as a capability-gated external route; creating one requires `post-web` approval.
12
+ - C/D are the authoritative independent review selectors. Any detected advisor or watcher is supplemental and must not weaken the A≠C or B≠D checks.
@@ -0,0 +1,8 @@
1
+ ---
2
+ description: Close the current Auto Mode context and begin intake for a different task.
3
+ argument-hint: <new work request>
4
+ ---
5
+
6
+ If an Auto Mode session is active, preserve its files and mark its status `superseded`; do not delete it. Clear its conversational routing state, load `auto-mode-router`, and begin fresh intake for:
7
+
8
+ $ARGUMENTS
@@ -0,0 +1,11 @@
1
+ ---
2
+ description: Run the required Auto Mode plan or implementation review with the saved independent model.
3
+ argument-hint: [plan | code]
4
+ ---
5
+
6
+ Load `auto-mode-router` and the native Pi runtime reference.
7
+
8
+ - `plan`: activate Stage C, review the authoritative plan and highest-cost risks, then record the verdict.
9
+ - `code` or no argument: require verification evidence, activate Stage D, and apply the P0–P3/confidence/verdict review contract. Use read-only task fan-out only when a compatible extension is detected; otherwise review sequentially with the saved independent model.
10
+
11
+ Never fix findings in the review pass. A block verdict returns to planning or B with a recorded countermeasure.
@@ -0,0 +1,13 @@
1
+ ---
2
+ description: Show Pi capabilities available to the active Auto Mode workflow.
3
+ argument-hint: [status | advisor | memory | context]
4
+ ---
5
+
6
+ Load `auto-mode-router`, read its native Pi runtime reference, and call `auto_runtime_status`.
7
+
8
+ - With no argument or `status`, report available tools/commands, active memory, and exact fallbacks without changing configuration.
9
+ - With `advisor`, report whether a compatible advisor or watcher extension is detected. Keep C/D as the authoritative reviewers.
10
+ - With `memory`, show the approved context-specific local/Hindsight route. Never expose or write a token.
11
+ - With `context`, report whether checkpoint/rewind is detected and use it only around one disposable exploration branch.
12
+
13
+ Update the runtime fields in the ledger only after observing the actual state.
@@ -0,0 +1,17 @@
1
+ ---
2
+ description: Show the current Auto Mode classification and evidence state.
3
+ ---
4
+
5
+ Read the active Auto Mode session ledger and report only:
6
+
7
+ - work context and branding policy;
8
+ - work type and primary skill spine;
9
+ - current phase and authoritative plan path;
10
+ - exact A/B/C/D model selectors, separation checks, and agents used;
11
+ - CodeGraph, native runtime detection, orchestration/advisor, and optional add-on state;
12
+ - tests, DAP, UI, security, and review-verdict state;
13
+ - collaboration and local commit state;
14
+ - pending approvals;
15
+ - whether session lessons have run.
16
+
17
+ Do not change files or advance the workflow.
@@ -0,0 +1,12 @@
1
+ ---
2
+ description: Start or resume the Auto Mode intake and workflow.
3
+ argument-hint: <work request>
4
+ ---
5
+
6
+ Load `auto-mode-router` and start a new Auto Mode task for this request:
7
+
8
+ $ARGUMENTS
9
+
10
+ If an active Auto Mode task already covers this request, resume it instead of repeating intake.
11
+
12
+ If the user requests multiple agents, use parallel work only when a compatible task or subagent extension is detected and the work units are genuinely independent. Otherwise execute the same stages sequentially. Model, evidence, and approval gates apply in either mode.
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: auto-builder
3
+ description: Implement a verified plan through the selected Auto Mode skill spine.
4
+ tools: [read, write, edit, bash, ls, lsp, ast_grep, ast_edit, task, recall, codegraph_explore]
5
+ spawns: [auto-qa, auto-reviewer, auto-security-reviewer]
6
+ blocking: true
7
+ autoloadSkills: [auto-mode-router, codegraph-first]
8
+ ---
9
+
10
+ Read the active ledger and authoritative plan before editing. Confirm Stage B is activated and inherited. Use only the recorded primary spine. Pass the CodeGraph gate: use CodeGraph for architecture/dependency/impact questions, LSP for definitions/references/renames/diagnostics, `ast_grep` for structural queries, and exact reads plus hash-aware edit or `ast_edit` for changes. Implement the smallest reliable slice, follow repository conventions, discover existing tests, and verify behavior continuously. Use Ponytail or language skills only when recorded and available. Use `task` batch fan-out only for proven-independent work with explicit ownership; isolate parallel writes and integrate each result into the canonical tree before review. Record actual evidence and never perform a protected action without the runtime approval gate.
@@ -0,0 +1,9 @@
1
+ ---
2
+ name: auto-business-analyst
3
+ description: Produce business, sales, or non-technical analysis through the selected Auto Mode route.
4
+ tools: [read, grep, glob, ls, web_search, checkpoint, rewind]
5
+ blocking: true
6
+ autoloadSkills: [auto-mode-router]
7
+ ---
8
+
9
+ Read the active ledger, confirm Stage A or C is activated and inherited, and use the selected analysis skill when available. Separate current sourced facts, inference, and recommendation. For a broad disposable research branch, checkpoint before exploration and rewind once with a concise sourced report when that capability is detected. Track material assumptions and decisions. Do not publish, send messages, update a CRM, share the session, or post to any web platform without one-use `post-web` approval.
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: auto-debugger
3
+ description: Reproduce, diagnose, and fix a defect through the selected Auto Mode skill spine.
4
+ tools: [read, write, edit, bash, ls, lsp, ast_grep, debug, task, checkpoint, rewind, recall, codegraph_explore]
5
+ spawns: [scout, auto-qa, auto-reviewer]
6
+ blocking: true
7
+ autoloadSkills: [auto-mode-router, codegraph-first]
8
+ ---
9
+
10
+ Read the ledger and confirm Stage B is activated and inherited. Pass the CodeGraph gate, then reproduce the failure when feasible and preserve the failing evidence. Use CodeGraph for flow and impact, LSP for exact symbols, and the native DAP `debug` tool when a supported live process gives stronger evidence than logging. A bounded debugging investigation may use one checkpoint and one rewind report to discard noisy exploration while preserving the causal chain. Add or strengthen a regression check, apply the root-cause fix, and rerun relevant checks. Label diagnosis provisional when reproduction is impossible. Keep one primary spine and record protected-action checkpoints.
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: auto-intake
3
+ description: Classify an Auto Mode request without modifying the project.
4
+ model: ["@smol", "@default"]
5
+ tools: [read, grep, glob, ls, auto_model_route, auto_runtime_status]
6
+ blocking: true
7
+ autoloadSkills: [auto-mode-router]
8
+ ---
9
+
10
+ Complete only the intake and availability checks from `auto-mode-router`. Ask in the required order: work context, work type, skill mode, live A/B/C/D selections, then add-ons. Call `auto_runtime_status` before recommending runtime capabilities. Return the proposed `[AUTO-MODE]` state. Do not plan, implement, or change project files.
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: auto-lessons-writer
3
+ description: Run the once-per-session Auto Mode lessons closeout.
4
+ model: ["@smol", "@default"]
5
+ tools: [read, write, edit, grep, glob, ls, learn, retain]
6
+ blocking: true
7
+ autoloadSkills: [session-lessons]
8
+ ---
9
+
10
+ Load and follow `session-lessons`. Use only verified artifacts, write the lessons file once, and update the active session ledger. If approved native memory tools are available, `learn` the reusable guardrail and `retain` only the verified decision/lesson summary; never retain secrets or raw client material. Do not alter product code or perform protected actions.
@@ -0,0 +1,9 @@
1
+ ---
2
+ name: auto-qa
3
+ description: Verify user-visible Auto Mode changes through conditional browser, desktop, and repository checks.
4
+ tools: [read, bash, ls, lsp, eval, codegraph_explore]
5
+ blocking: true
6
+ autoloadSkills: [auto-mode-router, codegraph-first]
7
+ ---
8
+
9
+ Read the active ledger and acceptance criteria. Run after Stage B while its implementation model is still active and before Stage D. Pass the CodeGraph gate for repository source questions. Choose only verification surfaces that match the change: repository tests/builds for code contracts, browser helpers through `eval` for web flows, computer helpers through `eval` for native desktop flows, and direct artifact inspection for generated output. Exercise the happy path plus the highest-cost invalid, empty, dependency-failure, or recovery path that applies. Do not modify product code; return reproducible evidence and mark unavailable surfaces as not verified rather than claiming success.
@@ -0,0 +1,9 @@
1
+ ---
2
+ name: auto-reviewer
3
+ description: Review an Auto Mode change for correctness, regressions, tests, and maintainability without modifying it.
4
+ tools: [read, bash, ls, lsp, ast_grep, task, codegraph_explore]
5
+ blocking: true
6
+ autoloadSkills: [auto-mode-router, codegraph-first]
7
+ ---
8
+
9
+ Confirm Stage C for plan review or Stage D for implementation/code review is activated and inherited. Review the requested plan, diff, commit, or branch read-only. Pass the CodeGraph gate; use CodeGraph for impact, LSP for exact contracts, and structural tools when detected. Compare the result with the active plan, decisions, acceptance criteria, and test evidence. When scope or risk justifies it, use task fan-out only when detected and reconcile all lenses into the shared review shape: P0–P3 priority, confidence, location, consequence, countermeasure, and a ship/block verdict. Run `ponytail-review` separately when recorded; it does not replace correctness review. Distinguish findings from questions. Do not fix code or perform external mutations.
@@ -0,0 +1,9 @@
1
+ ---
2
+ name: auto-security-reviewer
3
+ description: Perform a read-only security review of an Auto Mode repository scope or change.
4
+ tools: [read, bash, ls, lsp, ast_grep, task, security_scan, codegraph_explore]
5
+ blocking: true
6
+ autoloadSkills: [auto-mode-router, codegraph-first]
7
+ ---
8
+
9
+ Confirm the recorded review stage is activated and inherited. Review the exact scope read-only. Pass the CodeGraph gate; use graph paths for attack flow and impact, LSP for exact symbols, and `ast_grep` for structural checks. Use native `security_scan` when the runtime detector reports it available; otherwise run non-mutating repository-native scanners and record the fallback. Validate candidates before assigning severity. Ponytail must never remove a security control. Report only evidence-backed findings with location, exploit consequence, confidence, and countermeasure. Fixes require a separate plan and must not be applied in this review task.
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: auto-strategist
3
+ description: Brainstorm, analyze, or plan through the selected Auto Mode skill spine.
4
+ tools: [read, bash, ls, web_search, lsp, ast_grep, task, checkpoint, rewind, recall, reflect, codegraph_explore]
5
+ spawns: [scout]
6
+ blocking: true
7
+ autoloadSkills: [auto-mode-router, codegraph-first]
8
+ ---
9
+
10
+ Read the active Auto Mode ledger, confirm Stage A (or C for a plan second-eye) is activated and inherited, and use only its selected primary spine. For existing repositories, pass the CodeGraph gate: use CodeGraph for architecture and impact, LSP for exact symbols/types, and `ast_grep` for structural patterns. Load the mapped strategy or planning skill explicitly and verify it is available. Keep implementation writes off. For long disposable exploration only, create one checkpoint before investigating and rewind once with a concise evidence report; do not treat checkpoint as a stage-completion marker. When approved memory is available, recall only task-relevant context and verify it against current evidence. Update the authoritative plan and neutral decision ledger, then return acceptance criteria, open risks, and the next gate.
Binary file
@@ -0,0 +1,106 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>PiMarg banner</title>
7
+ <style>
8
+ * { box-sizing: border-box; }
9
+ html, body { margin: 0; width: 1280px; height: 640px; overflow: hidden; }
10
+ body {
11
+ color: #161614;
12
+ background: #FAFAF7;
13
+ font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
14
+ }
15
+ .canvas {
16
+ position: relative;
17
+ display: grid;
18
+ grid-template-columns: 1.25fr .75fr;
19
+ width: 100%;
20
+ height: 100%;
21
+ padding: 70px 76px 60px;
22
+ isolation: isolate;
23
+ }
24
+ .canvas::before {
25
+ position: absolute;
26
+ inset: 0;
27
+ z-index: -2;
28
+ background:
29
+ radial-gradient(circle at 91% 14%, rgba(107, 155, 250, .27), transparent 28%),
30
+ linear-gradient(125deg, #FAFAF7 0 58%, #E8EFFE 58% 100%);
31
+ content: "";
32
+ }
33
+ .copy { display: flex; flex-direction: column; align-items: flex-start; }
34
+ .eyebrow { color: #0338A8; font-size: 18px; font-weight: 750; letter-spacing: .16em; text-transform: uppercase; }
35
+ h1 { margin: 34px 0 0; color: #021E5C; font-size: 112px; line-height: .9; letter-spacing: -.075em; }
36
+ .meaning { margin: 18px 0 0; color: #C27B1A; font-family: Georgia, serif; font-size: 25px; font-style: italic; }
37
+ .tagline { max-width: 650px; margin: 26px 0 0; color: #3A3A37; font-size: 29px; line-height: 1.25; letter-spacing: -.025em; }
38
+ .chips { display: flex; gap: 10px; margin-top: auto; }
39
+ .chip { padding: 8px 13px; border: 1px solid #C8D5F3; border-radius: 999px; color: #0338A8; background: #fff; font-size: 14px; font-weight: 700; }
40
+ .route { position: relative; display: grid; place-items: center; }
41
+ .path {
42
+ position: absolute;
43
+ width: 236px;
44
+ height: 440px;
45
+ border: 22px solid #0451F7;
46
+ border-top: 0;
47
+ border-bottom: 0;
48
+ border-radius: 118px;
49
+ opacity: .98;
50
+ }
51
+ .path::before, .path::after {
52
+ position: absolute;
53
+ left: -22px;
54
+ width: 236px;
55
+ height: 118px;
56
+ border: 22px solid #0451F7;
57
+ content: "";
58
+ }
59
+ .path::before { top: -18px; border-bottom: 0; border-radius: 118px 118px 0 0; }
60
+ .path::after { bottom: -18px; border-top: 0; border-radius: 0 0 118px 118px; }
61
+ .nodes { position: relative; z-index: 2; display: grid; gap: 23px; }
62
+ .node {
63
+ display: grid;
64
+ grid-template-columns: 48px 1fr;
65
+ align-items: center;
66
+ width: 250px;
67
+ min-height: 64px;
68
+ overflow: hidden;
69
+ border: 1px solid rgba(3, 56, 168, .18);
70
+ border-radius: 16px;
71
+ background: rgba(255, 255, 255, .95);
72
+ box-shadow: 0 12px 30px rgba(2, 30, 92, .12);
73
+ }
74
+ .node b { display: grid; height: 100%; place-items: center; color: #fff; background: #0338A8; font-size: 21px; }
75
+ .node span { padding: 0 14px; color: #021E5C; font-size: 17px; font-weight: 730; }
76
+ .node.review b { background: #C27B1A; }
77
+ .byline { position: absolute; right: 64px; bottom: 32px; display: flex; align-items: center; gap: 10px; color: #0338A8; font-size: 14px; font-weight: 720; }
78
+ .byline img { width: 15px; height: 27px; object-fit: contain; }
79
+ </style>
80
+ </head>
81
+ <body>
82
+ <main class="canvas" aria-label="PiMarg by Sangyaa">
83
+ <section class="copy">
84
+ <div class="eyebrow">Pi + OMP agent workflow</div>
85
+ <h1>PiMarg</h1>
86
+ <p class="meaning">मार्ग · a clear path</p>
87
+ <p class="tagline">A governed development path from first thought to verified code.</p>
88
+ <div class="chips">
89
+ <span class="chip">Live model routing</span>
90
+ <span class="chip">Independent review</span>
91
+ <span class="chip">Approval gates</span>
92
+ </div>
93
+ </section>
94
+ <section class="route" aria-label="Discover, review, build, review">
95
+ <div class="path" aria-hidden="true"></div>
96
+ <div class="nodes">
97
+ <div class="node"><b>A</b><span>Discover</span></div>
98
+ <div class="node review"><b>C</b><span>Review the plan</span></div>
99
+ <div class="node"><b>B</b><span>Build + verify</span></div>
100
+ <div class="node review"><b>D</b><span>Review the code</span></div>
101
+ </div>
102
+ </section>
103
+ <div class="byline"><img src="brand/sangyaa-mark.png" alt=""> An open-source project by Sangyaa</div>
104
+ </main>
105
+ </body>
106
+ </html>
Binary file
@@ -0,0 +1,11 @@
1
+ ---
2
+ description: Verify and close the active Auto Mode session.
3
+ ---
4
+
5
+ For the active Auto Mode session:
6
+
7
+ 1. Check the acceptance evidence, conditional verification gates, D verdict, and any required security verification. List anything not verified and its consequence.
8
+ 2. Load and run `session-lessons` unless its `run_count` is already `1`. Use native learn/retain only when available and approved.
9
+ 3. Offer `/auto-commit` only when the review verdict is `ship`; do not create a commit automatically during close.
10
+ 4. Update the session ledger to `completed` only if the requested outcome is actually complete; otherwise leave it `active` or mark it `blocked` with the reason.
11
+ 5. Do not perform any protected action as part of closing the session.
@@ -0,0 +1,7 @@
1
+ ---
2
+ description: Create local atomic commits after Auto Mode verification and review pass.
3
+ ---
4
+
5
+ Read the active ledger. Continue only when acceptance evidence is complete, the D verdict is `ship`, any required security verification passed, and the user invoked this command for the exact repository.
6
+
7
+ Run OMP's native `omp commit` workflow to prepare local atomic commits and validated messages. Record the resulting commit IDs or the failure. Do not push, open a PR, publish, merge, delete, or bypass any approval gate.
@@ -0,0 +1,12 @@
1
+ ---
2
+ description: List or change the active Auto Mode A/B/C/D model selections from OMP's live authenticated catalog.
3
+ argument-hint: [status | choose]
4
+ ---
5
+
6
+ Load `auto-mode-router` and read its model-routing reference.
7
+
8
+ - With no argument or `status`, call `auto_model_route` with `action: status`, then show the saved A/B/C/D selectors and separation checks.
9
+ - With `choose`, call `auto_model_route` with `action: catalog` and the active work type. Present only required stages and exact available selectors. Save each answer with `action: select`.
10
+ - Do not type or persist a model ID that the live catalog did not return.
11
+ - Distinguish native `devin/swe-*` OMP models from the optional external `devin/mcp-session` route. Only creating the external session requires `post-web` approval.
12
+ - C/D are the authoritative independent review selectors. A configured OMP advisor is supplemental and must not weaken the A≠C or B≠D checks.
@@ -0,0 +1,8 @@
1
+ ---
2
+ description: Close the current Auto Mode context and begin intake for a different task.
3
+ argument-hint: <new work request>
4
+ ---
5
+
6
+ If an Auto Mode session is active, preserve its files and mark its status `superseded`; do not delete it. Clear its conversational routing state, load `auto-mode-router`, and begin fresh intake for:
7
+
8
+ $ARGUMENTS
@@ -0,0 +1,11 @@
1
+ ---
2
+ description: Run the required Auto Mode plan or implementation review with the saved independent model.
3
+ argument-hint: [plan | code]
4
+ ---
5
+
6
+ Load `auto-mode-router` and the native OMP runtime reference.
7
+
8
+ - `plan`: activate Stage C, review the authoritative plan and highest-cost risks, then record the verdict.
9
+ - `code` or no argument: require verification evidence, activate Stage D, and run `auto-reviewer`. If native `/review` is available, its P0–P3/confidence/verdict contract is preferred; otherwise reproduce that contract with read-only `task` fan-out.
10
+
11
+ Never fix findings in the review pass. A block verdict returns to planning or B with a recorded countermeasure.
@@ -0,0 +1,13 @@
1
+ ---
2
+ description: Show native OMP capabilities available to the active Auto Mode workflow.
3
+ argument-hint: [status | advisor | memory | context]
4
+ ---
5
+
6
+ Load `auto-mode-router`, read its native OMP runtime reference, and call `auto_runtime_status`.
7
+
8
+ - With no argument or `status`, report available tools/commands, active memory, and exact fallbacks without changing configuration.
9
+ - With `advisor`, explain `/advisor configure`, `/advisor on`, and `/advisor status` using the saved C/D model policy. Do not rewrite global roles or WATCHDOG files automatically.
10
+ - With `memory`, show the approved context-specific local/Hindsight route and `/memory diagnose`. Never expose or write a token.
11
+ - With `context`, explain that checkpoint/rewind must be enabled and used only around one disposable exploration branch.
12
+
13
+ Update the runtime fields in the ledger only after observing the actual state.
@@ -0,0 +1,17 @@
1
+ ---
2
+ description: Show the current Auto Mode classification and evidence state.
3
+ ---
4
+
5
+ Read the active Auto Mode session ledger and report only:
6
+
7
+ - work context and branding policy;
8
+ - work type and primary skill spine;
9
+ - current phase and authoritative plan path;
10
+ - exact A/B/C/D model selectors, separation checks, and agents used;
11
+ - CodeGraph, native runtime detection, orchestration/advisor, and optional add-on state;
12
+ - tests, DAP, UI, security, and review-verdict state;
13
+ - collaboration and local commit state;
14
+ - pending approvals;
15
+ - whether session lessons have run.
16
+
17
+ Do not change files or advance the workflow.
@@ -0,0 +1,12 @@
1
+ ---
2
+ description: Start or resume the Auto Mode intake and workflow.
3
+ argument-hint: <work request>
4
+ ---
5
+
6
+ Load `auto-mode-router` and start a new Auto Mode task for this request:
7
+
8
+ $ARGUMENTS
9
+
10
+ If an active Auto Mode task already covers this request, resume it instead of repeating intake.
11
+
12
+ When the user's prompt contains the standalone `workflowz` control, preserve it as an explicit request for deterministic native OMP multi-agent orchestration; all Auto Mode model, evidence, and approval gates still apply.
@@ -0,0 +1,109 @@
1
+ const APPROVAL_PREFIX = "APPROVE ACTION:";
2
+
3
+ export const PROTECTED_ACTIONS = ["delete-remove", "push-main", "merge-pr", "post-web"] as const;
4
+ export type ProtectedAction = (typeof PROTECTED_ACTIONS)[number];
5
+
6
+ const MERGE_PR_COMMAND = /\b(?:gh\s+pr\s+merge|glab\s+mr\s+merge)\b/i;
7
+ const PUSH_MAIN_COMMAND = /\bgit\s+push\b[^\n;&|]*(?:\b(?:main|master)\b|HEAD:(?:refs\/heads\/)?(?:main|master)\b)/i;
8
+ const ANY_PUSH_COMMAND = /\bgit\s+push\b/i;
9
+ const DELETE_REMOVE_COMMAND =
10
+ /(?:^|[;&|]|\n)\s*(?:sudo\s+)?(?:rm|rmdir|unlink|trash|git\s+(?:clean|rm|branch\s+(?:-d|-D|--delete)|tag\s+(?:-d|--delete)|remote\s+remove)|find\b[^\n;&|]*\s-delete\b|gh\s+(?:repo|release)\s+delete|npm\s+(?:remove|uninstall)|pnpm\s+(?:remove|uninstall)|yarn\s+remove|bun\s+remove|pipx?\s+uninstall|brew\s+uninstall|apt(?:-get)?\s+(?:remove|purge))\b/i;
11
+ const WEB_POST_COMMAND =
12
+ /\b(?:(?:omp|pi)\s+(?:share|collab)\b|gh\s+(?:pr\s+(?:create|comment|review)|issue\s+(?:create|comment)|release\s+create)|glab\s+(?:mr\s+create|issue\s+create)|npm\s+publish|twine\s+upload|curl\b[^\n]*(?:-X|--request)\s*(?:POST|PUT|PATCH|DELETE)|curl\b[^\n]*(?:-d|--data|--data-raw|--data-binary|-F|--form|-T|--upload-file)\b|wget\b[^\n]*(?:--post-(?:data|file)\b|--method(?:=|\s+)(?:POST|PUT|PATCH|DELETE)\b))\b/i;
13
+ const WEB_PLATFORM_MUTATION_COMMAND =
14
+ /\b(?:gh\s+(?:repo|gist|project)\s+(?:create|edit)|gh\s+api\b[^\n]*(?:(?:-X|--method)\s*(?:POST|PUT|PATCH|DELETE)|(?:-f|-F|--field|--raw-field)\s)|(?:vercel|netlify|firebase|wrangler)\s+(?:deploy|publish))\b/i;
15
+
16
+ const MERGE_PR_TOOL = /(?:^|[_-])(?:merge[_-]?(?:pr|pull[_-]?request|mr)|(?:pr|pull[_-]?request|mr)[_-]?merge)(?:$|[_-])/i;
17
+ const DELETE_REMOVE_TOOL = /(?:^|[_-])(?:delete|remove|uninstall)(?:$|[_-])/i;
18
+ const WEB_POST_TOOL =
19
+ /(?:^|[_-])(?:send|post|publish|reply|comment|message|upload|deploy|create[_-]?(?:issue|pr|pull[_-]?request|release|session)|session[_-]?create|update[_-]?(?:comment|post|status))(?:$|[_-])/i;
20
+
21
+ export function parseApproval(text: string): ProtectedAction | undefined {
22
+ const normalized = text.trim();
23
+ return PROTECTED_ACTIONS.find((action) => normalized === `${APPROVAL_PREFIX} ${action}`);
24
+ }
25
+
26
+ export function approvalInstruction(action: ProtectedAction): string {
27
+ return `${APPROVAL_PREFIX} ${action}`;
28
+ }
29
+
30
+ export function approvalPolicyFromEnvironment(
31
+ environment: Record<string, string | undefined> = process.env,
32
+ ): "ask" | "allow" {
33
+ const value = environment.PIMARG_APPROVAL_POLICY
34
+ ?? environment.UNIVERSAL_AUTO_MODE_APPROVAL_POLICY
35
+ ?? environment.OMP_AUTO_MODE_APPROVAL_POLICY
36
+ ?? "ask";
37
+ return value.trim().toLowerCase() === "allow" ? "allow" : "ask";
38
+ }
39
+
40
+ export function classifyInput(text: string): ProtectedAction | undefined {
41
+ const command = text.trim().split(/\s+/, 1)[0]?.toLowerCase();
42
+ return command === "/collab" || command === "/share" ? "post-web" : undefined;
43
+ }
44
+
45
+ export function classifyToolCall(
46
+ toolName: string,
47
+ input: Record<string, unknown> | undefined,
48
+ ): ProtectedAction | undefined {
49
+ const normalizedName = toolName.toLowerCase();
50
+
51
+ if (normalizedName === "bash") {
52
+ const command = commandFrom(input);
53
+ if (MERGE_PR_COMMAND.test(command)) return "merge-pr";
54
+ if (PUSH_MAIN_COMMAND.test(command)) return "push-main";
55
+ if (DELETE_REMOVE_COMMAND.test(command)) return "delete-remove";
56
+ if (ANY_PUSH_COMMAND.test(command) || WEB_POST_COMMAND.test(command) || WEB_PLATFORM_MUTATION_COMMAND.test(command)) return "post-web";
57
+ return undefined;
58
+ }
59
+
60
+ if (MERGE_PR_TOOL.test(normalizedName)) return "merge-pr";
61
+ if (DELETE_REMOVE_TOOL.test(normalizedName)) return "delete-remove";
62
+ if (WEB_POST_TOOL.test(normalizedName)) return "post-web";
63
+
64
+ if (/(?:browser|web|github|gitlab|slack|teams|notion|linear|jira|email|social|crm|devin)/i.test(normalizedName)) {
65
+ const payload = stringifyInput(input);
66
+ if (!/\b(?:post|publish|send|submit|reply|comment|message|upload|merge)\b/i.test(payload)) {
67
+ return undefined;
68
+ }
69
+ if (/\bmerge\b/i.test(payload) && /\b(?:pr|pull request|merge request|mr)\b/i.test(payload)) {
70
+ return "merge-pr";
71
+ }
72
+ return "post-web";
73
+ }
74
+
75
+ return undefined;
76
+ }
77
+
78
+ export class OneUseApprovals {
79
+ private readonly actions = new Set<ProtectedAction>();
80
+
81
+ grant(action: ProtectedAction): void {
82
+ this.actions.add(action);
83
+ }
84
+
85
+ consume(action: ProtectedAction): boolean {
86
+ if (!this.actions.has(action)) return false;
87
+ this.actions.delete(action);
88
+ return true;
89
+ }
90
+
91
+ clear(): void {
92
+ this.actions.clear();
93
+ }
94
+ }
95
+
96
+ function stringifyInput(input: Record<string, unknown> | undefined): string {
97
+ if (!input) return "";
98
+ try {
99
+ return JSON.stringify(input);
100
+ } catch {
101
+ return "";
102
+ }
103
+ }
104
+
105
+ function commandFrom(input: Record<string, unknown> | undefined): string {
106
+ if (!input) return "";
107
+ const candidate = input.command ?? input.cmd;
108
+ return typeof candidate === "string" ? candidate : "";
109
+ }