Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/offline-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
run: |
python3 -m unittest discover -s tests -p 'test_selected_catalog.py'
python3 -m unittest discover -s tests -p 'test_publisher.py'
python3 -m unittest discover -s tests -p 'test_vault*.py'
- name: Test CPU transcription admission
run: python3 -m unittest discover -s tests -p 'test_whisper_cpu.py'
- name: Check the outcome benchmark grader
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ cd Stack-Plus

[Rehearse in a disposable home](docs/ONBOARDING.md#try-the-installation-and-its-rollback) first. The rehearsal profile should list exactly one skill, `01`, and gives you a rollback command. When you're ready, [install into your own setup](docs/ONBOARDING.md#use-it-in-your-project). If you have existing skills, review the replacement and backup guidance before changing your selection.

During first-time setup you can skip knowledge storage, choose an existing Obsidian folder, or create a vault with starter notes. To set up the folder separately, run `./stack+ vault` from this checkout. [Set up a knowledge base](docs/ONBOARDING.md#optional-obsidian-knowledge-base)

In a project chat, select **`$01` in Codex** or **`@01` in OpenCode** and describe the result you want. Follow-ups retain the selection in that chat. Say **turn 01 off** to end it. [OpenCode setup and compatibility](docs/OPENCODE.md) · [Restore a prior setup](docs/RESTORE.md)

<a name="first-unfamiliar-task"></a><a name="what-changes-when-the-goal-changes"></a>
Expand Down
2 changes: 2 additions & 0 deletions docs/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,5 @@ Host contracts were checked against Anthropic's official
[skill documentation](https://code.claude.com/docs/en/skills) and
[instruction-file documentation](https://code.claude.com/docs/en/memory), including
the [configuration-directory override](https://code.claude.com/docs/en/settings).

To prepare a knowledge folder for this host, run `./stack+ vault` in the Stack+ checkout. Choose an existing Obsidian folder, create one with starter notes, or skip. The host keeps its own permission settings. [Knowledge base setup](ONBOARDING.md#optional-obsidian-knowledge-base)
4 changes: 3 additions & 1 deletion docs/EVERYDAY_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ reacquirable compilers/build caches can use non-synced temporary storage.

## Canonical knowledge vault

Choose one existing, explicitly authorized vault. `--vault /absolute/vault` only
Run `./stack+ vault` to use an existing folder or create a starter vault. [First-time setup](ONBOARDING.md#optional-obsidian-knowledge-base)

Choose one explicitly authorized vault. `--vault /absolute/vault` only
writes its location into owned guidance; it does not import notes or initialize
an arbitrary directory. `templates/vault` is a clean starting structure with Home,
Library, Templates, Archive, a Base and Canvas. Copy only to a new destination or
Expand Down
10 changes: 9 additions & 1 deletion docs/ONBOARDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Run these commands from the Stack+ checkout in Bash or zsh, using Git, Python 3.
```sh
preview=$(mktemp -d)
preview=$(cd "$preview" && pwd -P)
python3 native_setup.py install --only 01 \
python3 native_setup.py install --only 01 --skip-vault \
--home "$preview/home" --codex-home "$preview/home/.codex" --state "$preview/state"
python3 -m json.tool "$preview/state/native-profile.json"
"$preview/state/rollback.sh"
Expand All @@ -36,3 +36,11 @@ mkdir -p "$library"
For OpenCode, add `--host opencode` to the find command and its subsequent readback. Reopen a result with the same project, host and bundle, replacing the query and `--json` with `--method --read MATCH_ID`. The shared skill root still exposes only 01. Specialist dependencies belong in the project that needs them.

For an existing collection, inspect your shared and personal skill roots and retain a backup before replacing anything. Replacing a managed selection can retire omitted entries. Rehearse all additions you intend to retain together. The native installer accepts a custom `--codex-home` or the current `CODEX_HOME`. Keep project-specific skills and connectors in their owning project. [Selection and staging](stackplus-selections.md) · [Existing native profiles and optional bootstrap](REGISTRY.md) · [Recovery](RESTORE.md)

## Optional Obsidian knowledge base

A vault is a local folder of Markdown files. During first-time interactive native installation, choose **Skip**, **Use a folder I already have**, or **Create a vault with starter notes**. When installing for someone in chat, offer those same choices and ask for a folder only if they want one. Pass `--skip-vault`, `--vault "/path/to/Existing Vault"`, or `--create-vault "/path/to/New Vault"` with their native install command. An unattended install can omit all three.

To prepare the folder separately, run `./stack+ vault` in this checkout. You can also run `./stack+ vault --existing "/path/to/Existing Vault"` or `./stack+ vault --create "/path/to/New Vault"`. Choose a new name inside an existing parent folder. Existing vaults keep their own layout. New vaults include a home note, library, note template, index and canvas. For private knowledge, choose a location outside your public checkouts.

In Obsidian's vault switcher, choose **Open folder as vault** and select the folder shown by setup. In a new vault, open **Home**, follow **Library**, then copy **Templates/Knowledge Note.md** into **Library** to record a decision and its source. The notes also open in a Markdown editor. The standalone folder command is local. During native installation the selected path appears in the standard knowledge guidance. Host permissions govern access, and configuring the private writer is a separate opt-in. [Obsidian’s vault guide](https://help.obsidian.md/vault) · [Private knowledge writer](../integrations/knowledge-continuity/README.md)
2 changes: 2 additions & 0 deletions docs/OPENCODE.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,5 @@ Sources: [OpenCode agents](https://opencode.ai/docs/agents/),

The optional `--rea` shared method appears as `rea-software-analysis`. Its
[private pinned CLI](REA.md) needs no OpenCode provider or global MCP entry.

To prepare a knowledge folder for this host, run `./stack+ vault` in the Stack+ checkout. Choose an existing Obsidian folder, create one with starter notes, or skip. The host keeps its own permission settings. [Knowledge base setup](ONBOARDING.md#optional-obsidian-knowledge-base)
4 changes: 2 additions & 2 deletions docs/stackplus-selections.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ python3 xfactor.py report research-runs/smoke

The stage destination must be new. The Stack+ staging command uses Python 3.11 or newer. The staged X Factor workspace requires Python 3.10 or newer on macOS or Linux. The smoke test uses the shipped checker and should report `verified`.

To use an existing model CLI, run `./research "Your question" --model YOUR_COMMAND` inside the staged package. For a first checked run, the [model connection guide](https://github.com/nazeeh111/X-Factor/blob/f7a00959e1fcc94356864bf11250bd22b38cf26e/docs/connect.md) includes a working tool and verifier.
To use an existing model CLI, run `./research "Your question" --model YOUR_COMMAND` inside the staged package. For a first checked run, the [model connection guide](https://github.com/nazeeh111/X-Factor/blob/61e7e5827f6ccdf90da204025fbee0dea071d1b2/docs/connect.md) includes a working tool and verifier.

To install the staged engine in an existing research project, run its `research --setup --project /path/to/project`. Setup remembers when you want explanations and when you want to be consulted. It also offers three optional Stack+ skills for that project. Choose any, or skip to research. Use `--skills-dir DIR` when your host reads a different project skill directory. A host can run the staged skill on the original objective using the sibling engine. With Stack+ already installed, run `stack+ find --bundle x-factor --json "persistent X Factor investigation"` from the staged project. Use `stack+ find --bundle x-factor --instructions --read MATCH_ID` to reopen the skill. Keep the skill with its sibling engine and keep the resulting research runs with that project.
To install the staged engine in an existing research project, run its `research --setup --project /path/to/project`. Setup remembers when you want explanations and when you want to be consulted. You can connect an existing Obsidian vault, create a new one, or skip it. For a shared notebook with Stack+ starter notes, create it once with `./stack+ vault` in the Stack+ checkout, then select that folder in X Factor. After research, `research --save-note RUN` saves the checked result. Setup also offers three optional Stack+ skills for that project. Choose any, or skip to research. Use `--skills-dir DIR` when your host reads a different project skill directory. A host can run the staged skill on the original objective using the sibling engine. With Stack+ already installed, run `stack+ find --bundle x-factor --json "persistent X Factor investigation"` from the staged project. Use `stack+ find --bundle x-factor --instructions --read MATCH_ID` to reopen the skill. Keep the skill with its sibling engine and keep the resulting research runs with that project.

If your installed `stack+ find --help` lists `--root`, you can open the staged skill from a different project while honoring that project's skill rules:

Expand Down
94 changes: 94 additions & 0 deletions lib/vault_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
"""Set up a local folder for Obsidian using the shipped Stack+ notes."""

import argparse
import json
from pathlib import Path
import shutil
import sys
from tempfile import TemporaryDirectory

TEMPLATE = Path(__file__).resolve().parents[1] / "templates" / "vault"


def choose(existing=None, create=None, *, interactive=False):
"""Return a selected folder or None. Only an explicit create choice writes files."""
if existing is None and create is None and interactive:
print("Would you like an Obsidian knowledge base?\n"
" 1. Skip\n 2. Use a folder I already have\n 3. Create a vault with starter notes",
file=sys.stderr)
try:
while True:
print("Choose 1–3 [Skip]: ", end="", file=sys.stderr, flush=True)
answer = input().strip().casefold()
if answer in ("", "1", "skip"):
return None
if answer in ("2", "existing", "3", "create", "new"):
break
print("Folder path (Enter to skip): ", end="", file=sys.stderr, flush=True)
path = input().strip()
if not path:
return None
if answer in ("2", "existing"):
existing = path
else:
create = path
except EOFError:
return None

selected = create if create is not None else existing
if selected is None:
return None
if not str(selected).strip() or not str(selected).isprintable():
raise ValueError("Choose a folder with a printable path.")
path = Path(selected).expanduser()
if create is not None:
if path.exists() or path.is_symlink():
raise ValueError(f"{path} already exists. Choose the existing-folder option or a new folder name.")
parent = path.parent.resolve(strict=True)
path = parent / path.name
with TemporaryDirectory(prefix=".stack-vault-", dir=parent) as staging:
starter = Path(staging) / "notes"
shutil.copytree(TEMPLATE, starter)
starter.chmod(0o700)
Comment on lines +51 to +52

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Make copied starter notes and subdirectories writable

When vault creation runs through the installed stack+ command, install.stage() has made the shipped template files read-only (0444) and its directories non-writable (0555). shutil.copytree() preserves those permissions, and changing only the vault root to 0700 leaves the copied contents locked. Consequently, a normal user cannot edit Home or create the recommended first note inside Library. Normalize the copied files and descendant directories to user-writable modes before publishing the vault.

Useful? React with 👍 / 👎.

# Reserve the new name before publishing the complete starter tree.
# rename refuses if someone has added files to our empty reservation.
path.mkdir(mode=0o700)
try:
starter.rename(path)
except OSError:
if path.is_dir() and not path.is_symlink():
try:
path.rmdir()
except OSError:
pass # Another user has already added files.
raise
print(f"Created {path}. In Obsidian, choose “Open folder as vault” and select this folder.\n"
"Open Home, then use Templates/Knowledge Note.md for your first source-backed note.", file=sys.stderr)
else:
path = path.resolve(strict=True)
if not path.is_dir():
raise ValueError(f"Choose a folder. {path} is a file.")
print(f"Selected {path}. To open it in Obsidian, choose “Open folder as vault”.", file=sys.stderr)
return path


def arguments(parser):
group = parser.add_mutually_exclusive_group()
group.add_argument("--existing", metavar="FOLDER", help="Use an existing folder with its current notes")
group.add_argument("--create", metavar="FOLDER", help="Create a new folder with the Stack+ starter notes")
group.add_argument("--skip", action="store_true", help="Skip vault setup")


def command(args):
folder = choose(args.existing, args.create, interactive=not args.skip and sys.stdin.isatty() and sys.stderr.isatty())
print(json.dumps({"vault": str(folder) if folder else None}))
return 0


if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
arguments(parser)
try:
sys.exit(command(parser.parse_args()))
except (OSError, ValueError) as error:
parser.exit(1, f"{error}\n")
Loading