cli-community-intelligence 0.1.12 → 0.1.14

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.
@@ -1,73 +1,11 @@
1
1
  // ABOUTME: OpenClaw plugin extension entry point
2
2
  // ABOUTME: Registers community-intelligence CLI commands as OpenClaw tools
3
3
 
4
- import { definePluginEntry } from 'openclaw/plugin-sdk/plugin-entry'
5
4
  import { exec } from 'child_process'
6
5
  import { promisify } from 'util'
7
6
 
8
7
  const execAsync = promisify(exec)
9
8
 
10
- // ---------------------------------------------------------------------------------------------------------------------
11
- //
12
- // Constants
13
- //
14
- // ---------------------------------------------------------------------------------------------------------------------
15
-
16
- const scrapeToolDef = {
17
- id: 'community-intelligence-scrape',
18
- name: 'Scrape Community Posts',
19
- description:
20
- 'Scrape posts and comments from online communities (Reddit, YouTube). ' +
21
- 'Use --subreddits for Reddit, --query or --channels for YouTube. ' +
22
- 'Supports --incremental to only fetch new posts since last scrape.',
23
- parameters: {
24
- type: 'object',
25
- properties: {
26
- source: { type: 'string', enum: ['reddit', 'youtube'], description: 'Source platform to scrape' },
27
- subreddits: { type: 'string', description: 'Comma-separated subreddit names (reddit only)' },
28
- query: { type: 'string', description: 'Search query (youtube only)' },
29
- channels: { type: 'string', description: 'Comma-separated YouTube channel IDs (youtube only)' },
30
- incremental: { type: 'boolean', description: 'Only fetch posts newer than last scrape' },
31
- backfill: { type: 'number', description: 'Number of days to backfill' },
32
- },
33
- required: ['source'],
34
- },
35
- }
36
-
37
- const queryToolDef = {
38
- id: 'community-intelligence-query',
39
- name: 'Query Community Corpus',
40
- description:
41
- 'Search the scraped community posts corpus. Filter by source, channel, text, author, date range, or score.',
42
- parameters: {
43
- type: 'object',
44
- properties: {
45
- source: { type: 'string', description: 'Filter by source (reddit, youtube)' },
46
- channel: { type: 'string', description: 'Filter by channel/subreddit' },
47
- text: { type: 'string', description: 'Search text in body and title' },
48
- author: { type: 'string', description: 'Filter by author' },
49
- since: { type: 'string', description: 'Posts after this date (ISO 8601)' },
50
- until: { type: 'string', description: 'Posts before this date (ISO 8601)' },
51
- minScore: { type: 'number', description: 'Minimum score' },
52
- limit: { type: 'number', description: 'Maximum number of results' },
53
- },
54
- },
55
- }
56
-
57
- const statusToolDef = {
58
- id: 'community-intelligence-status',
59
- name: 'Community Corpus Status',
60
- description: 'Show summary statistics for the scraped community intelligence corpus.',
61
- parameters: { type: 'object', properties: {} },
62
- }
63
-
64
- const exportToolDef = {
65
- id: 'community-intelligence-export',
66
- name: 'Export Community Posts',
67
- description: 'Export matching posts as JSON. Same filters as query.',
68
- parameters: queryToolDef.parameters,
69
- }
70
-
71
9
  // ---------------------------------------------------------------------------------------------------------------------
72
10
  //
73
11
  // Transformers
@@ -92,15 +30,16 @@ const T = {
92
30
 
93
31
  const F = {
94
32
  // Create an execute handler for a given subcommand
95
- // @sig buildExecutor :: String -> (Object -> Promise Object)
96
- buildExecutor: subcommand => async params => {
33
+ // @sig buildExecutor :: String -> (String, Object) -> Promise Object
34
+ buildExecutor: subcommand => async (_toolCallId, params) => {
97
35
  const args = T.toArgs(params)
98
36
  const cmd = `community-intelligence ${subcommand} ${args}`.trim()
99
37
  try {
100
38
  const { stdout, stderr } = await execAsync(cmd)
101
- return { success: true, stdout, stderr }
39
+ const text = [stdout, stderr].filter(Boolean).join('\n')
40
+ return { content: [{ type: 'text', text }], details: null }
102
41
  } catch (error) {
103
- return { success: false, error: String(error) }
42
+ return { content: [{ type: 'text', text: `Error: ${String(error)}` }], details: null }
104
43
  }
105
44
  },
106
45
  }
@@ -111,13 +50,76 @@ const F = {
111
50
  //
112
51
  // ---------------------------------------------------------------------------------------------------------------------
113
52
 
114
- export default definePluginEntry({
53
+ export default {
115
54
  id: 'cli-community-intelligence',
116
55
  name: 'Community Intelligence',
56
+ description: 'Scrape and query posts from online communities (Reddit, YouTube)',
117
57
  register(api) {
118
- api.registerTool(scrapeToolDef, { execute: F.buildExecutor('scrape') })
119
- api.registerTool(queryToolDef, { execute: F.buildExecutor('query') })
120
- api.registerTool(statusToolDef, { execute: F.buildExecutor('status') })
121
- api.registerTool(exportToolDef, { execute: F.buildExecutor('export') })
58
+ api.registerTool({
59
+ name: 'community-intelligence-scrape',
60
+ description:
61
+ 'Scrape posts and comments from online communities (Reddit, YouTube). ' +
62
+ 'Use --subreddits for Reddit, --query or --channels for YouTube. ' +
63
+ 'Supports --incremental to only fetch new posts since last scrape.',
64
+ parameters: {
65
+ type: 'object',
66
+ properties: {
67
+ source: { type: 'string', enum: ['reddit', 'youtube'], description: 'Source platform to scrape' },
68
+ subreddits: { type: 'string', description: 'Comma-separated subreddit names (reddit only)' },
69
+ query: { type: 'string', description: 'Search query (youtube only)' },
70
+ channels: { type: 'string', description: 'Comma-separated YouTube channel IDs (youtube only)' },
71
+ incremental: { type: 'boolean', description: 'Only fetch posts newer than last scrape' },
72
+ backfill: { type: 'number', description: 'Number of days to backfill' },
73
+ },
74
+ required: ['source'],
75
+ },
76
+ execute: F.buildExecutor('scrape'),
77
+ })
78
+
79
+ api.registerTool({
80
+ name: 'community-intelligence-query',
81
+ description:
82
+ 'Search the scraped community posts corpus. Filter by source, channel, text, author, date range, or score.',
83
+ parameters: {
84
+ type: 'object',
85
+ properties: {
86
+ source: { type: 'string', description: 'Filter by source (reddit, youtube)' },
87
+ channel: { type: 'string', description: 'Filter by channel/subreddit' },
88
+ text: { type: 'string', description: 'Search text in body and title' },
89
+ author: { type: 'string', description: 'Filter by author' },
90
+ since: { type: 'string', description: 'Posts after this date (ISO 8601)' },
91
+ until: { type: 'string', description: 'Posts before this date (ISO 8601)' },
92
+ minScore: { type: 'number', description: 'Minimum score' },
93
+ limit: { type: 'number', description: 'Maximum number of results' },
94
+ },
95
+ },
96
+ execute: F.buildExecutor('query'),
97
+ })
98
+
99
+ api.registerTool({
100
+ name: 'community-intelligence-status',
101
+ description: 'Show summary statistics for the scraped community intelligence corpus.',
102
+ parameters: { type: 'object', properties: {} },
103
+ execute: F.buildExecutor('status'),
104
+ })
105
+
106
+ api.registerTool({
107
+ name: 'community-intelligence-export',
108
+ description: 'Export matching posts as JSON. Same filters as query.',
109
+ parameters: {
110
+ type: 'object',
111
+ properties: {
112
+ source: { type: 'string', description: 'Filter by source (reddit, youtube)' },
113
+ channel: { type: 'string', description: 'Filter by channel/subreddit' },
114
+ text: { type: 'string', description: 'Search text in body and title' },
115
+ author: { type: 'string', description: 'Filter by author' },
116
+ since: { type: 'string', description: 'Posts after this date (ISO 8601)' },
117
+ until: { type: 'string', description: 'Posts before this date (ISO 8601)' },
118
+ minScore: { type: 'number', description: 'Minimum score' },
119
+ limit: { type: 'number', description: 'Maximum number of results' },
120
+ },
121
+ },
122
+ execute: F.buildExecutor('export'),
123
+ })
122
124
  },
123
- })
125
+ }
@@ -2,7 +2,7 @@
2
2
  "id": "cli-community-intelligence",
3
3
  "name": "Community Intelligence",
4
4
  "description": "Scrape and query posts from online communities (Reddit, YouTube)",
5
- "version": "0.1.12",
5
+ "version": "0.1.14",
6
6
  "contracts": {
7
7
  "tools": [
8
8
  "community-intelligence-scrape",
@@ -11,6 +11,9 @@
11
11
  "community-intelligence-export"
12
12
  ]
13
13
  },
14
+ "capabilities": {
15
+ "childProcess": true
16
+ },
14
17
  "configSchema": {
15
18
  "type": "object",
16
19
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cli-community-intelligence",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "Community intelligence scraper for construction industry market research",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",