@looplia/looplia-cli 0.6.6

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.
Files changed (34) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +33216 -0
  3. package/package.json +55 -0
  4. package/plugins/looplia-core/.claude-plugin/plugin.json +10 -0
  5. package/plugins/looplia-core/commands/build-workflow.md +92 -0
  6. package/plugins/looplia-core/commands/build.md +71 -0
  7. package/plugins/looplia-core/commands/list-workflows.md +55 -0
  8. package/plugins/looplia-core/commands/run.md +50 -0
  9. package/plugins/looplia-core/hooks/hooks.json +27 -0
  10. package/plugins/looplia-core/scripts/hooks/compact-inject-state.sh +36 -0
  11. package/plugins/looplia-core/scripts/hooks/post-write-validate.sh +81 -0
  12. package/plugins/looplia-core/scripts/hooks/stop-guard.sh +56 -0
  13. package/plugins/looplia-core/skills/plugin-registry-scanner/SKILL.md +108 -0
  14. package/plugins/looplia-core/skills/plugin-registry-scanner/scripts/scan-plugins.ts +221 -0
  15. package/plugins/looplia-core/skills/plugin-registry-scanner/test/scan-plugins.test.ts +256 -0
  16. package/plugins/looplia-core/skills/search/SKILL.md +174 -0
  17. package/plugins/looplia-core/skills/skill-capability-matcher/SKILL.md +378 -0
  18. package/plugins/looplia-core/skills/workflow-executor/SKILL.md +469 -0
  19. package/plugins/looplia-core/skills/workflow-executor-inline/SKILL.md +217 -0
  20. package/plugins/looplia-core/skills/workflow-schema-composer/SCHEMA.md +214 -0
  21. package/plugins/looplia-core/skills/workflow-schema-composer/SKILL.md +373 -0
  22. package/plugins/looplia-core/skills/workflow-schema-composer/templates/workflow.md.template +44 -0
  23. package/plugins/looplia-core/skills/workflow-validator/SKILL.md +171 -0
  24. package/plugins/looplia-core/skills/workflow-validator/scripts/validate.ts +244 -0
  25. package/plugins/looplia-writer/.claude-plugin/plugin.json +10 -0
  26. package/plugins/looplia-writer/README.md +107 -0
  27. package/plugins/looplia-writer/skills/content-documenter/SKILL.md +189 -0
  28. package/plugins/looplia-writer/skills/id-generator/SKILL.md +120 -0
  29. package/plugins/looplia-writer/skills/idea-synthesis/SKILL.md +162 -0
  30. package/plugins/looplia-writer/skills/media-reviewer/SKILL.md +105 -0
  31. package/plugins/looplia-writer/skills/user-profile-reader/SKILL.md +94 -0
  32. package/plugins/looplia-writer/skills/writing-enhancer/SKILL.md +34 -0
  33. package/plugins/looplia-writer/skills/writing-kit-assembler/SKILL.md +206 -0
  34. package/plugins/looplia-writer/workflows/writing-kit.md +134 -0
@@ -0,0 +1,171 @@
1
+ ---
2
+ name: workflow-validator
3
+ description: |
4
+ This skill should be used when the user wants to validate a looplia workflow output,
5
+ check if an artifact meets validation criteria, or debug validation failures. Use when
6
+ someone says "validate this looplia output", "check if the workflow output is valid",
7
+ "verify the artifact JSON", or "debug why validation failed".
8
+
9
+ Runs deterministic validation scripts against JSON artifacts. Primarily used for manual
10
+ retry/debugging since automatic validation is handled by PostToolUse hooks. Part of
11
+ looplia's one step → one skill-executor → multiple skills architecture.
12
+ ---
13
+
14
+ # Workflow Validator Skill
15
+
16
+ Validates JSON artifacts against validation criteria using deterministic script execution.
17
+
18
+ ## Automatic Validation via Hook (v0.6.0)
19
+
20
+ As of v0.6.0, the `PostToolUse:Write` hook **automatically** calls this validation script whenever an artifact is written to `sandbox/*/outputs/*.json`.
21
+
22
+ **You typically don't need to manually invoke this skill** - the hook handles it.
23
+
24
+ ### When to Manually Use This Skill
25
+
26
+ Use this skill only in these scenarios:
27
+ - **Retrying after validation failure** - when the hook blocked a write and you need to debug
28
+ - **Debugging validation issues** - to see detailed check results
29
+ - **Checking artifacts outside the normal workflow** - for ad-hoc validation
30
+ - **Pre-checking before write** - to validate data before writing to sandbox
31
+
32
+ ## What This Skill Does
33
+
34
+ - Reads validation criteria from `sandbox/{id}/validation.json`
35
+ - Runs deterministic validation script (no LLM tokens consumed)
36
+ - Returns pass/fail status with detailed check results
37
+ - Enables workflow completion verification
38
+
39
+ ## Validation Process
40
+
41
+ ### Step 1: Read Validation Criteria
42
+
43
+ Read the validation manifest at `sandbox/{id}/validation.json`:
44
+
45
+ ```json
46
+ {
47
+ "workflow": "writing-kit",
48
+ "version": "1.0.0",
49
+ "sandboxId": "article-2025-12-18-xk7m",
50
+ "steps": {
51
+ "summary": {
52
+ "output": "outputs/summary.json",
53
+ "validate": {
54
+ "required_fields": ["contentId", "headline", "tldr", "keyThemes"],
55
+ "min_quotes": 3,
56
+ "min_key_points": 5
57
+ },
58
+ "validated": false
59
+ }
60
+ }
61
+ }
62
+ ```
63
+
64
+ ### Step 2: Run Validation Script
65
+
66
+ Execute the validation script with artifact path and criteria:
67
+
68
+ ```bash
69
+ bun scripts/validate.ts <artifact-path> '<criteria-json>'
70
+ ```
71
+
72
+ Example:
73
+ ```bash
74
+ bun scripts/validate.ts sandbox/podcast-2024-12-08-ai/outputs/summary.json '{"required_fields":["contentId","headline"],"min_quotes":3}'
75
+ ```
76
+
77
+ ### Step 3: Parse Results
78
+
79
+ The script returns JSON with pass/fail and individual checks:
80
+
81
+ ```json
82
+ {
83
+ "passed": true,
84
+ "checks": [
85
+ { "name": "has_contentId", "passed": true, "message": "OK" },
86
+ { "name": "has_headline", "passed": true, "message": "OK" },
87
+ { "name": "min_quotes", "passed": true, "message": "Found 5 quotes (min: 3)" }
88
+ ]
89
+ }
90
+ ```
91
+
92
+ ### Step 4: Handle Results
93
+
94
+ **If validation passes:**
95
+ - Update `validation.json` to set `validated: true` for this output
96
+ - Continue to next workflow step
97
+
98
+ **If validation fails:**
99
+ - Review failed checks
100
+ - Either retry the subagent with feedback
101
+ - Or report the issue to the user
102
+
103
+ ## Validation Criteria Reference
104
+
105
+ ### required_fields
106
+ Array of field names that must exist in the artifact:
107
+ ```json
108
+ "required_fields": ["contentId", "headline", "tldr"]
109
+ ```
110
+
111
+ ### min_quotes
112
+ Minimum number of items in `importantQuotes` array:
113
+ ```json
114
+ "min_quotes": 3
115
+ ```
116
+
117
+ ### min_key_points
118
+ Minimum number of items in `bullets` or key points array:
119
+ ```json
120
+ "min_key_points": 5
121
+ ```
122
+
123
+ ### min_outline_sections
124
+ Minimum number of outline sections:
125
+ ```json
126
+ "min_outline_sections": 4
127
+ ```
128
+
129
+ ### has_hooks
130
+ Requires `hooks` array with at least one item:
131
+ ```json
132
+ "has_hooks": true
133
+ ```
134
+
135
+ ## Output Format
136
+
137
+ The validation script returns:
138
+
139
+ ```json
140
+ {
141
+ "passed": boolean,
142
+ "checks": [
143
+ {
144
+ "name": "check_name",
145
+ "passed": boolean,
146
+ "message": "Human-readable result"
147
+ }
148
+ ]
149
+ }
150
+ ```
151
+
152
+ ## Important Rules
153
+
154
+ - **Automatic validation via hook** - Hook handles validation on write; manual use only for retry/debugging
155
+ - **Script is deterministic** - No LLM context consumed
156
+ - **Update validation.json** - Mark steps validated when passed (v0.6.0 uses `.steps` not `.outputs`)
157
+ - **Retry on failure** - Give subagent feedback on what failed
158
+ - **Check dependencies** - Ensure required steps are validated before dependent steps
159
+ - **Use exact paths** - Artifact paths are relative to workspace root
160
+
161
+ ## Script Location
162
+
163
+ The validation script is at:
164
+ ```
165
+ .claude/skills/workflow-validator/scripts/validate.ts
166
+ ```
167
+
168
+ Run with Bun for TypeScript execution:
169
+ ```bash
170
+ bun .claude/skills/workflow-validator/scripts/validate.ts <artifact> '<criteria>'
171
+ ```
@@ -0,0 +1,244 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * Workflow Validator Script (v0.6.0)
4
+ *
5
+ * Deterministic validation of workflow artifacts against criteria.
6
+ * Runs outside LLM context - no tokens consumed.
7
+ *
8
+ * Usage:
9
+ * bun validate.ts <artifact-path> '<criteria-json>'
10
+ *
11
+ * Example:
12
+ * bun validate.ts contentItem/session-123/summary.json '{"required_fields":["contentId"],"min_quotes":3}'
13
+ *
14
+ * @see docs/DESIGN-0.6.0.md
15
+ */
16
+
17
+ import { readFile } from "node:fs/promises";
18
+
19
+ type ValidationCheck = {
20
+ name: string;
21
+ passed: boolean;
22
+ message: string;
23
+ };
24
+
25
+ type ValidationResult = {
26
+ passed: boolean;
27
+ checks: ValidationCheck[];
28
+ };
29
+
30
+ type ValidationCriteria = {
31
+ required_fields?: string[];
32
+ min_quotes?: number;
33
+ min_key_points?: number;
34
+ min_outline_sections?: number;
35
+ has_hooks?: boolean;
36
+ [key: string]: unknown;
37
+ };
38
+
39
+ async function main(): Promise<void> {
40
+ const args = process.argv.slice(2);
41
+
42
+ if (args.length < 2) {
43
+ console.error("Usage: bun validate.ts <artifact-path> '<criteria-json>'");
44
+ process.exit(1);
45
+ }
46
+
47
+ const artifactPath = args[0];
48
+ const criteriaJson = args[1];
49
+
50
+ if (!(artifactPath && criteriaJson)) {
51
+ console.error("Error: Both artifact path and criteria JSON are required");
52
+ process.exit(1);
53
+ }
54
+
55
+ let data: Record<string, unknown>;
56
+ let criteria: ValidationCriteria;
57
+
58
+ // Read artifact file
59
+ try {
60
+ const content = await readFile(artifactPath, "utf-8");
61
+ data = JSON.parse(content) as Record<string, unknown>;
62
+ } catch (error) {
63
+ const result: ValidationResult = {
64
+ passed: false,
65
+ checks: [
66
+ {
67
+ name: "file_readable",
68
+ passed: false,
69
+ message: `Failed to read artifact: ${error instanceof Error ? error.message : "Unknown error"}`,
70
+ },
71
+ ],
72
+ };
73
+ console.log(JSON.stringify(result, null, 2));
74
+ process.exit(0);
75
+ }
76
+
77
+ // Parse criteria JSON
78
+ try {
79
+ criteria = JSON.parse(criteriaJson) as ValidationCriteria;
80
+ } catch (error) {
81
+ const result: ValidationResult = {
82
+ passed: false,
83
+ checks: [
84
+ {
85
+ name: "criteria_valid",
86
+ passed: false,
87
+ message: `Invalid criteria JSON: ${error instanceof Error ? error.message : "Unknown error"}`,
88
+ },
89
+ ],
90
+ };
91
+ console.log(JSON.stringify(result, null, 2));
92
+ process.exit(0);
93
+ }
94
+
95
+ // Run validation
96
+ const result = validate(data, criteria);
97
+ console.log(JSON.stringify(result, null, 2));
98
+ }
99
+
100
+ function validate(
101
+ data: Record<string, unknown>,
102
+ criteria: ValidationCriteria
103
+ ): ValidationResult {
104
+ const checks: ValidationCheck[] = [];
105
+
106
+ // Check required_fields
107
+ if (criteria.required_fields) {
108
+ checks.push(...checkRequiredFields(data, criteria.required_fields));
109
+ }
110
+
111
+ // Check min_quotes
112
+ if (criteria.min_quotes !== undefined) {
113
+ checks.push(checkMinQuotes(data, criteria.min_quotes));
114
+ }
115
+
116
+ // Check min_key_points
117
+ if (criteria.min_key_points !== undefined) {
118
+ checks.push(checkMinKeyPoints(data, criteria.min_key_points));
119
+ }
120
+
121
+ // Check min_outline_sections
122
+ if (criteria.min_outline_sections !== undefined) {
123
+ checks.push(checkMinOutlineSections(data, criteria.min_outline_sections));
124
+ }
125
+
126
+ // Check has_hooks
127
+ if (criteria.has_hooks === true) {
128
+ checks.push(checkHasHooks(data));
129
+ }
130
+
131
+ // Calculate overall pass/fail
132
+ const passed = checks.every((check) => check.passed);
133
+
134
+ return { passed, checks };
135
+ }
136
+
137
+ function checkRequiredFields(
138
+ data: Record<string, unknown>,
139
+ fields: string[]
140
+ ): ValidationCheck[] {
141
+ return fields.map((field) => {
142
+ const exists = hasField(data, field);
143
+ return {
144
+ name: `has_${field}`,
145
+ passed: exists,
146
+ message: exists ? "OK" : `Missing required field: ${field}`,
147
+ };
148
+ });
149
+ }
150
+
151
+ function checkMinQuotes(
152
+ data: Record<string, unknown>,
153
+ minQuotes: number
154
+ ): ValidationCheck {
155
+ const quotes = getArrayLength(data, "importantQuotes");
156
+ const passed = quotes >= minQuotes;
157
+ return {
158
+ name: "min_quotes",
159
+ passed,
160
+ message: passed
161
+ ? `Found ${quotes} quotes (min: ${minQuotes})`
162
+ : `Found ${quotes} quotes, need at least ${minQuotes}`,
163
+ };
164
+ }
165
+
166
+ function checkMinKeyPoints(
167
+ data: Record<string, unknown>,
168
+ minPoints: number
169
+ ): ValidationCheck {
170
+ const bullets = getArrayLength(data, "bullets");
171
+ const keyPoints = getArrayLength(data, "keyPoints");
172
+ const count = Math.max(bullets, keyPoints);
173
+ const passed = count >= minPoints;
174
+ return {
175
+ name: "min_key_points",
176
+ passed,
177
+ message: passed
178
+ ? `Found ${count} key points (min: ${minPoints})`
179
+ : `Found ${count} key points, need at least ${minPoints}`,
180
+ };
181
+ }
182
+
183
+ function checkMinOutlineSections(
184
+ data: Record<string, unknown>,
185
+ minSections: number
186
+ ): ValidationCheck {
187
+ const sections = getArrayLength(data, "suggestedOutline");
188
+ const passed = sections >= minSections;
189
+ return {
190
+ name: "min_outline_sections",
191
+ passed,
192
+ message: passed
193
+ ? `Found ${sections} outline sections (min: ${minSections})`
194
+ : `Found ${sections} sections, need at least ${minSections}`,
195
+ };
196
+ }
197
+
198
+ function checkHasHooks(data: Record<string, unknown>): ValidationCheck {
199
+ const hooksCount = getHooksCount(data);
200
+ const passed = hooksCount > 0;
201
+ return {
202
+ name: "has_hooks",
203
+ passed,
204
+ message: passed
205
+ ? `Found ${hooksCount} hooks`
206
+ : "No hooks found in artifact",
207
+ };
208
+ }
209
+
210
+ function getHooksCount(data: Record<string, unknown>): number {
211
+ const ideas = data.ideas as Record<string, unknown> | undefined;
212
+ if (ideas && Array.isArray(ideas.hooks)) {
213
+ return ideas.hooks.length;
214
+ }
215
+ if (Array.isArray(data.hooks)) {
216
+ return data.hooks.length;
217
+ }
218
+ return 0;
219
+ }
220
+
221
+ function hasField(data: Record<string, unknown>, field: string): boolean {
222
+ // Support nested fields with dot notation (e.g., "summary.headline")
223
+ const parts = field.split(".");
224
+ let current: unknown = data;
225
+
226
+ for (const part of parts) {
227
+ if (current === null || typeof current !== "object") {
228
+ return false;
229
+ }
230
+ current = (current as Record<string, unknown>)[part];
231
+ }
232
+
233
+ return current !== undefined && current !== null;
234
+ }
235
+
236
+ function getArrayLength(data: Record<string, unknown>, field: string): number {
237
+ const value = data[field];
238
+ if (Array.isArray(value)) {
239
+ return value.length;
240
+ }
241
+ return 0;
242
+ }
243
+
244
+ main();
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "looplia-writer",
3
+ "description": "Writing domain plugin - Content analysis, idea generation, and writing-kit workflow",
4
+ "version": "0.6.5",
5
+ "author": {
6
+ "name": "Looplia"
7
+ },
8
+ "keywords": ["writing", "content", "analysis", "ideas"],
9
+ "homepage": "https://github.com/memorysaver/looplia-core"
10
+ }
@@ -0,0 +1,107 @@
1
+ # Looplia Writer Plugin
2
+
3
+ Writing domain plugin providing content analysis, idea generation, and writing-kit workflow.
4
+
5
+ ## Overview
6
+
7
+ This plugin is a **domain plugin** that depends on `looplia-core` for workflow execution. It provides:
8
+
9
+ - **Writing-kit workflow** for transforming content into actionable writing materials
10
+ - **Specialized agents** for content analysis and idea generation
11
+ - **Domain skills** for media review, content documentation, and writing enhancement
12
+
13
+ ## Workflow
14
+
15
+ ### writing-kit
16
+
17
+ Transforms source content into a comprehensive writing kit:
18
+
19
+ ```
20
+ /run writing-kit --file article.md
21
+ ```
22
+
23
+ **Stages:**
24
+ 1. **content-analyzer** → `summary.json` - Deep content analysis
25
+ 2. **idea-generator** → `ideas.json` - Writing ideas and hooks
26
+ 3. **writing-kit-builder** → `writing-kit.json` - Final assembled kit
27
+
28
+ ## Agents
29
+
30
+ ### content-analyzer
31
+
32
+ Deep content analysis using media-reviewer skill.
33
+
34
+ **Skills:** media-reviewer, content-documenter
35
+
36
+ **Output:** `summary.json` with:
37
+ - Content ID, headline, TLDR
38
+ - Key themes and talking points
39
+ - Important quotes (verbatim)
40
+ - Source metadata
41
+
42
+ ### idea-generator
43
+
44
+ Generate writing ideas based on content analysis.
45
+
46
+ **Skills:** user-profile-reader
47
+
48
+ **Output:** `ideas.json` with:
49
+ - Content ideas with hooks and angles
50
+ - Format recommendations
51
+ - Target audience alignment
52
+
53
+ ### writing-kit-builder
54
+
55
+ Assemble final writing kit from all artifacts.
56
+
57
+ **Skills:** user-profile-reader
58
+
59
+ **Output:** `writing-kit.json` with:
60
+ - Complete writing kit structure
61
+ - All previous artifacts integrated
62
+ - Ready-to-use writing materials
63
+
64
+ ## Skills
65
+
66
+ | Skill | Purpose |
67
+ |-------|---------|
68
+ | media-reviewer | Analyze media content (transcripts, articles) |
69
+ | content-documenter | Generate structured documentation |
70
+ | id-generator | Create meaningful session IDs |
71
+ | user-profile-reader | Load user preferences and style |
72
+ | writing-enhancer | Enhance content quality |
73
+
74
+ ## Dependencies
75
+
76
+ This plugin requires `looplia-core` which provides:
77
+ - `/run` command for workflow execution
78
+ - `workflow-executor` skill for orchestration
79
+ - `workflow-validator` skill for output validation
80
+
81
+ ## Installation
82
+
83
+ ```bash
84
+ looplia init
85
+ ```
86
+
87
+ Both `looplia-core` and `looplia-writer` are installed together.
88
+
89
+ ## File Structure
90
+
91
+ ```
92
+ plugins/looplia-writer/
93
+ ├── .claude-plugin/plugin.json # Plugin manifest
94
+ ├── agents/
95
+ │ ├── content-analyzer.md # Stage 1 agent
96
+ │ ├── idea-generator.md # Stage 2 agent
97
+ │ └── writing-kit-builder.md # Stage 3 agent
98
+ ├── skills/
99
+ │ ├── media-reviewer/SKILL.md
100
+ │ ├── content-documenter/SKILL.md
101
+ │ ├── id-generator/SKILL.md
102
+ │ ├── user-profile-reader/SKILL.md
103
+ │ └── writing-enhancer/SKILL.md
104
+ ├── workflows/
105
+ │ └── writing-kit.md # Workflow definition
106
+ └── README.md # This file
107
+ ```