@sangyaahub/pi-marg 1.0.1 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sangyaahub/pi-marg",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "A governed, model-routed development path for Pi Agent and Oh My Pi.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -71,4 +71,4 @@ if [[ "${runtime}" == "omp" || "${runtime}" == "both" ]]; then
71
71
  omp plugin install --scope user pi-marg@pi-marg-marketplace
72
72
  fi
73
73
 
74
- echo "PiMarg v1.0.1 installed for ${runtime}. Start a fresh runtime session, then run /pi-marg."
74
+ echo "PiMarg v1.0.4 installed for ${runtime}. Start a fresh runtime session, then run /pi-marg."
@@ -14,10 +14,38 @@ done
14
14
 
15
15
  bun -e '
16
16
  import { existsSync } from "node:fs";
17
+ const isMapping = (value) =>
18
+ value !== null && !Array.isArray(value) && typeof value === "object";
19
+
20
+ function assertNpmPublishWorkflow(workflow, path) {
21
+ const publish = workflow.jobs.publish;
22
+ const steps = publish?.steps;
23
+ const setupNode = steps?.find((step) => step?.uses === "actions/setup-node@v7");
24
+ const commands = steps?.map((step) => step?.run).filter(Boolean) ?? [];
25
+
26
+ if (
27
+ !isMapping(workflow.on) ||
28
+ !("workflow_dispatch" in workflow.on) ||
29
+ workflow.permissions?.contents !== "read" ||
30
+ workflow.permissions?.["id-token"] !== "write" ||
31
+ !isMapping(publish) ||
32
+ publish.if !== "github.ref == \u0027refs/heads/main\u0027" ||
33
+ publish.environment !== "npm-publish" ||
34
+ publish["runs-on"] !== "ubuntu-latest" ||
35
+ !Array.isArray(steps) ||
36
+ setupNode?.with?.["node-version"] !== 24 ||
37
+ setupNode?.with?.["registry-url"] !== "https://registry.npmjs.org" ||
38
+ setupNode?.with?.["package-manager-cache"] !== false ||
39
+ !commands.includes("npm publish --provenance")
40
+ ) {
41
+ throw new Error(`Unsafe npm publishing workflow: ${path}`);
42
+ }
43
+ }
44
+
17
45
  const packageJson = await Bun.file("package.json").json();
18
46
  const marketplace = await Bun.file(".omp-plugin/marketplace.json").json();
19
47
  if (packageJson.name !== "@sangyaahub/pi-marg") throw new Error("Unexpected package name");
20
- if (packageJson.version !== "1.0.1") throw new Error("package.json must be v1.0.1");
48
+ if (packageJson.version !== "1.0.4") throw new Error("package.json must be v1.0.4");
21
49
  if (packageJson.license !== "MIT") throw new Error("package.json must declare MIT");
22
50
  if (packageJson.author !== "Sangyaa") throw new Error("Unexpected package author");
23
51
  if (!packageJson.keywords?.includes("pi-package")) throw new Error("Pi catalog keyword is missing");
@@ -60,6 +88,21 @@ bun -e '
60
88
  throw new Error(`Invalid skill frontmatter: ${path}`);
61
89
  }
62
90
  }
91
+ for await (const path of new Bun.Glob(".github/workflows/*.{yml,yaml}").scan(".")) {
92
+ const text = await Bun.file(path).text();
93
+ const workflow = Bun.YAML.parse(text);
94
+ if (
95
+ !isMapping(workflow) ||
96
+ typeof workflow.name !== "string" ||
97
+ !("on" in workflow) ||
98
+ !isMapping(workflow.jobs)
99
+ ) {
100
+ throw new Error(`Invalid GitHub Actions workflow structure: ${path}`);
101
+ }
102
+ if (path === ".github/workflows/npm-deploy.yml") {
103
+ assertNpmPublishWorkflow(workflow, path);
104
+ }
105
+ }
63
106
  for await (const path of new Bun.Glob("**/*").scan({ cwd: ".", onlyFiles: true })) {
64
107
  if (path === "scripts/validate.sh") continue;
65
108
  if (/\.(?:png|jpe?g|gif|webp)$/i.test(path)) continue;
@@ -10,7 +10,7 @@ Turn a user request into one controlled workflow.
10
10
  1. Read [intake-and-state.md](references/intake-and-state.md) and complete the intake stages in order.
11
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
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.
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. Then save two distinct runtime-only recovery models with `action: select_fallback`: high first, low second.
14
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
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
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.
@@ -18,11 +18,14 @@ Ask one intake stage at a time. A clear user prompt can support a proposed class
18
18
 
19
19
  ## Stage 1 — work context
20
20
 
21
- Ask first:
21
+ Ask first with numbered options:
22
22
 
23
23
  > Is this for your job/client, or is it personal work?
24
+ >
25
+ > 1. Job/client
26
+ > 2. Personal
24
27
 
25
- Record exactly one:
28
+ Record exactly one canonical value (`job-client` or `personal`); numbering is presentation-only:
26
29
 
27
30
  - `job-client`: Do not add Sangyaa branding, name, logo, metadata, footer, or promotional language. Use the employer/client/project brand already in scope.
28
31
  - `personal`: Existing project branding wins. Sangyaa branding is opt-in, never automatic.
@@ -58,6 +61,14 @@ Ask:
58
61
 
59
62
  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
63
 
64
+ Catalog presentation is provider-first:
65
+
66
+ 1. Show **every** authenticated provider as numbered options `1.`, `2.`, … (including Devin when present). Never omit a logged-in provider and never curate down to Claude/Codex/Cursor only.
67
+ 2. After the user picks a provider, call `auto_model_route` again with the same work type and `provider=<name>` so the tool lists **every** model for that provider as numbered `1.`, `2.`, …
68
+ 3. Ask the user with those numbered labels. If the option UI cannot fit the full list, paste the numbered list into the question text and accept the number or exact selector.
69
+
70
+ Interactive `/pi-marg` uses the same provider → model two-step with numbered labels.
71
+
61
72
  The four roles are:
62
73
 
63
74
  - A — thinking/discovery using a current Claude Fable/Opus, OpenAI Astra/Sol, or Grok 4.6-or-newer frontier model.
@@ -67,7 +78,9 @@ The four roles are:
67
78
 
68
79
  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
80
 
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.
81
+ Use `action: select` for each answer with the **exact selector** string (for example `devin/swe-2`), not the display number alone. 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.
82
+
83
+ After the stage models, choose two distinct authenticated runtime models from the same live catalog: a strong **high** backup and an economical **low** backup. Save them with `action: select_fallback`. Do not choose an external-agent route as a backup because automatic recovery requires `setModel` in the current session.
71
84
 
72
85
  ## Stage 5 — native runtime and supporting capabilities
73
86
 
@@ -98,6 +111,7 @@ type: 1..7
98
111
  mode: 1..4
99
112
  spine: compound-engineering | superpowers | gsd | none
100
113
  models: A=<selector> B=<selector|n/a> C=<selector> D=<selector|n/a>
114
+ fallbacks: high=<runtime-selector> low=<different-runtime-selector> active=<none|high|low|exhausted>
101
115
  runtime: advisor=<off|available|on|unavailable> orchestration=<serial|task|workflowz> checkpoint=<off|available|used>
102
116
  addons: ponytail=<off|lite|full> memory=<off|local|hindsight-recall|hindsight-retain> language=<names|none> cost=<economy|balanced|quality>
103
117
  verification: tests=<planned|n/a> dap=<planned|n/a> ui=<browser|desktop|n/a> security=<planned|n/a>
@@ -4,6 +4,8 @@
4
4
 
5
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
6
 
7
+ Catalog text is compact and provider-grouped. Call `action: catalog` first to list every provider with counts, then call again with `provider=<name>` to list every model for that provider as numbered options. Both OMP and Pi adapters accept the optional `provider` parameter. Never present a hand-curated Claude/Codex/Cursor subset when other authenticated providers (including Devin) are in the catalog.
8
+
7
9
  | Stage | Purpose | Eligible live groups | Normal agent and tools |
8
10
  |---|---|---|---|
9
11
  | 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 |
@@ -15,6 +17,15 @@ The extension compares normalized provider-independent identities, so the same m
15
17
 
16
18
  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
19
 
20
+ ## Automatic usage-limit recovery
21
+
22
+ Save two distinct authenticated runtime models after A/B/C/D selection:
23
+
24
+ - **high** — the strongest practical recovery model; frontier fits rank first;
25
+ - **low** — an economical recovery model; execution fits rank first.
26
+
27
+ The runtime waits for its own retry cycle to settle. If a direct model or detected model-execution route (including external Devin and subagents) still ends with a positively identified usage-limit/quota exhaustion error, PiMarg activates high, then low if the active high model itself fails, records and deduplicates failures, notifies the user, and resumes the same stage from the last safe point. It never treats an ordinary implementation error or temporary throttle as quota exhaustion and never re-enters a failed selector within the same activated stage.
28
+
18
29
  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
30
 
20
31
  ## Cross-family review
@@ -61,7 +72,9 @@ Call `auto_runtime_status` during intake. Follow [native-omp-runtime.md](native-
61
72
  - 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
73
  - Current business/market facts: web research with source links; keep external posting disabled until approved.
63
74
 
64
- ## Provider recommendation for the user's accounts
75
+ ## Provider recommendation (optional ranking only)
76
+
77
+ These names are soft ranking hints. They are never required. PiMarg always picks up the live authenticated catalog for whoever is using it.
65
78
 
66
79
  - Cursor Composer or a zero-metered Cursor route: economical B/D work when present in the live catalog.
67
80
  - Claude Fable/Opus: A/C product thinking, architecture, specification, and cross-family review.
@@ -71,4 +84,4 @@ Call `auto_runtime_status` during intake. Follow [native-omp-runtime.md](native-
71
84
  - Latest matching Grok 4.6-or-newer model: A/C independent frontier analysis or current web/social context.
72
85
  - Native Devin SWE: B/D when exposed by the runtime. External Devin: bounded delegation with acceptance criteria and a quota limit.
73
86
 
74
- Use Pi or OMP's own authentication and model UI as the authority for what the account can actually access.
87
+ Use Pi or OMP's own authentication and model UI as the authority for what the account can actually access. If the catalog is empty, promote subscription/provider setup (`/login` on OMP, or Pi credentials) before continuing. Present required stages in ascending A/B/C/D order.
@@ -48,6 +48,11 @@ Record:
48
48
  - Stage C model: <exact live selector>
49
49
  - Stage D model: <exact live selector or n/a>
50
50
  - Model separation: A != C; B != D
51
+ - High backup model: <exact live runtime selector>
52
+ - Low backup model: <different exact live runtime selector>
53
+ - Automatic failover: idle | high-active | low-active | exhausted
54
+ - Last failover: <failed selector -> activated selector at timestamp, or none>
55
+ - Recovery durability warning: <none or session ledger write failure that requires re-selection after restart>
51
56
  - CodeGraph: n/a | pending | ready | blocked
52
57
  - Runtime: advisor=<off|available|on|unavailable>; orchestration=<serial|task|workflowz>; checkpoint=<off|available|used>
53
58
  - Add-ons: Ponytail=<setting>; memory=<off|local|hindsight-recall|hindsight-retain>; language skills=<names or none>; cost=<posture>