@epsilon-asi/actors 0.0.3 → 0.0.5

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 (112) hide show
  1. package/.ai/generators/_template.ts +37 -0
  2. package/.ai/generators/abstract.ts +24 -0
  3. package/.ai/generators/actor-task-form-filler.ts +140 -0
  4. package/.ai/generators/actor-task.ts +122 -0
  5. package/.ai/generators/auth-core.ts +126 -0
  6. package/.ai/generators/browser-runtime.ts +114 -0
  7. package/.ai/generators/cli-command.ts +96 -0
  8. package/.ai/generators/core-framework.ts +80 -0
  9. package/.ai/generators/docs.ts +92 -0
  10. package/.ai/generators/error-logging.ts +102 -0
  11. package/.ai/generators/extraction-helper.ts +96 -0
  12. package/.ai/generators/interaction-behavior.ts +129 -0
  13. package/.ai/generators/site-actor.ts +125 -0
  14. package/.ai/generators/site-login-flow.ts +117 -0
  15. package/.ai/generators/unit-test.ts +109 -0
  16. package/.ai/workflows/_template.ts +20 -0
  17. package/.ai/workflows/starter.ts +20 -0
  18. package/ai-gen.config.ts +67 -0
  19. package/package.json +4 -12
  20. package/src/auth/AuthStateDetector.ts +18 -0
  21. package/src/auth/CredentialsProvider.ts +48 -0
  22. package/src/auth/LoginFlow.ts +332 -0
  23. package/src/auth/LoginFlow.types.ts +141 -0
  24. package/src/auth/SessionStore.ts +21 -0
  25. package/src/auth/index.ts +5 -0
  26. package/src/browser/BrowserFactory.ts +253 -0
  27. package/src/browser/BrowserSession.ts +50 -0
  28. package/src/browser/PuppeteerLike.ts +65 -0
  29. package/src/browser/RuntimeConfig.ts +152 -0
  30. package/src/browser/index.ts +5 -0
  31. package/src/browser/profileValidation.ts +73 -0
  32. package/src/cli/run.ts +112 -0
  33. package/src/core/Actor.ts +167 -0
  34. package/src/core/ActorContext.ts +34 -0
  35. package/src/core/ActorRegistry.ts +26 -0
  36. package/src/core/ActorRunner.ts +240 -0
  37. package/src/core/defineActor.ts +5 -0
  38. package/src/core/index.ts +5 -0
  39. package/src/errors/AuthError.ts +7 -0
  40. package/src/errors/AutomationError.ts +26 -0
  41. package/src/errors/ConfigError.ts +7 -0
  42. package/src/errors/ExtractionError.ts +7 -0
  43. package/src/errors/NavigationError.ts +7 -0
  44. package/src/errors/SelectorError.ts +10 -0
  45. package/src/errors/index.ts +6 -0
  46. package/src/extraction/Extractor.ts +65 -0
  47. package/src/extraction/Pagination.ts +47 -0
  48. package/src/extraction/index.ts +2 -0
  49. package/src/index.ts +9 -0
  50. package/src/interaction/FieldClearer.ts +73 -0
  51. package/src/interaction/Forms.ts +27 -0
  52. package/src/interaction/GhostCursorAdapter.ts +79 -0
  53. package/src/interaction/HumanInteractor.ts +32 -0
  54. package/src/interaction/HumanTyping.ts +157 -0
  55. package/src/interaction/NativePuppeteerInteractor.ts +68 -0
  56. package/src/interaction/Navigation.ts +37 -0
  57. package/src/interaction/PageAdapter.ts +86 -0
  58. package/src/interaction/Waits.ts +5 -0
  59. package/src/interaction/index.ts +9 -0
  60. package/src/logging/ConsoleLogger.ts +44 -0
  61. package/src/logging/Logger.ts +15 -0
  62. package/src/logging/MemoryLogger.ts +34 -0
  63. package/src/logging/NullLogger.ts +8 -0
  64. package/src/logging/index.ts +4 -0
  65. package/src/sites/example/example.actor.ts +53 -0
  66. package/src/sites/example/example.selectors.ts +17 -0
  67. package/src/sites/example/example.types.ts +18 -0
  68. package/src/sites/example/index.ts +3 -0
  69. package/src/sites/index.ts +3 -0
  70. package/src/sites/myvistage-com/index.ts +3 -0
  71. package/src/sites/myvistage-com/login-action-list.json +349 -0
  72. package/src/sites/myvistage-com/myvistage-com.actor.ts +50 -0
  73. package/src/sites/myvistage-com/myvistage-com.selectors.ts +14 -0
  74. package/src/sites/myvistage-com/myvistage-com.types.ts +18 -0
  75. package/src/sites/myvistage-com/post-comment-action.json +81 -0
  76. package/src/sites/upwork-com/index.ts +6 -0
  77. package/src/sites/upwork-com/upwork-com.actor.ts +97 -0
  78. package/src/sites/upwork-com/upwork-com.runner.ts +17 -0
  79. package/src/sites/upwork-com/upwork-com.selectors.ts +10 -0
  80. package/src/sites/upwork-com/upwork-com.types.ts +102 -0
  81. package/src/sites/upwork-com/upwork-com.util.ts +41 -0
  82. package/src/utils/delay.ts +4 -0
  83. package/src/utils/index.ts +5 -0
  84. package/src/utils/invariant.ts +7 -0
  85. package/src/utils/redact.ts +53 -0
  86. package/src/utils/retry.ts +31 -0
  87. package/src/utils/url.ts +7 -0
  88. package/tests/fixtures/FakeCredentialsProvider.ts +12 -0
  89. package/tests/fixtures/FakeCursor.ts +48 -0
  90. package/tests/fixtures/FakePage.ts +266 -0
  91. package/tests/fixtures/makeContext.ts +76 -0
  92. package/tests/unit/auth/AuthStateDetector.test.ts +80 -0
  93. package/tests/unit/auth/LoginFlow.test.ts +296 -0
  94. package/tests/unit/browser/BrowserFactory.test.ts +370 -0
  95. package/tests/unit/core/ActorRunner.test.ts +370 -0
  96. package/tests/unit/core/defineActor.test.ts +112 -0
  97. package/tests/unit/extraction/Extractor.test.ts +48 -0
  98. package/tests/unit/extraction/Pagination.test.ts +54 -0
  99. package/tests/unit/interaction/FieldClearer.test.ts +29 -0
  100. package/tests/unit/interaction/Forms.test.ts +35 -0
  101. package/tests/unit/interaction/GhostCursorAdapter.test.ts +68 -0
  102. package/tests/unit/interaction/HumanTyping.test.ts +54 -0
  103. package/tests/unit/interaction/NativePuppeteerInteractor.test.ts +22 -0
  104. package/tests/unit/interaction/PageAdapter.test.ts +25 -0
  105. package/tests/unit/logging/redact.test.ts +36 -0
  106. package/tests/unit/sites/myvistage-com.actor.test.ts +19 -0
  107. package/tests/unit/sites/myvistage-com.login.test.ts +22 -0
  108. package/tests/unit/sites/myvistage-com.postComment.test.ts +70 -0
  109. package/tests/unit/sites/upwork-com.login.test.ts +52 -0
  110. package/tsconfig.build.json +9 -0
  111. package/tsconfig.json +22 -0
  112. package/vitest.config.ts +12 -0
@@ -0,0 +1,80 @@
1
+ export default {
2
+ id: 'core-framework',
3
+ description:
4
+ 'Modify core actor framework behavior: ActorRunner, ActorContext, ActorRegistry, defineActor, hooks, context services, and execution lifecycle.',
5
+ instructions: `
6
+ Make reusable framework changes in src/core unless another layer clearly owns the behavior.
7
+
8
+ Rules:
9
+ - ActorRunner coordinates browser session creation, auth, task execution, hooks, error wrapping, and cleanup.
10
+ - ActorContext should expose stable services to site actors; avoid leaking low-level implementation details unless necessary.
11
+ - Keep defineActor simple and type-preserving.
12
+ - Keep ActorRegistry focused on registration and lookup.
13
+ - Do not implement site-specific scraping in core.
14
+ - Add unit tests for every lifecycle, auth, context, or hook behavior change.
15
+ `.trim(),
16
+ output: {
17
+ pathTemplates: [
18
+ { key: 'actor', pathTemplate: 'src/core/Actor.ts', description: 'Actor/task/hook types.' },
19
+ { key: 'context', pathTemplate: 'src/core/ActorContext.ts', description: 'Task context services.' },
20
+ { key: 'runner', pathTemplate: 'src/core/ActorRunner.ts', description: 'Execution lifecycle implementation.' },
21
+ { key: 'registry', pathTemplate: 'src/core/ActorRegistry.ts', description: 'Actor registry implementation.' },
22
+ { key: 'define-actor', pathTemplate: 'src/core/defineActor.ts', description: 'Actor definition helper.' },
23
+ { key: 'core-index', pathTemplate: 'src/core/index.ts', description: 'Core barrel exports.' },
24
+ { key: 'runner-tests', pathTemplate: 'tests/unit/core/ActorRunner.test.ts', description: 'Runner lifecycle tests.' },
25
+ { key: 'define-tests', pathTemplate: 'tests/unit/core/defineActor.test.ts', description: 'defineActor type/runtime tests.' }
26
+ ],
27
+ maxFiles: 8
28
+ },
29
+ parameters: {
30
+ feature: {
31
+ description: 'Core framework feature to add or change, for example hooks, context service, actor lookup, or error wrapping.',
32
+ required: true
33
+ },
34
+ instructions: {
35
+ description: 'Detailed behavior, affected actors, lifecycle semantics, and test expectations.',
36
+ required: false
37
+ }
38
+ },
39
+ examples: [
40
+ 'src/core/ActorRunner.ts',
41
+ 'src/core/ActorContext.ts',
42
+ 'src/core/ActorRegistry.ts',
43
+ 'tests/unit/core/ActorRunner.test.ts'
44
+ ],
45
+ context: [
46
+ { kind: 'path', path: 'src/core/Actor.ts', description: 'Actor/task/hook types.' },
47
+ { kind: 'path', path: 'src/core/ActorContext.ts', description: 'Services exposed to tasks.' },
48
+ { kind: 'path', path: 'src/core/ActorRunner.ts', description: 'Execution lifecycle.' },
49
+ { kind: 'path', path: 'src/core/ActorRegistry.ts', description: 'Registry behavior.' },
50
+ { kind: 'path', path: 'src/core/defineActor.ts', description: 'Type-preserving actor helper.' },
51
+ { kind: 'path', path: 'src/browser/BrowserSession.ts', description: 'Session lifecycle consumed by ActorRunner.' },
52
+ { kind: 'path', path: 'src/auth/LoginFlow.ts', description: 'Auth service used by ActorRunner.' },
53
+ { kind: 'path', path: 'src/errors/AutomationError.ts', description: 'Base error wrapper used by ActorRunner.' },
54
+ { kind: 'pattern', pattern: 'tests/unit/core/*.test.ts', description: 'Core unit tests.', limit: 5 },
55
+ { kind: 'path', path: 'tests/fixtures/makeContext.ts', description: 'ActorContext test fixture.' }
56
+ ],
57
+ keywordContexts: [
58
+ {
59
+ keywords: ['browser', 'session', 'cleanup', 'close', 'disconnect'],
60
+ context: [
61
+ { kind: 'path', path: 'src/browser/BrowserFactory.ts', description: 'BrowserSession creation behavior.' },
62
+ { kind: 'path', path: 'src/browser/BrowserSession.ts', description: 'Close/disconnect behavior.' },
63
+ { kind: 'path', path: 'tests/unit/browser/BrowserFactory.test.ts', description: 'Browser lifecycle tests.' }
64
+ ]
65
+ },
66
+ {
67
+ keywords: ['auth', 'login', 'ensureAuthenticated', 'isLoggedIn'],
68
+ context: [
69
+ { kind: 'path', path: 'src/auth/LoginFlow.ts', description: 'Auth execution consumed by ActorRunner.' },
70
+ { kind: 'path', path: 'src/auth/AuthStateDetector.ts', description: 'Logged-in detection consumed by context auth controller.' },
71
+ { kind: 'path', path: 'tests/unit/auth/LoginFlow.test.ts', description: 'Auth behavior tests.' }
72
+ ]
73
+ }
74
+ ],
75
+ tooling: {
76
+ allowGetExistingCode: true,
77
+ allowFindFiles: true,
78
+ allowSearchRepo: true
79
+ }
80
+ };
@@ -0,0 +1,92 @@
1
+ export default {
2
+ id: 'docs',
3
+ description: 'Update README and usage documentation for framework features, site actors, CLI examples, browser setup, and auth/login examples.',
4
+ instructions: `
5
+ Update documentation to match the actual code.
6
+
7
+ Rules:
8
+ - Keep examples consistent with RuntimeConfig, ActorRunner, LoginFlowDefinition, and CLI behavior.
9
+ - Use the example actor only as a pattern; do not imply it scrapes a real site unless it does.
10
+ - Include concrete command examples when documenting CLI behavior.
11
+ - Include safe Chrome remote debugging examples bound to 127.0.0.1 when documenting running Chrome attach.
12
+ - Document environment variables only if src/cli/run.ts supports them.
13
+ - Avoid overstating test coverage or behavior not implemented in code.
14
+ - Keep docs practical and concise.
15
+
16
+ DO NOT include real credentials, cookies, tokens, or private local paths.
17
+ DO NOT document CAPTCHA bypass or anti-bot circumvention.
18
+ `.trim(),
19
+ output: {
20
+ pathTemplates: [
21
+ {
22
+ key: 'readme',
23
+ pathTemplate: 'README.md',
24
+ description: 'Primary project documentation.'
25
+ },
26
+ {
27
+ key: 'example-actor',
28
+ pathTemplate: 'src/sites/example/example.actor.ts',
29
+ description: 'Update only if documentation examples require the example actor to change.'
30
+ },
31
+ {
32
+ key: 'cli',
33
+ pathTemplate: 'src/cli/run.ts',
34
+ description: 'Update only if docs expose CLI behavior that code does not yet support.'
35
+ }
36
+ ],
37
+ maxFiles: 3
38
+ },
39
+ parameters: {
40
+ topic: {
41
+ description: 'Documentation topic, for example multi-step login, running Chrome attach, human typing, creating site actors, or CLI usage.',
42
+ required: true
43
+ },
44
+ instructions: {
45
+ description: 'Specific docs to add, change, or clarify.',
46
+ required: false
47
+ }
48
+ },
49
+ examples: [
50
+ 'README.md',
51
+ 'src/sites/example/example.actor.ts',
52
+ 'src/cli/run.ts'
53
+ ],
54
+ context: [
55
+ { kind: 'path', path: 'README.md', description: 'Existing documentation.' },
56
+ { kind: 'path', path: 'package.json', description: 'Scripts, package name, binary name, and dependencies.' },
57
+ { kind: 'path', path: 'src/browser/RuntimeConfig.ts', description: 'Runtime config docs must match these types.' },
58
+ { kind: 'path', path: 'src/browser/BrowserFactory.ts', description: 'Launch/connect behavior docs must match this implementation.' },
59
+ { kind: 'path', path: 'src/auth/LoginFlow.types.ts', description: 'Login examples must match these types.' },
60
+ { kind: 'path', path: 'src/interaction/HumanTyping.ts', description: 'Typing docs must match these options/defaults.' },
61
+ { kind: 'path', path: 'src/core/ActorRunner.ts', description: 'Runner examples must match constructor/run behavior.' },
62
+ { kind: 'path', path: 'src/cli/run.ts', description: 'CLI examples must match env parsing and command behavior.' },
63
+ { kind: 'path', path: 'src/sites/example/example.actor.ts', description: 'Example actor implementation.' }
64
+ ],
65
+ keywordContexts: [
66
+ {
67
+ keywords: ['login', 'multi-step', 'auth', 'credentials'],
68
+ context: [
69
+ { kind: 'path', path: 'src/auth/LoginFlow.ts', description: 'Login execution details.' },
70
+ { kind: 'path', path: 'tests/unit/auth/LoginFlow.test.ts', description: 'Behavior examples from tests.' }
71
+ ]
72
+ },
73
+ {
74
+ keywords: ['browser', 'chrome', 'debug endpoint', 'remote debugging', 'profile'],
75
+ context: [
76
+ { kind: 'path', path: 'tests/unit/browser/BrowserFactory.test.ts', description: 'Browser behavior examples from tests.' }
77
+ ]
78
+ },
79
+ {
80
+ keywords: ['site', 'actor', 'task', 'scrape'],
81
+ context: [
82
+ { kind: 'path', path: 'src/core/Actor.ts', description: 'Actor/task contracts.' },
83
+ { kind: 'path', path: 'src/extraction/Extractor.ts', description: 'Extraction helpers available to actor tasks.' }
84
+ ]
85
+ }
86
+ ],
87
+ tooling: {
88
+ allowGetExistingCode: true,
89
+ allowFindFiles: true,
90
+ allowSearchRepo: true
91
+ }
92
+ };
@@ -0,0 +1,102 @@
1
+ export default {
2
+ id: 'error-logging',
3
+ description: 'Modify typed errors, logging implementations, metadata redaction, and diagnostics behavior.',
4
+ instructions: `
5
+ Update error/logging behavior safely.
6
+
7
+ Rules:
8
+ - Keep AutomationError as the base class for framework-level errors.
9
+ - Preserve useful metadata: actorId, taskName, url, selector, and cause where applicable.
10
+ - Keep logging implementation independent from site-specific code.
11
+ - Redact sensitive metadata recursively before writing logs.
12
+ - Add tests for every new redaction key or error metadata behavior.
13
+ - If a browser/auth/core module starts throwing a new typed error, update the relevant unit tests there too.
14
+ - Prefer typed errors over plain Error for framework-level failures.
15
+
16
+ DO NOT log raw passwords, tokens, authorization headers, cookies, or session secrets.
17
+ DO NOT swallow causes; preserve them in metadata where feasible.
18
+ `.trim(),
19
+ output: {
20
+ pathTemplates: [
21
+ {
22
+ key: 'error',
23
+ pathTemplate: 'src/errors/{{errorPascal}}.ts',
24
+ description: 'Typed error class. Use existing files when editing existing errors.'
25
+ },
26
+ {
27
+ key: 'errors-index',
28
+ pathTemplate: 'src/errors/index.ts',
29
+ description: 'Error barrel exports.'
30
+ },
31
+ {
32
+ key: 'logger',
33
+ pathTemplate: 'src/logging/{{loggerPascal}}.ts',
34
+ description: 'Logger interface or implementation. Use existing files when editing existing loggers.'
35
+ },
36
+ {
37
+ key: 'redact',
38
+ pathTemplate: 'src/utils/redact.ts',
39
+ description: 'Sensitive metadata redaction utility.'
40
+ },
41
+ {
42
+ key: 'tests',
43
+ pathTemplate: 'tests/unit/logging/{{subjectPascal}}.test.ts',
44
+ description: 'Logging/redaction unit tests.'
45
+ }
46
+ ],
47
+ maxFiles: 5
48
+ },
49
+ parameters: {
50
+ subject: {
51
+ description: 'Error/logging/redaction behavior to implement or update.',
52
+ required: true
53
+ },
54
+ instructions: {
55
+ description: 'Specific metadata, redaction keys, logger behavior, or error semantics.',
56
+ required: false
57
+ }
58
+ },
59
+ examples: [
60
+ 'src/errors/AutomationError.ts',
61
+ 'src/errors/AuthError.ts',
62
+ 'src/logging/ConsoleLogger.ts',
63
+ 'src/logging/MemoryLogger.ts',
64
+ 'src/utils/redact.ts',
65
+ 'tests/unit/logging/redact.test.ts'
66
+ ],
67
+ context: [
68
+ { kind: 'pattern', pattern: 'src/errors/*.ts', description: 'Existing typed errors and barrel export.', limit: 10 },
69
+ { kind: 'pattern', pattern: 'src/logging/*.ts', description: 'Logger interface and implementations.', limit: 10 },
70
+ { kind: 'path', path: 'src/utils/redact.ts', description: 'Sensitive metadata redaction utility.' },
71
+ { kind: 'path', path: 'tests/unit/logging/redact.test.ts', description: 'Existing redaction tests.' },
72
+ { kind: 'path', path: 'src/auth/LoginFlow.ts', description: 'Auth error and redacted logging usage.' },
73
+ { kind: 'path', path: 'src/browser/BrowserFactory.ts', description: 'ConfigError metadata usage.' },
74
+ { kind: 'path', path: 'src/core/ActorRunner.ts', description: 'Error wrapping behavior.' }
75
+ ],
76
+ keywordContexts: [
77
+ {
78
+ keywords: ['auth', 'login', 'credentials', 'password'],
79
+ context: [
80
+ { kind: 'path', path: 'tests/unit/auth/LoginFlow.test.ts', description: 'Auth tests may need error/log assertion updates.' }
81
+ ]
82
+ },
83
+ {
84
+ keywords: ['browser', 'chrome', 'profile', 'remote debugging'],
85
+ context: [
86
+ { kind: 'path', path: 'tests/unit/browser/BrowserFactory.test.ts', description: 'Browser error tests.' }
87
+ ]
88
+ },
89
+ {
90
+ keywords: ['selector', 'form', 'extraction'],
91
+ context: [
92
+ { kind: 'path', path: 'tests/unit/interaction/Forms.test.ts', description: 'Selector error behavior tests.' },
93
+ { kind: 'path', path: 'tests/unit/extraction/Extractor.test.ts', description: 'Extraction behavior tests.' }
94
+ ]
95
+ }
96
+ ],
97
+ tooling: {
98
+ allowGetExistingCode: true,
99
+ allowFindFiles: true,
100
+ allowSearchRepo: true
101
+ }
102
+ };
@@ -0,0 +1,96 @@
1
+ export default {
2
+ id: 'extraction-helper',
3
+ description: 'Add or modify reusable extraction helpers, pagination behavior, data mapping utilities, and extraction tests.',
4
+ instructions: `
5
+ Add or revise extraction utilities for reusable scraping behavior.
6
+
7
+ Rules:
8
+ - Keep extraction helpers generic and site-agnostic.
9
+ - Use PageAdapter methods before reaching for raw Puppeteer APIs.
10
+ - Preserve existing Extractor and Pagination behavior unless the user asks for a change.
11
+ - Return normalized values where possible: trimmed text, null for missing optional attributes, arrays for lists.
12
+ - Make missing-required-element behavior explicit in options rather than surprising callers.
13
+ - Add unit tests using FakePage for every new extraction behavior.
14
+ - Update src/extraction/index.ts when adding a new exported helper.
15
+ - Update src/index.ts if the new helper is part of the public package API.
16
+
17
+ DO NOT put site-specific selectors or actor-specific data shapes in generic extraction helpers.
18
+ `.trim(),
19
+ output: {
20
+ pathTemplates: [
21
+ {
22
+ key: 'helper',
23
+ pathTemplate: 'src/extraction/{{helperPascal}}.ts',
24
+ description: 'New extraction helper. Use Extractor.ts or Pagination.ts directly when editing existing helpers.'
25
+ },
26
+ {
27
+ key: 'extraction-index',
28
+ pathTemplate: 'src/extraction/index.ts',
29
+ description: 'Extraction barrel export.'
30
+ },
31
+ {
32
+ key: 'root-index',
33
+ pathTemplate: 'src/index.ts',
34
+ description: 'Root package export when public API changes.'
35
+ },
36
+ {
37
+ key: 'tests',
38
+ pathTemplate: 'tests/unit/extraction/{{helperPascal}}.test.ts',
39
+ description: 'Unit tests for the extraction helper.'
40
+ },
41
+ {
42
+ key: 'fake-page',
43
+ pathTemplate: 'tests/fixtures/FakePage.ts',
44
+ description: 'Update when the helper requires new fake page behavior.'
45
+ }
46
+ ],
47
+ maxFiles: 5
48
+ },
49
+ parameters: {
50
+ helper: {
51
+ description: 'Extraction helper to add or modify, for example TableExtractor, Pagination, JsonLdExtractor, or Extractor.',
52
+ required: true
53
+ },
54
+ instructions: {
55
+ description: 'Specific selectors, data shape, normalization, pagination, or edge cases.',
56
+ required: false
57
+ }
58
+ },
59
+ examples: [
60
+ 'src/extraction/Extractor.ts',
61
+ 'src/extraction/Pagination.ts',
62
+ 'tests/unit/extraction/Extractor.test.ts',
63
+ 'tests/unit/extraction/Pagination.test.ts'
64
+ ],
65
+ context: [
66
+ { kind: 'path', path: 'src/extraction/Extractor.ts', description: 'Current extraction helper.' },
67
+ { kind: 'path', path: 'src/extraction/Pagination.ts', description: 'Current pagination helper.' },
68
+ { kind: 'path', path: 'src/extraction/index.ts', description: 'Extraction barrel export.' },
69
+ { kind: 'path', path: 'src/interaction/PageAdapter.ts', description: 'Page operations available to extraction helpers.' },
70
+ { kind: 'path', path: 'src/errors/ExtractionError.ts', description: 'Typed extraction error.' },
71
+ { kind: 'path', path: 'tests/unit/extraction/Extractor.test.ts', description: 'Extractor tests.' },
72
+ { kind: 'path', path: 'tests/unit/extraction/Pagination.test.ts', description: 'Pagination tests.' },
73
+ { kind: 'path', path: 'tests/fixtures/FakePage.ts', description: 'Fake page fixture.' },
74
+ { kind: 'path', path: 'tests/fixtures/FakeCursor.ts', description: 'Fake cursor for pagination click tests.' }
75
+ ],
76
+ keywordContexts: [
77
+ {
78
+ keywords: ['actor', 'site', 'task', 'scraper'],
79
+ context: [
80
+ { kind: 'path', path: 'src/core/ActorContext.ts', description: 'Extraction helpers available in ActorContext.' },
81
+ { kind: 'path', path: 'src/sites/example/example.actor.ts', description: 'Example actor usage of extraction.' }
82
+ ]
83
+ },
84
+ {
85
+ keywords: ['selector', 'wait', 'page adapter', 'raw puppeteer'],
86
+ context: [
87
+ { kind: 'path', path: 'tests/unit/interaction/PageAdapter.test.ts', description: 'PageAdapter behavior tests.' }
88
+ ]
89
+ }
90
+ ],
91
+ tooling: {
92
+ allowGetExistingCode: true,
93
+ allowFindFiles: true,
94
+ allowSearchRepo: true
95
+ }
96
+ };
@@ -0,0 +1,129 @@
1
+ export default {
2
+ id: 'interaction-behavior',
3
+ description: 'Modify human interaction behavior: ghost-cursor adapter, native interactor, typing, field clearing, forms, navigation, waits, and page adapter behavior.',
4
+ instructions: `
5
+ Modify the interaction layer while preserving the HumanInteractor abstraction.
6
+
7
+ Rules:
8
+ - Keep HumanInteractor as the contract that site actors and forms use.
9
+ - Keep ghost-cursor-specific details inside GhostCursorAdapter.
10
+ - Keep NativePuppeteerInteractor deterministic and suitable for tests/fallbacks.
11
+ - Human-like typing should remain key-by-key unless explicitly disabled.
12
+ - Field clearing should remain opt-in through options and login defaults, not forced globally for all interactions.
13
+ - If PageAdapter gains a method, update PuppeteerPageAdapter and FakePage where appropriate.
14
+ - If FormFiller behavior changes, update Forms tests and any affected LoginFlow tests.
15
+ - If typing timing changes, update HumanTyping tests with deterministic random/sleep functions.
16
+
17
+ DO NOT put site-specific selectors or auth flow logic in the interaction layer.
18
+ DO NOT introduce sleeps where selector waits or navigation waits are more precise.
19
+ `.trim(),
20
+ output: {
21
+ pathTemplates: [
22
+ {
23
+ key: 'human-interactor',
24
+ pathTemplate: 'src/interaction/HumanInteractor.ts',
25
+ description: 'Human interaction interface and shared options.'
26
+ },
27
+ {
28
+ key: 'ghost-adapter',
29
+ pathTemplate: 'src/interaction/GhostCursorAdapter.ts',
30
+ description: 'ghost-cursor-backed interactor implementation.'
31
+ },
32
+ {
33
+ key: 'native-adapter',
34
+ pathTemplate: 'src/interaction/NativePuppeteerInteractor.ts',
35
+ description: 'Puppeteer-native interactor implementation.'
36
+ },
37
+ {
38
+ key: 'typing',
39
+ pathTemplate: 'src/interaction/HumanTyping.ts',
40
+ description: 'Typing timing and key-by-key typing implementation.'
41
+ },
42
+ {
43
+ key: 'field-clearer',
44
+ pathTemplate: 'src/interaction/FieldClearer.ts',
45
+ description: 'Field clearing strategies.'
46
+ },
47
+ {
48
+ key: 'forms',
49
+ pathTemplate: 'src/interaction/Forms.ts',
50
+ description: 'Form filling helper.'
51
+ },
52
+ {
53
+ key: 'page-adapter',
54
+ pathTemplate: 'src/interaction/PageAdapter.ts',
55
+ description: 'Page adapter when new selector/page operations are needed.'
56
+ },
57
+ {
58
+ key: 'tests',
59
+ pathTemplate: 'tests/unit/interaction/{{componentPascal}}.test.ts',
60
+ description: 'Focused tests for the changed interaction component.'
61
+ },
62
+ {
63
+ key: 'fake-page',
64
+ pathTemplate: 'tests/fixtures/FakePage.ts',
65
+ description: 'Update when PageAdapter or keyboard/page behavior changes.'
66
+ },
67
+ {
68
+ key: 'fake-cursor',
69
+ pathTemplate: 'tests/fixtures/FakeCursor.ts',
70
+ description: 'Update when cursor behavior or recorded calls change.'
71
+ }
72
+ ],
73
+ maxFiles: 10
74
+ },
75
+ parameters: {
76
+ component: {
77
+ description: 'Interaction component or behavior to edit, for example typing, cursor, forms, field clearing, page adapter, or navigation.',
78
+ required: true
79
+ },
80
+ instructions: {
81
+ description: 'Specific behavior, options, timing, selectors, or compatibility requirements.',
82
+ required: false
83
+ }
84
+ },
85
+ examples: [
86
+ 'src/interaction/HumanInteractor.ts',
87
+ 'src/interaction/GhostCursorAdapter.ts',
88
+ 'src/interaction/HumanTyping.ts',
89
+ 'src/interaction/FieldClearer.ts',
90
+ 'tests/unit/interaction/HumanTyping.test.ts',
91
+ 'tests/fixtures/FakePage.ts'
92
+ ],
93
+ context: [
94
+ { kind: 'path', path: 'src/interaction/HumanInteractor.ts', description: 'Interaction contract.' },
95
+ { kind: 'path', path: 'src/interaction/GhostCursorAdapter.ts', description: 'ghost-cursor interactor.' },
96
+ { kind: 'path', path: 'src/interaction/NativePuppeteerInteractor.ts', description: 'Puppeteer-native interactor.' },
97
+ { kind: 'path', path: 'src/interaction/HumanTyping.ts', description: 'Human typing implementation.' },
98
+ { kind: 'path', path: 'src/interaction/FieldClearer.ts', description: 'Field clearing implementation.' },
99
+ { kind: 'path', path: 'src/interaction/Forms.ts', description: 'Form helper.' },
100
+ { kind: 'path', path: 'src/interaction/PageAdapter.ts', description: 'Page wrapper.' },
101
+ { kind: 'path', path: 'src/interaction/Navigation.ts', description: 'Navigation helper.' },
102
+ { kind: 'path', path: 'src/interaction/Waits.ts', description: 'Wait profiles.' },
103
+ { kind: 'path', path: 'src/browser/PuppeteerLike.ts', description: 'Keyboard/page/browser types used by interactors and tests.' },
104
+ { kind: 'pattern', pattern: 'tests/unit/interaction/*.test.ts', description: 'Existing interaction tests.', limit: 10 },
105
+ { kind: 'path', path: 'tests/fixtures/FakePage.ts', description: 'Fake page fixture.' },
106
+ { kind: 'path', path: 'tests/fixtures/FakeCursor.ts', description: 'Fake cursor fixture.' }
107
+ ],
108
+ keywordContexts: [
109
+ {
110
+ keywords: ['login', 'auth', 'clearFieldBeforeTyping'],
111
+ context: [
112
+ { kind: 'path', path: 'src/auth/LoginFlow.ts', description: 'Login fill steps consume form/interactor options.' },
113
+ { kind: 'path', path: 'tests/unit/auth/LoginFlow.test.ts', description: 'Login tests may need updates after interaction changes.' }
114
+ ]
115
+ },
116
+ {
117
+ keywords: ['runtime config', 'default typing', 'config'],
118
+ context: [
119
+ { kind: 'path', path: 'src/browser/RuntimeConfig.ts', description: 'Global interaction typing config.' },
120
+ { kind: 'path', path: 'src/core/ActorRunner.ts', description: 'Passes typing config to GhostCursorAdapter.' }
121
+ ]
122
+ }
123
+ ],
124
+ tooling: {
125
+ allowGetExistingCode: true,
126
+ allowFindFiles: true,
127
+ allowSearchRepo: true
128
+ }
129
+ };
@@ -0,0 +1,125 @@
1
+ export default {
2
+ id: 'site-actor',
3
+ description: 'Create or update a website-specific actor, selector map, types, barrel exports, and focused unit tests.',
4
+ instructions: `
5
+ Generate a site actor that follows the existing framework conventions.
6
+
7
+ Rules:
8
+ - Use defineActor from src/core/defineActor.ts.
9
+ - Keep selectors in src/sites/{{siteKebab}}/{{siteKebab}}.selectors.ts.
10
+ - Keep task input/output types in src/sites/{{siteKebab}}/{{siteKebab}}.types.ts.
11
+ - Export the site through src/sites/{{siteKebab}}/index.ts and src/sites/index.ts.
12
+ - Prefer context.nav, context.forms, context.cursor, context.extract, and context.pagination over raw Puppeteer APIs.
13
+ - Use context.page.raw() only when the abstraction does not support the needed operation.
14
+ - Never hard-code credentials or secrets.
15
+ - If login is required, use defineLoginFlow and the typed LoginFlowDefinition shape.
16
+ - If the task scrapes data, use Extractor/Pagination helpers before inventing new extraction logic.
17
+ - Add or update focused unit tests when behavior is non-trivial.
18
+ - Keep actor tasks small and named by what they do, for example scrapeDashboard or scrapeListings.
19
+ - Update barrel exports when adding a new site.
20
+
21
+ DO NOT INVENT selectors that were not supplied by the user unless the instructions explicitly say to make placeholders.
22
+ DO NOT add CAPTCHA bypass, anti-bot evasion, or credential harvesting behavior.
23
+ `.trim(),
24
+ output: {
25
+ pathTemplates: [
26
+ {
27
+ key: 'actor',
28
+ pathTemplate: 'src/sites/{{siteKebab}}/{{siteKebab}}.actor.ts',
29
+ description: 'The site actor with auth definition, hooks, and task implementations.'
30
+ },
31
+ {
32
+ key: 'selectors',
33
+ pathTemplate: 'src/sites/{{siteKebab}}/{{siteKebab}}.selectors.ts',
34
+ description: 'Site-specific CSS selector constants grouped by page/flow.'
35
+ },
36
+ {
37
+ key: 'types',
38
+ pathTemplate: 'src/sites/{{siteKebab}}/{{siteKebab}}.types.ts',
39
+ description: 'Task input/output types for this site.'
40
+ },
41
+ {
42
+ key: 'site-index',
43
+ pathTemplate: 'src/sites/{{siteKebab}}/index.ts',
44
+ description: 'Per-site barrel exports.'
45
+ },
46
+ {
47
+ key: 'sites-index',
48
+ pathTemplate: 'src/sites/index.ts',
49
+ description: 'Global sites barrel export; add this site export if needed.'
50
+ },
51
+ {
52
+ key: 'tests',
53
+ pathTemplate: 'tests/unit/sites/{{siteKebab}}.actor.test.ts',
54
+ description: 'Focused unit tests for task behavior or auth config when useful.'
55
+ }
56
+ ],
57
+ maxFiles: 6
58
+ },
59
+ parameters: {
60
+ site: {
61
+ description: 'The website/site name, for example Apple, Upwork, Example Marketplace, or Acme Dashboard.',
62
+ required: true
63
+ },
64
+ actorId: {
65
+ description: 'Actor id used at runtime. Defaults to the kebab-case site name when omitted.',
66
+ required: false
67
+ },
68
+ baseUrl: {
69
+ description: 'The site base URL, for example https://example.com.',
70
+ required: false
71
+ },
72
+ instructions: {
73
+ description: 'Specific login, task, selector, or scraping behavior to implement.',
74
+ required: false
75
+ }
76
+ },
77
+ examples: [
78
+ 'src/sites/example/example.actor.ts',
79
+ 'src/sites/example/example.selectors.ts',
80
+ 'src/sites/example/example.types.ts',
81
+ 'src/sites/example/index.ts',
82
+ 'src/sites/index.ts'
83
+ ],
84
+ context: [
85
+ { kind: 'path', path: 'src/core/defineActor.ts', description: 'Helper used to define actors.' },
86
+ { kind: 'path', path: 'src/core/Actor.ts', description: 'Actor/task/hook contracts.' },
87
+ { kind: 'path', path: 'src/core/ActorContext.ts', description: 'Task context available to actor implementations.' },
88
+ { kind: 'path', path: 'src/sites/example/example.actor.ts', description: 'Canonical example actor.' },
89
+ { kind: 'path', path: 'src/sites/example/example.selectors.ts', description: 'Canonical selector map.' },
90
+ { kind: 'path', path: 'src/sites/example/example.types.ts', description: 'Canonical site task types.' },
91
+ { kind: 'path', path: 'src/auth/LoginFlow.types.ts', description: 'Auth/login configuration types.' },
92
+ { kind: 'path', path: 'src/extraction/Extractor.ts', description: 'Reusable extraction helper.' },
93
+ { kind: 'path', path: 'src/extraction/Pagination.ts', description: 'Reusable pagination helper.' },
94
+ { kind: 'path', path: 'src/sites/index.ts', description: 'Global site export pattern.' }
95
+ ],
96
+ keywordContexts: [
97
+ {
98
+ keywords: ['login', 'auth', 'sign in', 'signin', 'multi-step', 'username', 'password'],
99
+ context: [
100
+ { kind: 'path', path: 'src/auth/LoginFlow.ts', description: 'Login execution behavior.' },
101
+ { kind: 'path', path: 'tests/unit/auth/LoginFlow.test.ts', description: 'Login config/test examples.' }
102
+ ]
103
+ },
104
+ {
105
+ keywords: ['scrape', 'extract', 'pagination', 'next page', 'table', 'href', 'jsonld'],
106
+ context: [
107
+ { kind: 'path', path: 'tests/unit/extraction/Extractor.test.ts', description: 'Extractor behavior examples.' },
108
+ { kind: 'path', path: 'tests/unit/extraction/Pagination.test.ts', description: 'Pagination behavior examples.' }
109
+ ]
110
+ },
111
+ {
112
+ keywords: ['form', 'type', 'click', 'navigation', 'wait', 'selector'],
113
+ context: [
114
+ { kind: 'path', path: 'src/interaction/Forms.ts', description: 'Form filler helper.' },
115
+ { kind: 'path', path: 'src/interaction/Navigation.ts', description: 'Navigation helper.' },
116
+ { kind: 'path', path: 'src/interaction/PageAdapter.ts', description: 'Page wrapper methods available to actors.' }
117
+ ]
118
+ }
119
+ ],
120
+ tooling: {
121
+ allowGetExistingCode: true,
122
+ allowFindFiles: true,
123
+ allowSearchRepo: true
124
+ }
125
+ };