thought-cabinet 0.1.13 → 0.2.1

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.
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # onboard.sh — Pre-flight checks, thoughts init, and verification for the onboard skill.
5
+ #
6
+ # Usage: bash onboard.sh [--force] [--verify-only]
7
+ # --force Re-initialize thoughts even if already set up
8
+ # --verify-only Skip init, only run verification
9
+ #
10
+ # Exit codes:
11
+ # 0 Success (init completed or already set up)
12
+ # 1 Fatal error (not a git repo, thc missing, init failed)
13
+ # 2 Thoughts already initialized, AGENTS.md not found (agent memory needed)
14
+ # 3 Thoughts already initialized, AGENTS.md exists (fully onboarded)
15
+
16
+ FORCE=false
17
+ VERIFY_ONLY=false
18
+ for arg in "$@"; do
19
+ case "$arg" in
20
+ --force) FORCE=true ;;
21
+ --verify-only) VERIFY_ONLY=true ;;
22
+ esac
23
+ done
24
+
25
+ # --- Helpers ---
26
+
27
+ resolve_thc() {
28
+ if command -v thc > /dev/null 2>&1; then
29
+ echo "thc"
30
+ elif command -v thoughtcabinet > /dev/null 2>&1; then
31
+ echo "thoughtcabinet"
32
+ else
33
+ echo ""
34
+ fi
35
+ }
36
+
37
+ check_status() {
38
+ [ -L thoughts/shared ] && THOUGHTS=true || THOUGHTS=false
39
+ [ -f AGENTS.md ] && MEMORY=true || MEMORY=false
40
+
41
+ echo "thoughts: $([ "$THOUGHTS" = true ] && echo initialized || echo 'not initialized')"
42
+ echo "memory: $([ "$MEMORY" = true ] && echo exists || echo 'not found')"
43
+ }
44
+
45
+ verify() {
46
+ echo "=== Onboarding Status ==="
47
+ local issues=0
48
+
49
+ if [ -L thoughts/shared ] && [ -L thoughts/global ]; then
50
+ echo "[OK] thoughts/ initialized"
51
+ else
52
+ echo "[FAIL] thoughts/ not initialized"
53
+ issues=$((issues + 1))
54
+ fi
55
+
56
+ [ -f AGENTS.md ] && echo "[OK] AGENTS.md created" || echo "[SKIP] AGENTS.md not created"
57
+
58
+ if [ -L CLAUDE.md ]; then echo "[OK] CLAUDE.md symlink"
59
+ elif [ -f CLAUDE.md ]; then echo "[OK] CLAUDE.md exists"
60
+ else echo "[SKIP] CLAUDE.md not created"; fi
61
+
62
+ local git_dir
63
+ git_dir=$(git rev-parse --git-common-dir 2>/dev/null)
64
+ [ -f "$git_dir/hooks/pre-commit" ] && echo "[OK] pre-commit hook" || echo "[WARN] no pre-commit hook"
65
+ [ -f "$git_dir/hooks/post-commit" ] && echo "[OK] post-commit hook" || echo "[WARN] no post-commit hook"
66
+
67
+ echo "=== Done ==="
68
+ return "$issues"
69
+ }
70
+
71
+ # --- Main ---
72
+
73
+ # Pre-flight: git repo
74
+ if ! git rev-parse --git-dir > /dev/null 2>&1; then
75
+ echo "FATAL: Not a git repository. Run 'git init' first."
76
+ exit 1
77
+ fi
78
+
79
+ # Pre-flight: thc availability
80
+ THC_CMD=$(resolve_thc)
81
+ if [ -z "$THC_CMD" ]; then
82
+ echo "FATAL: thc is not installed or not in PATH."
83
+ exit 1
84
+ fi
85
+
86
+ # Verify-only mode
87
+ if [ "$VERIFY_ONLY" = true ]; then
88
+ verify
89
+ exit $?
90
+ fi
91
+
92
+ # Status check
93
+ check_status
94
+
95
+ # Initialize thoughts
96
+ if [ "$THOUGHTS" = true ] && [ "$FORCE" = false ]; then
97
+ echo "SKIP: thoughts/ already initialized."
98
+ if [ "$MEMORY" = true ]; then
99
+ exit 3
100
+ else
101
+ exit 2
102
+ fi
103
+ fi
104
+
105
+ INIT_FLAGS="--directory $(basename "$(pwd)")"
106
+ [ "$FORCE" = true ] && INIT_FLAGS="$INIT_FLAGS --force"
107
+ $THC_CMD init $INIT_FLAGS
108
+
109
+ # Verify init succeeded
110
+ if [ -L thoughts/shared ] && [ -L thoughts/global ]; then
111
+ echo "OK: thoughts/ initialized."
112
+ else
113
+ echo "FATAL: thoughts/ init failed — symlinks not created."
114
+ exit 1
115
+ fi
116
+
117
+ # Return based on memory status
118
+ [ -f AGENTS.md ] && exit 3 || exit 2
@@ -198,4 +198,9 @@ When working within a plan phase:
198
198
 
199
199
  The phase's automated verification is the final gate. TDD cycles happen within that gate, not instead of it.
200
200
 
201
- **When the plan says tests aren't needed**: Evaluate independently — apply TDD unless genuinely untestable (pure wiring, no behavioral logic). Document any skip with a reason in the phase completion message.
201
+ **When the plan says tests aren't needed**: Evaluate independently — the plan may be wrong. Read existing test files first. Apply TDD unless the code meets ALL of these criteria:
202
+ 1. Zero conditional logic (no if/else, switches, ternaries, or loops with conditions)
203
+ 2. Zero data transformation (no mapping, filtering, formatting, restructuring)
204
+ 3. The function is a pure pass-through calling already-tested functions with static arguments
205
+
206
+ "Wiring", "integration-level", "mostly delegation", and "would require too many mocks" are NOT valid skip reasons. Document any skip with the specific criterion (1-3) that applies.
@@ -0,0 +1,205 @@
1
+ ---
2
+ name: test-skill-e2e
3
+ description: End-to-end smoke test a ThoughtCabinet skill by deploying it to a target agent, running the agent non-interactively against a test project, capturing output, and evaluating results. Use when you want to verify a skill works correctly before shipping.
4
+ ---
5
+
6
+ # End-to-End Skill Testing
7
+
8
+ Smoke test a ThoughtCabinet skill by deploying it to a target agent CLI, invoking the agent non-interactively against a real project, capturing all output, and evaluating results.
9
+
10
+ ## Workflow Overview
11
+
12
+ 1. **Gather inputs** - Determine which skill, which agent, and which project to test against
13
+ 2. **Deploy skills** - Copy all bundled skills into the agent's project-level skill directory
14
+ 3. **Prepare test environment** - Clean up artifacts from prior runs
15
+ 4. **Execute agent** - Run the agent CLI non-interactively with the skill prompt
16
+ 5. **Evaluate results** - Read captured output and generate a pass/fail summary
17
+
18
+ ## Step 1: Gather Inputs
19
+
20
+ Determine three things from the user or surrounding context:
21
+
22
+ | Input | Example |
23
+ |-------|---------|
24
+ | Skill to test | `onboard`, or path like `src/agent-assets/skills/onboard/SKILL.md` |
25
+ | Agent CLI | `codex`, `claude` |
26
+
27
+ Once identified, read the target skill's SKILL.md to understand:
28
+ - What the skill does (description, workflow steps)
29
+ - What artifacts it creates (files, directories, symlinks)
30
+ - What verification checks it performs (look for `[OK]`/`[FAIL]` markers)
31
+
32
+ ```bash
33
+ # Example: read the skill under test
34
+ cat src/agent-assets/skills/<skill-name>/SKILL.md
35
+ ```
36
+
37
+ This understanding is essential for Steps 3 and 5.
38
+
39
+ ## Step 2: Deploy Skills
40
+
41
+ Copy **all** bundled skills from the ThoughtCabinet source tree into the agent's project-level skill directory. Include all skills (not just the one under test) because skills may reference each other.
42
+
43
+ Agent skill directory conventions:
44
+
45
+ | Agent | Directory |
46
+ |-------|-----------|
47
+ | Codex | `<project>/.codex/skills/<skill-name>/` |
48
+ | Claude Code | `<project>/.claude/skills/<skill-name>/` |
49
+ | Cline | `<project>/.cline/skills/<skill-name>/` |
50
+
51
+ ```bash
52
+ # Example: deploy all skills for Codex
53
+ THC_SRC="/path/to/thought-cabinet/src/agent-assets/skills"
54
+ PROJECT="/path/to/test-project"
55
+ AGENT_SKILLS="$PROJECT/.codex/skills"
56
+
57
+ for skill_dir in "$THC_SRC"/*/; do
58
+ skill_name=$(basename "$skill_dir")
59
+ mkdir -p "$AGENT_SKILLS/$skill_name"
60
+ cp "$skill_dir"SKILL.md "$AGENT_SKILLS/$skill_name/SKILL.md"
61
+ done
62
+ ```
63
+
64
+ Verify deployment:
65
+
66
+ ```bash
67
+ ls -la "$AGENT_SKILLS"
68
+ ```
69
+
70
+ ## Step 3: Prepare Test Environment
71
+
72
+ Clean up artifacts from prior runs so the test starts from a known state. Use the skill's SKILL.md (read in Step 1) to determine what to remove.
73
+
74
+ Common cleanup actions by skill type:
75
+
76
+ ```bash
77
+ cd "$PROJECT"
78
+
79
+ # For onboard skill
80
+ thc destroy --force 2>/dev/null || true
81
+ rm -f AGENTS.md
82
+ rm -f CLAUDE.md
83
+ rm -rf docs/architectural-patterns.md
84
+
85
+ # For init-agent-memory skill
86
+ rm -f AGENTS.md
87
+ rm -f CLAUDE.md
88
+ rm -rf docs/architectural-patterns.md
89
+
90
+ # Generic: remove thoughts artifacts
91
+ rm -rf thoughts/
92
+ ```
93
+
94
+ Verify the starting state is clean:
95
+
96
+ ```bash
97
+ echo "=== Pre-test state ==="
98
+ [ ! -d thoughts ] && echo "[OK] no thoughts/" || echo "[WARN] thoughts/ still exists"
99
+ [ ! -f AGENTS.md ] && echo "[OK] no AGENTS.md" || echo "[WARN] AGENTS.md still exists"
100
+ [ ! -f CLAUDE.md ] && echo "[OK] no CLAUDE.md" || echo "[WARN] CLAUDE.md still exists"
101
+ ```
102
+
103
+ All checks should show `[OK]` before proceeding.
104
+
105
+ ## Step 4: Execute Agent
106
+
107
+ Run the agent CLI non-interactively with full permissions, instructing it to invoke the skill. Stream all output to a timestamped log file via `tee`.
108
+
109
+ ### Build the prompt
110
+
111
+ The prompt should instruct the agent to invoke the target skill:
112
+
113
+ ```
114
+ Invoke the <skill-name> skill to <summary of what the skill does>.
115
+ ```
116
+
117
+ ### Agent invocation patterns
118
+
119
+ | Agent | Command |
120
+ |-------|---------|
121
+ | Codex | `codex exec --dangerously-bypass-approvals-and-sandbox "<prompt>"` |
122
+ | Claude Code | `claude -p "<prompt>" --dangerously-skip-permissions` |
123
+
124
+ ### Run with output capture
125
+
126
+ ```bash
127
+ LOGFILE="test-$(date +%Y%m%d-%H%M%S)-<skill-name>.log"
128
+
129
+ # Codex example
130
+ codex exec --dangerously-bypass-approvals-and-sandbox \
131
+ "Invoke the onboard skill to initialize ThoughtCabinet and bootstrap agent memory." \
132
+ 2>&1 | tee "$LOGFILE"
133
+
134
+ # Claude Code example
135
+ claude -p \
136
+ "Invoke the onboard skill to initialize ThoughtCabinet and bootstrap agent memory." \
137
+ --dangerously-skip-permissions \
138
+ 2>&1 | tee "$LOGFILE"
139
+ ```
140
+
141
+ Wait for the agent to complete. Do not interrupt it.
142
+
143
+ ## Step 5: Evaluate Results
144
+
145
+ Read the log file end-to-end and assess:
146
+
147
+ ```bash
148
+ cat "$LOGFILE"
149
+ ```
150
+
151
+ ### Evaluation checklist
152
+
153
+ | Check | What to look for |
154
+ |-------|-----------------|
155
+ | Skill discovery | Agent found and read the SKILL.md |
156
+ | Step execution | Each numbered workflow step was attempted |
157
+ | No errors | No stack traces, permission blocks, or sandbox violations |
158
+ | Artifact creation | Expected files/directories exist on disk |
159
+ | Verification markers | `[OK]` markers in output; no `[FAIL]` markers |
160
+
161
+ ### Verify artifacts on disk
162
+
163
+ ```bash
164
+ echo "=== Post-test verification ==="
165
+ # Adapt these checks to the skill under test
166
+
167
+ # For onboard skill
168
+ [ -L thoughts/shared ] && echo "[OK] thoughts/shared symlink" || echo "[FAIL] thoughts/shared missing"
169
+ [ -L thoughts/global ] && echo "[OK] thoughts/global symlink" || echo "[FAIL] thoughts/global missing"
170
+ [ -f AGENTS.md ] && echo "[OK] AGENTS.md exists" || echo "[FAIL] AGENTS.md missing"
171
+ [ -e CLAUDE.md ] && echo "[OK] CLAUDE.md exists" || echo "[FAIL] CLAUDE.md missing"
172
+ ```
173
+
174
+ ### Generate summary
175
+
176
+ Produce a clear pass/fail report:
177
+
178
+ ```
179
+ === Test Results: <skill-name> ===
180
+ Agent: <agent-name>
181
+ Project: <project-path>
182
+ Log: <logfile-path>
183
+
184
+ Step 1 (Pre-flight): PASS
185
+ Step 2 (Init thoughts): PASS
186
+ Step 3 (Bootstrap memory): PASS
187
+ Step 4 (Verify): PASS
188
+
189
+ Overall: PASS (4/4 steps)
190
+ Notes: <any observations>
191
+ ```
192
+
193
+ If any step failed, include the relevant log excerpt and suggested remediation.
194
+
195
+ ## Guidelines
196
+
197
+ **Idempotent cleanup**: The prepare step (Step 3) should make the test fully repeatable. Running the test twice in a row should produce the same result.
198
+
199
+ **Log everything**: Always capture output to a file. Agent output in terminals can scroll away or be lost.
200
+
201
+ **Read the skill first**: Understanding expected outcomes (Step 1) is essential for meaningful evaluation (Step 5). Do not skip this.
202
+
203
+ **One skill per run**: Test skills individually for clear signal. If you need to test multiple skills, run this workflow once per skill.
204
+
205
+ **Adapt checks to the skill**: The cleanup and verification examples above are for the `onboard` skill. For other skills, derive the appropriate checks from the skill's SKILL.md.
@@ -0,0 +1,207 @@
1
+ ---
2
+ name: writing-skill
3
+ description: Create, revise, or distill workflows into skills following best practices. Use when user asks to create a new skill, iterate on an existing skill, distill a session workflow into a reusable skill, or improve skill quality.
4
+ ---
5
+
6
+ # Writing Skills
7
+
8
+ Create new skills, revise existing ones, or distill workflows into reusable skills. Follow [best practices](best-practices.md) and use [skill-template](skill-template.md).
9
+
10
+ ## Workflow Context
11
+
12
+ This meta-skill produces skills. Common skill patterns:
13
+ - **Complex workflow** — Multiple phases, planning/implementation/validation
14
+ - **Research/synthesis** — Discovery, analysis, pattern extraction
15
+ - **Simple imperative** — Single task, straightforward execution
16
+ - **Integration-focused** — Modifies/enhances other workflows
17
+
18
+ **Skills are saved to your Thought Cabinet skills directory**:
19
+ - `~/.thought-cabinet/skills/` (new)
20
+ - `~/.config/thought-cabinet/skills/` (legacy, if config exists there)
21
+
22
+ ## Determine the Mode
23
+
24
+ Infer from user query:
25
+ - "create", "new", "write" → Step 1
26
+ - "revise", "update", "fix", "improve", "modify" → Step 2
27
+ - "distill", "extract", "turn into skill" → Step 3
28
+
29
+ Only ask if ambiguous.
30
+
31
+ ---
32
+
33
+ ## Step 1: Create New Skill
34
+
35
+ ### 1a. Requirements
36
+
37
+ Only ask what user hasn't provided:
38
+ - Task automated/guided
39
+ - Trigger contexts (words/situations)
40
+ - Inputs needed and outputs produced
41
+ - Relation to existing skills
42
+
43
+ ### 1b. Resolve Skills Directory
44
+
45
+ ```bash
46
+ # Check for existing config
47
+ if [ -f ~/.thought-cabinet/config.json ]; then
48
+ export THC_SKILLS_DIR=~/.thought-cabinet/skills
49
+ elif [ -f ~/.config/thought-cabinet/config.json ]; then
50
+ export THC_SKILLS_DIR=~/.config/thought-cabinet/skills
51
+ else
52
+ export THC_SKILLS_DIR=~/.thought-cabinet/skills
53
+ fi
54
+
55
+ mkdir -p "$THC_SKILLS_DIR"
56
+ ```
57
+
58
+ Save to `$THC_SKILLS_DIR/[skill-name]/`.
59
+
60
+ ### 1c. Research Patterns
61
+
62
+ Spawn parallel sub-agents to searche for analog skills in skill directories:
63
+ - `$THC_SKILLS_DIR`
64
+ - agent skill directories, e.g. `~/.claude/skills/` and `.claude/skills/` for Claude Code
65
+
66
+ **Choose analog** based on characteristics:
67
+ - Multi-phase workflow → find complex workflow skills
68
+ - Simple imperative → find single-task skills
69
+ - Research/synthesis → find discovery/analysis skills
70
+ - Integration-focused → find skills that modify/enhance other workflows
71
+
72
+ ### 1d. Design Present
73
+
74
+ ```
75
+ **Name**: kebab-case-name
76
+ **Description**: Third-person, specific, includes triggers
77
+ **Modeled after**: [skill pattern] + rationale
78
+ **Save to**: $THC_SKILLS_DIR/[skill-name]
79
+
80
+ **Workflow**:
81
+ 1. Step - action
82
+ 2. Step - action
83
+
84
+ **Integration**: how it connects
85
+
86
+ **Files**: SKILL.md, [supplements + rationale]
87
+
88
+ Confirm before writing?
89
+ ```
90
+
91
+ ### 1e. Write
92
+
93
+ 1. Create `$THC_SKILLS_DIR/[skill-name]/`
94
+ 2. Write SKILL.md following template
95
+ 3. Add supplementary files
96
+ 4. Verify against analog skill
97
+
98
+ ### 1f. Quality Check
99
+
100
+ Run the checklist from best-practices.md:
101
+ - [ ] Description specific with triggers
102
+ - [ ] Under 500 lines
103
+ - [ ] Concise (no unnecessary explanations)
104
+ - [ ] Consistent terminology
105
+ - [ ] One-level references
106
+ - [ ] Clear workflow steps
107
+ - [ ] Integrates naturally
108
+
109
+ ```
110
+ Created: $THC_SKILLS_DIR/[name]/SKILL.md
111
+ Key decisions: [rationales]
112
+ Quality: [x] passes checklist
113
+ ```
114
+
115
+ ### 1g. Install Skill
116
+
117
+ Make the skill available:
118
+
119
+ ```bash
120
+ thc skill install --target [agent-name] --force
121
+ ```
122
+
123
+ ---
124
+
125
+ ## Step 2: Revise Existing Skill
126
+
127
+ ### 2a. Locate Skills Directory
128
+
129
+ Resolve directory (Step 1b), then list available skills:
130
+ ```bash
131
+ ls -la "$THC_SKILLS_DIR"
132
+ ```
133
+
134
+ ### 2b. Audit
135
+
136
+ Read SKILL.md and best-practices.md.
137
+
138
+ ```
139
+ **Strengths**: [what works]
140
+ **Issues**: [specific problems from checklist]
141
+ **Changes**: 1. [change] 2. [change]
142
+
143
+ Which changes?
144
+ ```
145
+
146
+ ### 2c. Apply
147
+
148
+ Make surgical edits to `$THC_SKILLS_DIR/[skill-name]/`. Maintain structure unless changing it.
149
+
150
+ ```
151
+ Updated [skill-name]:
152
+ - [change 1]
153
+ - [change 2]
154
+ Quality check passed. Further?
155
+ ```
156
+
157
+ ---
158
+
159
+ ## Step 3: Distill Session Workflow
160
+
161
+ ### 3a. Extract
162
+
163
+ ```
164
+ **Task pattern**: what we did
165
+ **Steps**: 1. [step] 2. [step]
166
+ **Context needed**: what helps future runs
167
+ **Proposed name**: kebab-case-name
168
+ Save to: $THC_SKILLS_DIR/[name]/
169
+ Create?
170
+ ```
171
+
172
+ ### 3b. Generalize
173
+
174
+ Replace specifics with patterns, frameworks. Remove session artifacts.
175
+
176
+ ### 3c. Write
177
+
178
+ Resolve directory (Step 1b), then follow Step 1e-1g.
179
+
180
+ ---
181
+
182
+ ## Sync to Source (thought-cabinet repo only)
183
+
184
+ After creating, revising, or distilling a skill, check if you're working inside the `thought-cabinet` repository:
185
+
186
+ ```bash
187
+ # Check if src/agent-assets/skills/ exists in the repo root
188
+ if [ -d "$(git rev-parse --show-toplevel 2>/dev/null)/src/agent-assets/skills" ]; then
189
+ REPO_ROOT="$(git rev-parse --show-toplevel)"
190
+ # Copy the skill directory into the bundled assets
191
+ cp -r "$THC_SKILLS_DIR/[skill-name]" "$REPO_ROOT/src/agent-assets/skills/[skill-name]"
192
+ fi
193
+ ```
194
+
195
+ This ensures new or updated skills are tracked in `src/agent-assets/skills/` for packaging and distribution. The copy goes into the repo's working tree — it is NOT committed automatically.
196
+
197
+ ---
198
+
199
+ ## Guidelines
200
+
201
+ **Conciseness**: Challenge every paragraph — does it justify its token cost?
202
+
203
+ **Integration**: Reference related skills in Workflow Context. Match tone/structure to analog.
204
+
205
+ **Iterate**: Ship minimal working skill, refine from usage.
206
+
207
+ **Config Compatibility**: Check `~/.thought-cabinet/` (new) and `~/.config/thought-cabinet/` (legacy). Use existing location; default to new.