@rubytech/create-maxy-code 0.1.185 → 0.1.186

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": "@rubytech/create-maxy-code",
3
- "version": "0.1.185",
3
+ "version": "0.1.186",
4
4
  "description": "Install Maxy — AI for Productive People",
5
5
  "bin": {
6
6
  "create-maxy-code": "./dist/index.js"
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env bash
2
+ # Regression test for prompt-optimiser-directive.sh.
3
+ #
4
+ # Covers:
5
+ # 1. Valid UserPromptSubmit stdin -> exit 0, stdout is valid JSON,
6
+ # hookEventName == "UserPromptSubmit", additionalContext non-empty.
7
+ # 2. Empty / garbage stdin -> exit 0, still valid JSON (the hook
8
+ # ignores the prompt text; the directive is standing).
9
+ # 3. python3 unavailable on PATH -> exit 0, empty stdout (fail-open).
10
+
11
+ set -u
12
+
13
+ HOOK="$(cd "$(dirname "$0")/.." && pwd)/prompt-optimiser-directive.sh"
14
+ if [[ ! -x "$HOOK" ]]; then
15
+ echo "FAIL: $HOOK not executable" >&2
16
+ exit 1
17
+ fi
18
+
19
+ PASS=0
20
+ FAIL=0
21
+
22
+ # Assert: hook on $1 (stdin) exits 0 and stdout is JSON with a non-empty
23
+ # additionalContext and the correct hookEventName.
24
+ assert_valid_injection() {
25
+ local name="$1" stdin="$2" out actual_exit
26
+ out=$(printf '%s' "$stdin" | bash "$HOOK" 2>/dev/null)
27
+ actual_exit=$?
28
+ if [[ "$actual_exit" -ne 0 ]]; then
29
+ echo "FAIL: $name (expected exit=0, got=$actual_exit)" >&2; FAIL=$((FAIL+1)); return
30
+ fi
31
+ if printf '%s' "$out" | python3 -c '
32
+ import json, sys
33
+ d = json.load(sys.stdin)
34
+ h = d["hookSpecificOutput"]
35
+ assert h["hookEventName"] == "UserPromptSubmit", "wrong hookEventName"
36
+ assert isinstance(h["additionalContext"], str) and len(h["additionalContext"]) > 0, "empty additionalContext"
37
+ ' 2>/dev/null; then
38
+ echo "PASS: $name"; PASS=$((PASS+1))
39
+ else
40
+ echo "FAIL: $name (stdout not valid directive JSON: $out)" >&2; FAIL=$((FAIL+1))
41
+ fi
42
+ }
43
+
44
+ # Case 1 — valid UserPromptSubmit envelope.
45
+ assert_valid_injection "valid UserPromptSubmit stdin -> directive JSON" \
46
+ '{"hook_event_name":"UserPromptSubmit","prompt":"fix the thing","session_id":"abc"}'
47
+
48
+ # Case 2 — garbage stdin still yields the standing directive.
49
+ assert_valid_injection "garbage stdin -> still directive JSON" \
50
+ 'not json at all'
51
+
52
+ # Case 3 — fail-open when python3 is absent from PATH.
53
+ FAKEBIN=$(mktemp -d)
54
+ # A minimal PATH containing the core utils the hook needs (cat, printf, env,
55
+ # command) but NOT python3. Resolve their real dir(s) and symlink them in.
56
+ for util in cat printf env bash; do
57
+ src=$(command -v "$util" 2>/dev/null) && ln -sf "$src" "$FAKEBIN/$util" 2>/dev/null
58
+ done
59
+ nopy_out=$(printf '%s' '{"prompt":"x"}' | PATH="$FAKEBIN" bash "$HOOK" 2>/dev/null)
60
+ nopy_exit=$?
61
+ if [[ "$nopy_exit" -eq 0 && -z "$nopy_out" ]]; then
62
+ echo "PASS: python3 absent -> exit 0, empty stdout (fail-open)"; PASS=$((PASS+1))
63
+ else
64
+ echo "FAIL: python3 absent (expected exit=0 + empty stdout, got exit=$nopy_exit stdout=$nopy_out)" >&2; FAIL=$((FAIL+1))
65
+ fi
66
+ rm -rf "$FAKEBIN"
67
+
68
+ echo "----"
69
+ echo "PASS=$PASS FAIL=$FAIL"
70
+ [[ "$FAIL" -eq 0 ]]
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env bash
2
+ # UserPromptSubmit hook: inject the standing prompt-optimiser directive as
3
+ # additionalContext on every turn, so the agent restates each non-trivial
4
+ # prompt via the prompt-optimiser skill before acting on it. Mirrors
5
+ # doctrine.sh: emit hookSpecificOutput.additionalContext via python3,
6
+ # fail-open with exit 0.
7
+ #
8
+ # Compliance is behavioural, not deterministic. A hook cannot force a skill
9
+ # call; the directive steers the agent, it does not gate the turn. The raw
10
+ # prompt always still reaches the model (UserPromptSubmit output is ADDED to
11
+ # the prompt, never substituted), so "the restatement governs" is an
12
+ # instruction to the agent, not a removal of the original text.
13
+ #
14
+ # Input (stdin, UserPromptSubmit contract): { "prompt": "...", ... } — drained
15
+ # and ignored; the directive is standing and prompt-independent.
16
+ # Output (stdout JSON):
17
+ # { "hookSpecificOutput": { "hookEventName": "UserPromptSubmit",
18
+ # "additionalContext": "<directive>" } }
19
+ #
20
+ # Fail-open: if python3 is unavailable or JSON encoding fails, exit 0 with no
21
+ # stdout. The hook must never block or corrupt a turn.
22
+
23
+ set -uo pipefail
24
+
25
+ # Drain stdin; the directive does not depend on the prompt text.
26
+ cat >/dev/null 2>&1 || true
27
+
28
+ # Fail-open if the JSON encoder is unavailable.
29
+ command -v python3 >/dev/null 2>&1 || exit 0
30
+
31
+ DIRECTIVE=$(cat <<'DIRECTIVE_EOF'
32
+ PROMPT-OPTIMISER DIRECTIVE (standing)
33
+ Before acting on this turn's request, run the prompt-optimiser skill on the user's raw prompt in its in-session restatement mode, then treat the restated task as the authoritative statement of what was asked and proceed from it. Set aside your own first reading of the raw wording; the restatement governs. The raw prompt stays in context for reference only.
34
+ Skip the restatement when the prompt is a one-word confirmation, a slash-command invocation, or a direct continuation of the immediately preceding turn; restatement adds nothing in those cases.
35
+ DIRECTIVE_EOF
36
+ )
37
+
38
+ OUT=$(printf '%s' "$DIRECTIVE" | python3 -c '
39
+ import json, sys
40
+ ctx = sys.stdin.read()
41
+ print(json.dumps({
42
+ "hookSpecificOutput": {
43
+ "hookEventName": "UserPromptSubmit",
44
+ "additionalContext": ctx,
45
+ }
46
+ }))
47
+ ' 2>/dev/null) || exit 0
48
+
49
+ [ -n "$OUT" ] || exit 0
50
+ printf '%s\n' "$OUT"
51
+ echo "[prompt-optimiser-directive] injected len=${#DIRECTIVE}" >&2
52
+ exit 0
@@ -24,7 +24,7 @@ These are part of {{productName}}'s foundation and cannot be disabled:
24
24
  | `tasks` | Task lifecycle — create, update, list, relate, complete |
25
25
  | `workflows` | Persistent named workflows — reusable instruction sets |
26
26
  | `contacts` | CRM contact management — create, lookup, update, list |
27
- | `prompt-optimiser` | Prompt optimiser — turns a rough draft or task description into a single finished, copy-pasteable prompt tuned for Opus 4.7 adaptive thinking in the chat app (claude.ai, Mac, iOS) |
27
+ | `prompt-optimiser` | Prompt optimiser — two modes. Chat-app mode turns a rough draft or task description into a single finished, copy-pasteable prompt tuned for Opus 4.7 adaptive thinking (claude.ai, Mac, iOS). In-session mode is applied automatically: a standing `UserPromptSubmit` directive hook (`admin/hooks/prompt-optimiser-directive.sh`) injects context every turn telling the admin agent to restate each non-trivial prompt through this skill and act on the restatement, skipped for one-word confirmations, slash-commands, and direct continuations. Compliance is behavioural — the hook steers the agent, it cannot force the skill call. |
28
28
  | `url-get` | Faithful page retrieval — fetches a server-rendered page, writes a verbatim markdown copy to an account-scoped reference file (no model in the path, so no copyright refusal), and returns a transformative summary plus the file path. Use instead of WebFetch when a faithful copy is needed (e.g. ingesting your own published writing). |
29
29
 
30
30
  ### {{productName}} Plugins (user-selectable)
@@ -9,6 +9,21 @@ You turn whatever the user gives you — a rough draft, a vague idea, a task des
9
9
 
10
10
  This is for the **chat app** (claude.ai, Mac, iOS), not the API. The user is going to paste a single message into chat. There is no system prompt, no `effort` parameter, no tool config to tune. The prompt itself has to do all the work.
11
11
 
12
+ ## Which mode are you in? (read this first)
13
+
14
+ This skill is invoked two ways, and they want opposite outputs. Decide which one applies before doing anything else.
15
+
16
+ **In-session restatement mode.** You are invoking this skill on the current turn's own user prompt — triggered by the standing prompt-optimiser directive — so that you can act on a sharper reading of what was just asked. The output is for *you*, the working agent, not for a human to paste anywhere. Produce a plain restated task and nothing else:
17
+
18
+ - Restate what the user is actually asking for: the goal, the constraints they stated, and the format or scope if they gave one. Turn vague wording into concrete intent, grounded only in what they wrote plus the conversation context you already hold.
19
+ - Write it as plain prose or a short bulleted brief. No fenced code block. No role line, no XML tags, no length-cap ceremony unless the user asked for one.
20
+ - Do not end with "Think before answering". Do not ask the user to paste anything — you already have the content and the context.
21
+ - Do not invent requirements or add scope the user did not ask for. If the prompt was already clear, say so in one line and restate it tightly.
22
+
23
+ Then do the work from the restated task. Everything below this section is for the other mode and does not apply — stop reading here.
24
+
25
+ **Chat-app prompt mode.** The user explicitly asked you to write, rewrite, or optimise a prompt they will paste into the chat app. That is the rest of this document: a single finished, copy-pasteable prompt in a code block ending in "Think before answering". Read on.
26
+
12
27
  ## Two hard rules
13
28
 
14
29
  These two rules override everything else in this skill. Read them, then re-read them.
@@ -143,7 +143,8 @@ cat > "$ACCOUNT_SETTINGS" << SETTINGS_EOF
143
143
  "UserPromptSubmit": [
144
144
  {
145
145
  "hooks": [
146
- { "type": "command", "command": "bash $HOOKS_PATH/archive-ingest-surface-gate.sh" }
146
+ { "type": "command", "command": "bash $HOOKS_PATH/archive-ingest-surface-gate.sh" },
147
+ { "type": "command", "command": "bash $HOOKS_PATH/prompt-optimiser-directive.sh" }
147
148
  ]
148
149
  }
149
150
  ],