@tenonhq/dovetail-core 0.0.85

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 (78) hide show
  1. package/README.md +6 -0
  2. package/dist/FileLogger.js +207 -0
  3. package/dist/FileUtils.js +387 -0
  4. package/dist/Logger.js +88 -0
  5. package/dist/MultiScopeWatcher.js +615 -0
  6. package/dist/PluginManager.js +125 -0
  7. package/dist/_defaultOptionsOLD.js +44 -0
  8. package/dist/allScopesCommands.js +418 -0
  9. package/dist/appUtils.js +929 -0
  10. package/dist/benchmark.js +104 -0
  11. package/dist/bootstrap.js +62 -0
  12. package/dist/claudeCommand.js +60 -0
  13. package/dist/clickupCommands.js +472 -0
  14. package/dist/clickupPushHelper.js +33 -0
  15. package/dist/commander.js +466 -0
  16. package/dist/commands.js +378 -0
  17. package/dist/config.js +697 -0
  18. package/dist/constants.js +15 -0
  19. package/dist/createRecordCommand.js +314 -0
  20. package/dist/dashboardCommand.js +38 -0
  21. package/dist/defaultOptions.js +14 -0
  22. package/dist/deleteRecordCommand.js +282 -0
  23. package/dist/flowDesigner/values.js +55 -0
  24. package/dist/genericUtils.js +189 -0
  25. package/dist/gitUtils.js +99 -0
  26. package/dist/index.js +35 -0
  27. package/dist/initSystem/corePlugin.js +344 -0
  28. package/dist/initSystem/discovery.js +107 -0
  29. package/dist/initSystem/orchestrator.js +408 -0
  30. package/dist/logMessages.js +82 -0
  31. package/dist/loginCommand.js +20 -0
  32. package/dist/migrateCommand.js +123 -0
  33. package/dist/projectFiles.js +32 -0
  34. package/dist/recentEdits.js +66 -0
  35. package/dist/schemaCommand.js +85 -0
  36. package/dist/snClient.js +519 -0
  37. package/dist/tests/benchmarkRefresh.test.js +265 -0
  38. package/dist/tests/clickupCommands.test.js +384 -0
  39. package/dist/tests/clickupPushHelper.test.js +124 -0
  40. package/dist/tests/configFallback.test.js +68 -0
  41. package/dist/tests/cred.test.js +59 -0
  42. package/dist/tests/discovery.test.js +67 -0
  43. package/dist/tests/ensureUpdateSetWarnings.test.js +218 -0
  44. package/dist/tests/errorLogLevels.test.js +273 -0
  45. package/dist/tests/example.test.js +6 -0
  46. package/dist/tests/fileContextSkipReason.test.js +116 -0
  47. package/dist/tests/globalDebounce.test.js +308 -0
  48. package/dist/tests/migrateCommand.test.js +113 -0
  49. package/dist/tests/multi-scope-watcher.test.js +558 -0
  50. package/dist/tests/orchestrator.test.js +23 -0
  51. package/dist/tests/pushFiles.test.js +248 -0
  52. package/dist/tests/rateLimitCoordination.test.js +271 -0
  53. package/dist/tests/resolveConfigReadOnly.test.js +67 -0
  54. package/dist/tests/retryOnHttpErr.test.js +154 -0
  55. package/dist/tests/scopeCaching.test.js +115 -0
  56. package/dist/tests/serializeUpdateSetConfig.test.js +325 -0
  57. package/dist/tests/snClient.fallback.test.js +120 -0
  58. package/dist/tests/syncManifestRefresh.test.js +287 -0
  59. package/dist/tests/syncManifestWhitelist.test.js +192 -0
  60. package/dist/tests/taskClear.test.js +170 -0
  61. package/dist/tests/taskStaleness.test.js +220 -0
  62. package/dist/tests/unwrapSNResponseError.test.js +145 -0
  63. package/dist/tests/v2Values.test.js +79 -0
  64. package/dist/tests/validateTaskId.test.js +304 -0
  65. package/dist/tests/verifyUpdateSetSwitch.test.js +277 -0
  66. package/dist/tests/writeEnvVar.test.js +119 -0
  67. package/dist/updateSetCommands.js +702 -0
  68. package/dist/wizard.js +40 -0
  69. package/package.json +69 -0
  70. package/skills/dove-configure-pipeline.md +158 -0
  71. package/skills/dove-create-plugin.md +174 -0
  72. package/skills/dove-create-record.md +135 -0
  73. package/skills/dove-debug-build.md +117 -0
  74. package/skills/dove-delete-record.md +104 -0
  75. package/skills/dove-manage-tables.md +174 -0
  76. package/skills/dove-manage-update-sets.md +88 -0
  77. package/skills/dove-setup-project.md +154 -0
  78. package/skills/dove-troubleshoot-sync.md +113 -0
@@ -0,0 +1,104 @@
1
+ # Delete ServiceNow Records
2
+
3
+ ## Task
4
+ $ARGUMENTS
5
+
6
+ ## Instructions for Claude
7
+
8
+ ### Directory Context
9
+
10
+ Dovetail commands can be run from two locations:
11
+ - **From `ServiceNow/` directory:** `npx sinc <command>`
12
+ - **From Craftsman root:** `npm run sinc:<command>` (proxy scripts)
13
+
14
+ The `delete` command requires running from the `ServiceNow/` directory directly, as it accepts flags and arguments that npm run scripts don't forward.
15
+
16
+ ---
17
+
18
+ Help the user delete records from a ServiceNow instance using Dovetail's `delete` command. After deletion, local files and the manifest are automatically cleaned up.
19
+
20
+ ### Command Syntax
21
+
22
+ ```bash
23
+ npx dove delete <table> [name] [options]
24
+ ```
25
+
26
+ ### Options
27
+
28
+ | Flag | Alias | Type | Description |
29
+ |------|-------|------|-------------|
30
+ | `--scope` | `-s` | string | Target scope (e.g., x_cadso_core) |
31
+ | `--sysid` | | string | Delete by sys_id directly (skip manifest lookup) |
32
+ | `--ci` | | boolean | Skip confirmation prompt |
33
+ | `--keep-local` | | boolean | Keep local files after instance delete |
34
+
35
+ ### Examples
36
+
37
+ #### Delete by record name (interactive)
38
+
39
+ ```bash
40
+ npx dove delete sys_script_include MyOldUtil
41
+ # Prompts for: scope (if not determinable), confirmation
42
+ ```
43
+
44
+ #### Delete with scope
45
+
46
+ ```bash
47
+ npx dove delete sys_script_include MyOldUtil --scope x_cadso_core
48
+ ```
49
+
50
+ #### Delete by sys_id
51
+
52
+ ```bash
53
+ npx dove delete sys_script_include --sysid abc123def456789012345678901234ab --scope x_cadso_core
54
+ ```
55
+
56
+ #### Delete but keep local files
57
+
58
+ ```bash
59
+ npx dove delete sys_script_include MyOldUtil --scope x_cadso_core --keep-local
60
+ ```
61
+
62
+ #### CI/Automation mode (no prompts)
63
+
64
+ ```bash
65
+ npx dove delete sys_script_include MyOldUtil --scope x_cadso_core --ci
66
+ ```
67
+
68
+ ### What Happens After Delete
69
+
70
+ 1. **Record is deleted** from the ServiceNow instance via `api/cadso/dovetail/deleteRecord`
71
+ 2. **Local files are removed** — the entire record directory (`src/<scope>/<table>/<name>/`) is deleted
72
+ 3. **Manifest is updated** — the record entry is removed from `dove.manifest.<scope>.json`
73
+ 4. If the table has no remaining records, the table entry is also removed from the manifest
74
+
75
+ ### How sys_id Resolution Works
76
+
77
+ When you provide a **record name** (not `--sysid`):
78
+ 1. The scope manifest (`dove.manifest.<scope>.json`) is loaded
79
+ 2. The sys_id is looked up from `manifest.tables[table].records[name].sys_id`
80
+ 3. If not found, an error is shown with a suggestion to use `--sysid`
81
+
82
+ ### Common Table Names
83
+
84
+ | Table | Deletes |
85
+ |-------|---------|
86
+ | `sys_script_include` | Script Include |
87
+ | `sys_script` | Business Rule |
88
+ | `sys_ui_script` | UI Script |
89
+ | `sys_ui_page` | UI Page |
90
+ | `sys_ux_client_script` | UX Client Script |
91
+ | `sys_processor` | Processor |
92
+ | `sys_ws_operation` | REST API Operation |
93
+ | `sys_rest_message_fn` | REST Message Function |
94
+ | `sys_ui_action` | UI Action |
95
+ | `sysevent_script_action` | Event Script Action |
96
+
97
+ ### Troubleshooting
98
+
99
+ - **"Record not found in manifest"** — The record isn't tracked locally. Use `--sysid` to delete by sys_id directly, or run `npx dove refresh` first
100
+ - **"Missing required fields: table, sys_id"** — Provide the table as the first argument and either a name or `--sysid`
101
+ - **"Record not found: table/sys_id"** — The record doesn't exist on the instance (may have been deleted already)
102
+ - **"Failed to delete record"** — Check permissions. The user may not have delete access to this table/scope
103
+ - **"Local cleanup failed"** — Record was deleted on instance but local files remain. Run `npx dove refresh` to sync
104
+ - **Deleted wrong record** — Records deleted from ServiceNow cannot be recovered unless they're in an update set that hasn't been committed. Check update set history
@@ -0,0 +1,174 @@
1
+ # Manage Dovetail Table Includes, Excludes, and Options
2
+
3
+ ## Task
4
+ $ARGUMENTS
5
+
6
+ ## Instructions for Claude
7
+
8
+ ### Directory Context
9
+
10
+ Dovetail commands can be run from two locations:
11
+ - **From `ServiceNow/` directory:** `npx sinc <command>`
12
+ - **From Craftsman root:** `npm run sinc:<command>` (proxy scripts)
13
+
14
+ Available root scripts: `sinc:init`, `sinc:start`, `sinc:dev`, `sinc:build`, `sinc:deploy`, `sinc:push`, `sinc:refresh`, `sinc:status`
15
+
16
+ When this skill references `npx sinc <command>`, use `npm run sinc:<command>` if working from the Craftsman root. Configuration files (`dove.config.js`) live in the `ServiceNow/` directory.
17
+
18
+ ---
19
+
20
+ Help the user configure which ServiceNow tables and fields Dovetail tracks, and how records are organized locally.
21
+
22
+ ### How Table Filtering Works
23
+
24
+ Dovetail has a three-layer system:
25
+
26
+ 1. **Default excludes** (built into core) -- Tables excluded by default because they contain non-code metadata
27
+ 2. **User `excludes`** in `dove.config.js` -- Additional exclusions or overrides of defaults
28
+ 3. **User `includes`** in `dove.config.js` -- Explicit inclusions that override excludes
29
+
30
+ User config is ADDITIVE to defaults (merged with `Object.assign`).
31
+
32
+ ### Default Excluded Tables
33
+
34
+ These tables are excluded by default:
35
+
36
+ ```
37
+ sys_scope_privilege, sys_dictionary, sys_impex_entry, sys_security_acl,
38
+ sys_transform_map, sys_ui_policy, sys_ui_list_control, sys_relationship,
39
+ sys_report, item_option_new, sys_process_flow, content_block_programmatic,
40
+ sp_instance, sys_transform_script, sc_category, sysrule_view, sc_cat_item,
41
+ sysevent_in_email_action, sys_navigator, sys_transform_entry,
42
+ metric_definition, content_block_lists, content_block_detail, sp_portal,
43
+ sc_cat_item_producer, sys_impex_map
44
+ ```
45
+
46
+ ### Excludes Configuration
47
+
48
+ ```javascript
49
+ // dove.config.js
50
+ module.exports = {
51
+ excludes: {
52
+ // Override a default exclusion (RE-INCLUDE the table)
53
+ sys_scope_privilege: false,
54
+
55
+ // Exclude an entire table
56
+ my_cool_table: true,
57
+
58
+ // Exclude specific fields from a table (other fields still included)
59
+ new_cool_table: {
60
+ cool_script: true
61
+ }
62
+ }
63
+ };
64
+ ```
65
+
66
+ ### Includes Configuration
67
+
68
+ Includes override excludes when there is a conflict on the same table.
69
+
70
+ ```javascript
71
+ // dove.config.js
72
+ module.exports = {
73
+ includes: {
74
+ // Override a default inclusion (REMOVE the table)
75
+ content_css: false,
76
+
77
+ // Explicitly include a table (overrides any exclude on same table)
78
+ sys_report: true,
79
+
80
+ // Include a specific field with a custom file type
81
+ special_code_table: {
82
+ neat_script_field: {
83
+ type: "js"
84
+ }
85
+ }
86
+ }
87
+ };
88
+ ```
89
+
90
+ Valid file types: `"js"`, `"css"`, `"xml"`, `"html"`, `"scss"`, `"txt"`, `"json"`
91
+
92
+ ### Table Options
93
+
94
+ The `tableOptions` section controls how records are organized on disk:
95
+
96
+ ```javascript
97
+ // dove.config.js
98
+ module.exports = {
99
+ tableOptions: {
100
+ some_table: {
101
+ // Use a different field for the record folder name
102
+ displayField: "some_field",
103
+
104
+ // De-duplicate records with the same display value
105
+ differentiatorField: "sys_id",
106
+
107
+ // Can be an array -- falls back to next field if first is empty
108
+ differentiatorField: ["some_field", "sys_id"],
109
+
110
+ // Filter records with an encoded query
111
+ query: "active=true^category=scripts"
112
+ }
113
+ }
114
+ };
115
+ ```
116
+
117
+ ### After Changing Configuration
118
+
119
+ 1. Run `npx dove refresh` to update the manifest with new tables/fields
120
+ 2. Manually delete any folders for tables you just excluded (Dovetail does not auto-delete)
121
+ 3. New tables/fields will be downloaded automatically by refresh
122
+
123
+ ### Common Recipes
124
+
125
+ **Track only script-related tables:**
126
+ ```javascript
127
+ includes: {
128
+ sys_script_include: true,
129
+ sys_script: true,
130
+ sys_ui_script: true,
131
+ sys_ui_page: true,
132
+ sp_widget: true
133
+ }
134
+ ```
135
+
136
+ **Include a non-code field as code:**
137
+ ```javascript
138
+ includes: {
139
+ sys_ui_page: {
140
+ html: { type: "html" },
141
+ client_script: { type: "js" },
142
+ processing_script: { type: "js" }
143
+ }
144
+ }
145
+ ```
146
+
147
+ **Filter records by query:**
148
+ ```javascript
149
+ tableOptions: {
150
+ sys_script_include: {
151
+ query: "active=true"
152
+ }
153
+ }
154
+ ```
155
+
156
+ ### Scope-Specific Configuration
157
+
158
+ When using multi-scope mode, each scope can have its own `tableOptions`:
159
+
160
+ ```javascript
161
+ module.exports = {
162
+ tableOptions: { /* default table options */ },
163
+ scopes: {
164
+ x_cadso_core: {
165
+ sourceDirectory: "src/x_cadso_core",
166
+ tableOptions: {
167
+ sys_script_include: {
168
+ query: "active=true"
169
+ }
170
+ }
171
+ }
172
+ }
173
+ };
174
+ ```
@@ -0,0 +1,88 @@
1
+ # Manage ServiceNow Update Sets
2
+
3
+ ## Task
4
+ $ARGUMENTS
5
+
6
+ ## Instructions for Claude
7
+
8
+ ### Directory Context
9
+
10
+ Dovetail commands can be run from two locations:
11
+ - **From `ServiceNow/` directory:** `npx sinc <command>`
12
+ - **From Craftsman root:** `npm run sinc:<command>` (proxy scripts)
13
+
14
+ Available root scripts: `sinc:init`, `sinc:start`, `sinc:dev`, `sinc:build`, `sinc:deploy`, `sinc:push`, `sinc:refresh`, `sinc:status`
15
+
16
+ When this skill references `npx sinc <command>`, use `npm run sinc:<command>` if working from the Craftsman root. Note: commands with extra flags (e.g., `npx dove push --updateSet "name"`) require running from the `ServiceNow/` directory directly, as npm run scripts don't forward arguments.
17
+
18
+ ---
19
+
20
+ Help the user manage ServiceNow update sets through Dovetail's CLI commands and dashboard.
21
+
22
+ ### Available Commands
23
+
24
+ | Command | Purpose |
25
+ |---------|---------|
26
+ | `npx dove listUpdateSets` | List all in-progress update sets |
27
+ | `npx dove listUpdateSets --scope x_cadso_core` | List update sets for a specific scope |
28
+ | `npx dove createUpdateSet --name "FEAT-123 New Feature"` | Create and activate a new update set |
29
+ | `npx dove createUpdateSet --name "FEAT-123" --scope x_cadso_core --description "Feature description"` | Create with scope and description |
30
+ | `npx dove switchUpdateSet --name "FEAT-123"` | Switch to an existing update set (partial name match) |
31
+ | `npx dove switchUpdateSet --scope x_cadso_core` | Browse and select from a scope's update sets |
32
+ | `npx dove currentUpdateSet` | Show the currently active update set |
33
+ | `npx dove currentScope` | Show the currently active scope |
34
+ | `npx dove changeScope --scope x_cadso_work` | Switch to a different scope |
35
+
36
+ ### Push with Update Set
37
+
38
+ Create a new update set as part of a push operation:
39
+
40
+ ```bash
41
+ npx dove push --updateSet "FEAT-123 My Changes"
42
+ # or short form:
43
+ npx dove push --us "FEAT-123 My Changes"
44
+ ```
45
+
46
+ This creates the update set, assigns it as current, and pushes all files into it.
47
+
48
+ ### Web Dashboard
49
+
50
+ Dovetail includes a web dashboard for visual update set management:
51
+
52
+ ```bash
53
+ npx dove dashboard
54
+ ```
55
+
56
+ Launches at `http://localhost:3456` (configurable via `DASHBOARD_PORT` in `.env`). Features:
57
+ - All configured scopes with display names
58
+ - In-progress update sets per scope
59
+ - Create new update sets
60
+ - Close (complete) update sets
61
+ - Select active update set per scope
62
+
63
+ The dashboard reads scopes from `dove.config.js` and stores selections in `.dove-update-sets.json`.
64
+
65
+ ### Multi-Scope Update Set Monitoring
66
+
67
+ When using `npx dove watchAllScopes`, update set status is automatically checked every 2 minutes. It warns if any scope is using the DEFAULT update set (a common mistake that puts changes in the wrong place).
68
+
69
+ ### Recommended Workflow
70
+
71
+ 1. **Before starting work:** Create a named update set for your feature/ticket:
72
+ ```bash
73
+ npx dove createUpdateSet --name "FEAT-123 Add User Dashboard" --scope x_cadso_core
74
+ ```
75
+
76
+ 2. **During development:** Use `npx dove dev` or `npx dove watchAllScopes`. Changes go into the active update set.
77
+
78
+ 3. **Check status:** `npx dove currentUpdateSet` to verify you are in the right update set.
79
+
80
+ 4. **When done:** Complete the update set in ServiceNow or via the dashboard.
81
+
82
+ 5. **For deployment:** Use `npx dove push --us "RELEASE-1.0"` to push all changes into a clean update set.
83
+
84
+ ### Common Issues
85
+
86
+ - **"No update set selected"** -- You are using the Default update set. Create or switch to a named one.
87
+ - **Changes going to wrong scope** -- In multi-scope mode, use `npx dove watchAllScopes` which auto-switches scopes. Single-scope `npx dove dev` only works for one scope.
88
+ - **Update set not found** -- Check the scope filter. Update sets are scope-specific.
@@ -0,0 +1,154 @@
1
+ # Set Up Dovetail Project
2
+
3
+ ## Task
4
+ $ARGUMENTS
5
+
6
+ ## Instructions for Claude
7
+
8
+ ### Directory Context
9
+
10
+ Dovetail commands can be run from two locations:
11
+ - **From `ServiceNow/` directory:** `npx sinc <command>`
12
+ - **From Craftsman root:** `npm run sinc:<command>` (proxy scripts)
13
+
14
+ Available root scripts: `sinc:init`, `sinc:start`, `sinc:dev`, `sinc:build`, `sinc:deploy`, `sinc:push`, `sinc:refresh`, `sinc:status`
15
+
16
+ When this skill references `npx sinc <command>`, use `npm run sinc:<command>` if working from the Craftsman root. Configuration files (`dove.config.js`, `.env`, manifests) live in the `ServiceNow/` directory.
17
+
18
+ ---
19
+
20
+ Help the user set up a new Dovetail project or add a new scope to an existing project.
21
+
22
+ ### Determine the Scenario
23
+
24
+ 1. **New project from scratch** -- No `dove.config.js` exists yet
25
+ 2. **Add a new scope to existing project** -- `dove.config.js` exists, need to add scope config
26
+ 3. **Re-initialize / reset** -- Project exists but needs fresh download
27
+
28
+ ### Scenario 1: New Project
29
+
30
+ #### Prerequisites check
31
+ - Node.js v20 LTS installed (`node -v`)
32
+ - The Dovetail server scoped app is installed on the target ServiceNow instance
33
+
34
+ #### Initialize the project
35
+ ```bash
36
+ mkdir my-servicenow-app && cd my-servicenow-app
37
+ npm init -y
38
+ npm i -D @tenonhq/dovetail-core
39
+ ```
40
+
41
+ #### Run the init wizard
42
+ ```bash
43
+ npx dove init
44
+ ```
45
+ Prompts for: instance URL, username, password, and which scoped app to download.
46
+
47
+ #### Configure the build pipeline
48
+ Direct the user to use the `configure-pipeline` skill or help inline.
49
+
50
+ #### Set up `.env`
51
+ ```
52
+ SN_USER=admin
53
+ SN_PASSWORD=your_password
54
+ SN_INSTANCE=your-instance.service-now.com
55
+ ```
56
+ - Instance should NOT have `https://` prefix or trailing slash
57
+ - Optional: `DASHBOARD_PORT=3456`
58
+ - **Never commit `.env` to git**
59
+
60
+ #### Set up `.gitignore`
61
+ ```
62
+ node_modules/
63
+ .env
64
+ build/
65
+ dove.manifest*.json
66
+ dovetail-debug-*.log
67
+ ```
68
+
69
+ #### Start development
70
+ ```bash
71
+ npx dove dev
72
+ ```
73
+
74
+ ### Scenario 2: Add a New Scope (Multi-Scope Setup)
75
+
76
+ #### Add the scope to `dove.config.js`
77
+ ```javascript
78
+ module.exports = {
79
+ sourceDirectory: "src",
80
+ buildDirectory: "build",
81
+ rules: [ /* ... */ ],
82
+ scopes: {
83
+ x_cadso_core: {
84
+ sourceDirectory: "src/x_cadso_core"
85
+ },
86
+ x_cadso_work: {
87
+ sourceDirectory: "src/x_cadso_work"
88
+ }
89
+ }
90
+ };
91
+ ```
92
+
93
+ #### Download all scopes
94
+ ```bash
95
+ npx dove initScopes
96
+ ```
97
+ Creates per-scope manifest files (`dove.manifest.x_cadso_core.json`, etc.) and downloads files to each scope's source directory.
98
+
99
+ If hitting rate limits:
100
+ ```bash
101
+ npx dove initScopes --delay 1000
102
+ ```
103
+
104
+ #### Watch all scopes simultaneously
105
+ ```bash
106
+ npx dove watchAllScopes
107
+ ```
108
+ Watches all scope directories, auto-switches ServiceNow scope context per file, monitors update set status every 2 minutes.
109
+
110
+ #### Download a single scope
111
+ ```bash
112
+ npx dove download x_cadso_core
113
+ ```
114
+
115
+ ### Scenario 3: Reset / Re-download
116
+
117
+ 1. Back up any local changes (commit to git)
118
+ 2. Run: `npx dove download <scope>` (destructive -- overwrites local files)
119
+ 3. Or for all scopes: `npx dove initScopes`
120
+
121
+ ### File Structure After Setup
122
+
123
+ ```
124
+ project/
125
+ .env # Credentials (git-ignored)
126
+ dove.config.js # Build pipeline config
127
+ dove.manifest.json # Single-scope manifest
128
+ dove.manifest.x_cadso_core.json # Multi-scope manifest
129
+ src/
130
+ x_cadso_core/
131
+ sys_script_include/
132
+ MyScriptInclude/
133
+ script.ts
134
+ sys_ui_page/
135
+ MyUIPage/
136
+ html.html
137
+ client_script.js
138
+ x_cadso_work/
139
+ ...
140
+ build/ # Built output (git-ignored)
141
+ node_modules/ # Dependencies (git-ignored)
142
+ ```
143
+
144
+ ### Commands Reference
145
+
146
+ | Command | Purpose |
147
+ |---------|---------|
148
+ | `npx dove init` | Interactive project setup |
149
+ | `npx dove initScopes` | Download all configured scopes |
150
+ | `npx dove download <scope>` | Download a specific scope (destructive) |
151
+ | `npx dove refresh` | Refresh manifest, download new files only |
152
+ | `npx dove dev` | Start single-scope watch mode |
153
+ | `npx dove watchAllScopes` | Start multi-scope watch mode |
154
+ | `npx dove status` | Show connected instance, scope, user |
@@ -0,0 +1,113 @@
1
+ # Troubleshoot Dovetail Sync Issues
2
+
3
+ ## Task
4
+ $ARGUMENTS
5
+
6
+ ## Instructions for Claude
7
+
8
+ ### Directory Context
9
+
10
+ Dovetail commands can be run from two locations:
11
+ - **From `ServiceNow/` directory:** `npx sinc <command>`
12
+ - **From Craftsman root:** `npm run sinc:<command>` (proxy scripts)
13
+
14
+ Available root scripts: `sinc:init`, `sinc:start`, `sinc:dev`, `sinc:build`, `sinc:deploy`, `sinc:push`, `sinc:refresh`, `sinc:status`
15
+
16
+ When this skill references `npx sinc <command>`, use `npm run sinc:<command>` if working from the Craftsman root. References to "project root" mean the `ServiceNow/` directory (where `dove.config.js`, `.env`, and manifest files live).
17
+
18
+ ---
19
+
20
+ Help the user diagnose and fix Dovetail synchronization problems. Follow this systematic diagnostic approach.
21
+
22
+ ### Step 1: Identify the Symptom Category
23
+
24
+ Ask the user which symptom they are experiencing (if not already clear):
25
+
26
+ - **A. Files not pushing** -- saves detected but nothing reaches ServiceNow
27
+ - **B. Authentication/connection failure** -- errors about credentials or instance
28
+ - **C. Scope mismatch** -- "scope check failed" errors
29
+ - **D. Build/transform errors** -- plugin pipeline failures
30
+ - **E. Missing files** -- files exist in ServiceNow but not locally (or vice versa)
31
+ - **F. Manifest corruption** -- strange behavior, duplicate records, wrong sys_ids
32
+
33
+ ### Diagnostic A: Files Not Pushing
34
+
35
+ 1. **Check dev mode is running:** `npx dove dev` or `npx dove watchAllScopes`
36
+ 2. **Check the file is in the manifest:** Look in `dove.manifest.json` or `dove.manifest.<scope>.json` for the table/record/field entry. If missing, run `npx dove refresh`.
37
+ 3. **Check file extension matches a rule:** The file extension must match a `match` regex in `dove.config.js` rules. If no rule matches, the file content is pushed as-is (no build).
38
+ 4. **Check debug logs:** Look for `dovetail-debug-*.log` files in the project root.
39
+ 5. **Try manual push:** `npx dove push` to push all files and see errors.
40
+
41
+ ### Diagnostic B: Authentication/Connection Failure
42
+
43
+ 1. **Verify `.env` file exists** in the project root with correct values:
44
+ ```
45
+ SN_USER=your_username
46
+ SN_PASSWORD=your_password
47
+ SN_INSTANCE=your-instance.service-now.com
48
+ ```
49
+ - Instance should NOT have `https://` prefix or trailing slash
50
+ - Credentials must have admin or developer role
51
+
52
+ 2. **Test connection:** `npx dove status`
53
+
54
+ 3. **Check the Dovetail server scoped app** is installed on the instance. Without it, API endpoints will 404.
55
+
56
+ 4. **Check for MFA/SSO:** If the instance uses MFA or SSO, basic auth may not work. You may need a local ServiceNow account.
57
+
58
+ ### Diagnostic C: Scope Mismatch
59
+
60
+ Dovetail checks that your local manifest scope matches the active scope on the ServiceNow instance.
61
+
62
+ 1. **Check current scope:** `npx dove currentScope`
63
+ 2. **Change scope:** `npx dove changeScope --scope x_cadso_core`
64
+ 3. **For multi-scope watch:** `npx dove watchAllScopes` handles scope switching automatically per file.
65
+ 4. **Force scope swap on push:** `npx dove push --scopeSwap`
66
+
67
+ ### Diagnostic D: Build/Transform Errors
68
+
69
+ 1. **Run a local build to see errors:** `npx dove build`
70
+ 2. **Common Babel errors:**
71
+ - "Cannot find module '@tenonhq/dovetail-remove-modules'" -- Need `npm i -D @tenonhq/dovetail-babel-plugin-remove-modules`
72
+ - "Cannot find module '@tenonhq/dovetail-servicenow'" -- Need `npm i -D @tenonhq/dovetail-babel-preset-servicenow`
73
+ - Note: Babel package names differ from dove.config.js names. In Babel config, `@tenonhq/dovetail-remove-modules` refers to npm package `@tenonhq/dovetail-babel-plugin-remove-modules`.
74
+
75
+ 3. **Common TypeScript errors:**
76
+ - Type errors block the build. Fix the types or set `transpile: true` to skip type checking.
77
+ - Missing `tsconfig.json` -- Plugin works without it but may produce unexpected output.
78
+
79
+ 4. **Rhino engine errors (code works locally but fails in ServiceNow):**
80
+ - Missing `@tenonhq/dovetail-servicenow` preset -- `__proto__` references and reserved word property access crash Rhino.
81
+ - Using `useBuiltIns` with `@babel/env` -- Polyfills fail because Rhino locks base class prototypes.
82
+ - Using `for...of`, `Map`, `Set`, `WeakMap` -- These require prototype extensions that Rhino blocks.
83
+ - Using arrow functions in class properties without `@babel/proposal-class-properties`.
84
+
85
+ ### Diagnostic E: Missing Files
86
+
87
+ 1. **Files in ServiceNow but not local:**
88
+ - Run `npx dove refresh` to update the manifest and download new files.
89
+ - Check `excludes` in `dove.config.js` -- the table may be excluded.
90
+ - Check `includes` -- some tables need explicit inclusion.
91
+
92
+ 2. **Files local but not in ServiceNow:**
93
+ - Records must be created in ServiceNow first, then `npx dove refresh` to pick them up.
94
+ - Dovetail does NOT create ServiceNow records from local files.
95
+
96
+ ### Diagnostic F: Manifest Corruption
97
+
98
+ 1. **Symptoms:** Wrong files being pushed, duplicate record folders, sys_id mismatches.
99
+ 2. **Fix:** Delete the manifest file(s) and re-download:
100
+ ```bash
101
+ rm dove.manifest*.json
102
+ npx dove download <scope>
103
+ # or for multi-scope:
104
+ npx dove initScopes
105
+ ```
106
+ 3. **Prevention:** Never manually edit `dove.manifest.json`. Never have duplicate record display values in the same table.
107
+
108
+ ### General Tips
109
+
110
+ - Always `npx dove refresh` before starting work to catch new records.
111
+ - Use `npx dove status` to verify connectivity.
112
+ - Check `dovetail-debug-*.log` for detailed error information.
113
+ - Node.js v20 LTS is required -- check with `node -v`.