Skip to content

docs(examples): read-only PowerShell example script (shell_examples.ps1) - #13514

Closed
amasen02 wants to merge 1 commit into
BasedHardware:mainfrom
amasen02:docs/ps1-examples
Closed

amasen02 wants to merge 1 commit into
BasedHardware:mainfrom
amasen02:docs/ps1-examples

Conversation

@amasen02

@amasen02 amasen02 commented Sep 11, 2026 •

Copy link
Copy Markdown

What changed and why

Adds sdks/python-cli/examples/shell_examples.ps1 — a Windows PowerShell
counterpart to shell_examples.sh — plus one index link in
examples/README.md and offline tests for the script. Proposed in #13513
(read-only PowerShell examples, US$25 after acceptance and merge).

Scope is exactly as proposed: the script covers memories, conversations,
action items and goals with selectable read-only examples; parses with native
ConvertFrom-Json/Select-Object (no jq or Bash); documents auth separately
with no credentials in source; and performs no login or mutation merely by
running.

Product invariants affected

none

How it was verified

  • Command surface checked against the source before writing: every flag used
    (--json, --limit, --start-date, --open, --days) and every command
    shape (memory list, conversation list, action-item list, goal list,
    goal history) exists in omi_cli/commands/* on the current tree.
  • Script parses cleanly under Windows PowerShell 5.1 (full parser API, zero
    errors) — the shell most Windows users run by default.
  • Offline behavior tests stub the omi command (no network, no live
    account): nonzero exit throws with the CLI's message attached, malformed
    JSON throws instead of flowing into ConvertFrom-Json, valid JSON parses,
    empty output yields $null.
  • The script itself was never pointed at a live account; all executed
    verification used stubs.

Tests

tests/test_shell_examples_ps1.py (new, 7 tests; auto-skipped on platforms
without PowerShell, e.g. the CI Linux matrix):

  • test_script_exists, test_script_parses_cleanly — real PowerShell parser
    run over the file.
  • test_script_is_read_only — no mutating verb in any non-comment line.
  • test_script_has_no_embedded_credentials — no hardcoded keys.
  • test_every_omi_call_checks_exit_code — direct omi invocations are only
    allowed inside the guarded helper.
  • test_helper_throws_on_nonzero_exit_and_malformed_json — the four helper
    outcomes (throw/throw/parse/null) against a stubbed omi.
  • test_readme_links_the_script — index link present.

Error paths covered: nonzero exit and malformed JSON inside the helper test;
the full suite is green locally (402 passed, including these 7).

Failure class (fixes)

Failure-Class: none

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this — the structure is genuinely good: a guarded Invoke-OmiJson helper, no embedded credentials, auth documented separately, and offline tests are exactly the right instincts for an examples file. I'm requesting changes for one blocking issue that I verified by running the CLI built from this branch, plus a few smaller hardening items.

Blocking: every example passes --json after the verb, which the CLI rejects

--json is a root-level option (omi_cli/main.py, the _root callback: json_output: bool = typer.Option(False, "--json", ...)), not a subcommand option. Verified against the actual CLI from this branch:

$ omi memory list --json --limit 10
Usage: omi memory list [OPTIONS]
Error: No such option '--json'.

$ omi --json memory list --limit 10
{"error": "Not authenticated", ...}   # parsed/handled correctly

Every executed call in shell_examples.ps1 uses the broken position: line 73 ($memories = Invoke-OmiJson @('memory', 'list', '--json', '--limit', '10')), the conversations block (lines 89–93), action items (line 106), goals (line 117), and the error-handling demo (line 133). Because Invoke-OmiJson checks $LASTEXITCODE before parsing (line 38), every example will throw with a usage error on a real machine — after successful auth, too. The fix is mechanical: move '--json' to the front of each args array, e.g. Invoke-OmiJson @('--json', 'memory', 'list', '--limit', '10'). The offline tests stub omi, which is why CI passes; if you want a regression net, one test invoking the real omi binary unauthenticated distinguishes the two positions (omi memory list --json fails to parse; omi --json memory list emits the auth JSON) without any network.

For completeness: the existing shell_examples.sh line 26 has the same latent issue (omi memory list --json --limit 50 | jq ...) — not something you introduced, but worth a follow-up issue since the README calls these runnable.

Smaller items (same files):

  1. shell_examples.ps1:99 — $_.structured.title under Set-StrictMode -Version 2.0 throws for any conversation without a structured object and, with $ErrorActionPreference = 'Stop', aborts the whole listing mid-stream. The CLI itself is null-safe here (omi_cli/commands/conversation.py: structured = c.get("structured") or {}). Guard it, e.g. if ($_.structured) { $_.structured.title }.
  2. test_shell_examples_ps1.py:62–67 — the read-only guard (\bomi\b.*\b(create|update|delete|progress|complete|from-segments|logout)\b) can never match an executed line: every invocation routes through Invoke-OmiJson argument arrays where omi never appears as a standalone word, and the helper's own & omi @OmiArgs line (line 38) contains none of the mutating verbs. A future mutating example like Invoke-OmiJson @('memory','create','x') would pass this test. Consider matching the verb token inside the arrays instead.
  3. test_shell_examples_ps1.py:18–21 — the module-level pytestmark = skipif(no powershell) also skips the pure-text checks (read-only guard, credentials scan, README link) on Linux CI, where they would actually run. Applying the skip only to the parser/execution tests keeps the structural guarantees tested everywhere.

Once the --json position is fixed this is a welcome addition — the PowerShell-native JSON handling and read-only framing fit the examples directory well.


by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.

@Git-on-my-level Git-on-my-level added docs-accuracy Documentation or committed reports need accuracy fixes docs-tooling Layer: Documentation, examples, dev tools labels Sep 11, 2026
@amasen02

Copy link
Copy Markdown
Author

All points addressed and pushed (9464f35):

  1. Blocking --json position — moved ahead of the verb in all five Invoke-OmiJson invocations, with a short comment noting --json is a root-level option. Also added your suggested regression net as test_real_cli_json_position: it invokes the real omi binary unauthenticated (no network) and asserts the wrong position is rejected with No such option '--json' while the right position parses and emits the JSON auth-error object. Reproduced your exact failure locally before the fix (Usage: omi memory list [OPTIONS] / Error: No such option '--json') and the fixed script's arrays were re-verified against the same binary.
  2. structured guard — ForEach-Object { if ($_.structured) { $_.structured.title } }, matching the CLI's own null-safe behavior under Set-StrictMode -Version 2.0 + $ErrorActionPreference = 'Stop'.
  3. Read-only guard — now matches mutating verbs inside Invoke-OmiJson quoted token arrays (so a future @('memory','create',...) trips it), plus direct omi calls; block comments stripped before scanning.
  4. Skip scoping — module-level pytestmark replaced with a requires_powershell decorator applied only to test_script_parses_cleanly and test_helper_throws_on_nonzero_exit_and_malformed_json; the read-only-guard, credentials-scan, README-link and new CLI-position tests now run on every platform.

Full suite green on Windows with the real CLI on PATH: 8 passed. (Agreed the latent shell_examples.sh:26 position issue is worth a follow-up issue — will open it once this lands to keep this PR one-concern.)

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New example script (feature, not a bug fix) -- stays approve-only per policy regardless of quality. Independently verified the blocking --json-position issue raised in review was real (confirmed --json is a root-level typer option in omi_cli/main.py) and has since been fixed in the latest commit with a regression test added.

@amasen02
amasen02 force-pushed the docs/ps1-examples branch 3 times, most recently from d6fccaf to efeb443 Compare September 12, 2026 17:19
@Git-on-my-level
Git-on-my-level dismissed their stale review September 12, 2026 23:00

Dismissing as resolved: the blocking --json-after-verb issue and the three smaller items from this review are fixed and verified on the current head (437d902) — all Invoke-OmiJson calls now pass --json before the verb (root-level option in omi_cli/main.py), the structured guard is in place, the read-only test guard matches argument arrays, and skipif is scoped to PowerShell-only tests. Confirmed the rebase kept the script and tests byte-identical to the commit kodjima33 signed off on.

@Git-on-my-level Git-on-my-level added positive-signal Automation verified a genuine fix/quality contribution and removed docs-accuracy Documentation or committed reports need accuracy fixes labels Sep 12, 2026
@Git-on-my-level

Copy link
Copy Markdown
Member

Follow-up verification on the current head (437d902) after the rebase:

  • The rebase changed none of the reviewed substance: examples/shell_examples.ps1 and tests/test_shell_examples_ps1.py are byte-identical to the commit @kodjima33 approved; examples/README.md differs only by picking up the merged quickstart.ru.md entry and reordering this script's link to the end of the list.
  • All five Invoke-OmiJson calls in shell_examples.ps1 now pass '--json' before the verb, matching the root-level option in omi_cli/main.py (json_output: bool = typer.Option(False, "--json", ...)), and test_real_cli_json_position pins the regression against the real binary.
  • Cross-checked every command and flag in the examples against omi_cli/commands/* at this head: memory list --limit (1-200), conversation list --start-date/--limit, action-item list --open, goal list, goal history --days all exist with those exact names. The intentional --limit 0 failure demo is correct as written — it exits nonzero via the 1-200 range validation and exercises the catch block.
  • Ran the platform-independent tests from this PR on Linux: read-only guard, credentials scan, exit-code guard placement, README link — all pass (PowerShell-dependent tests skip cleanly).
  • One trivial nit, no action needed: in the Goals block, Format-Table -AutoSize sits on its own line with no pipe connecting it to the preceding Select-Object statement, so it runs as a separate no-op; the properties still render via default formatting. A trailing pipe on the Select-Object line would make it explicit.

Thanks for the thorough response to the earlier review — the offline-stub test design plus the real-binary regression net is exactly the right combination for an examples file. The earlier automated change request is dismissed as resolved.

by AI on behalf of David

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs: PowerShell example script verified — every flag/command shape (memory list, conversation list, action-item list, goal list) exists in current omi_cli source, script is read-only (no mutating verbs reach the CLI, no Invoke-Expression, no embedded credentials), tests cover parse/read-only/error-handling. Merging.

@kodjima33 kodjima33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read-only PowerShell examples, offline-tested, commands verified against current CLI source; docs-correctness gate passes

@aryanorastar

Copy link
Copy Markdown
Collaborator

Keeping this open on 437d902550a4.

DIRTY 0-checks PowerShell shell_examples.ps1 + tests; unique file, rebase/CI needed.

GitHub reports CONFLICTING/DIRTY against current main — rebase before any merge path.

kodjima APPROVE is the size gate, not maintainer merge.

I am not approving or merging this SHA.

@aryanorastar

Copy link
Copy Markdown
Collaborator

Keeping this open. Not approving 437d902550a4. sdks/python-cli/examples/shell_examples.ps1 absent. CONFLICTING/DIRTY. Do not approve.

— Astar, on behalf of @aryanorastar

@Git-on-my-level

Copy link
Copy Markdown
Member

This looks like a class of change we currently aren't taking, based on maintainer pattern rulings. That's not a judgment on the work itself — if you think this one is different, comment and it goes straight to a maintainer. Thanks for contributing!

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Hey @amasen02 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-tooling Layer: Documentation, examples, dev tools positive-signal Automation verified a genuine fix/quality contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants