diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bd7f7d..c6a80fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 2.0.4 + +Fix `update` silently no-opping on projects. Things applies the `update` +command to to-dos only; a project needs the separate `update-project` command, +so renaming or editing a project reported success but changed nothing. + +- **Project updates now route to `update-project`.** `update` (and the + `things_update` MCP tool) reads the resolved entity type and, when it is a + project (`TMTask.type === 1`), issues `things:///update-project` instead of + `things:///update`. A new `buildUpdateProjectUrl` builder backs this. + +Unit test added for the new endpoint builder. + ## 2.0.3 Fix recurring tasks across `someday` and `repeating`. Two bugs, both from the same diff --git a/package-lock.json b/package-lock.json index b29cdce..b16c7b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "thingsctl", - "version": "2.0.1", + "version": "2.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "thingsctl", - "version": "2.0.1", + "version": "2.0.4", "license": "MIT", "os": [ "darwin" diff --git a/package.json b/package.json index 8fa10b3..9f9f63e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "thingsctl", - "version": "2.0.3", + "version": "2.0.4", "description": "A full-featured command-line interface and MCP server for Things 3 on macOS.", "main": "src/cli.js", "type": "commonjs", diff --git a/src/commands/update.js b/src/commands/update.js index 154ae54..c33efba 100644 --- a/src/commands/update.js +++ b/src/commands/update.js @@ -3,7 +3,7 @@ const db = require('../lib/db'); const queries = require('../lib/queries'); const { resolveTaskId } = require('../lib/uuid'); -const { buildUpdateUrl } = require('../lib/url'); +const { buildUpdateUrl, buildUpdateProjectUrl } = require('../lib/url'); const { openUrl } = require('../lib/exec'); const { getToken } = require('../lib/token'); const { colors } = require('../lib/format'); @@ -41,8 +41,11 @@ function run(id, opts = {}) { if (changes.length === 0) throw new Error('No changes specified'); - openUrl(buildUpdateUrl(params)); - return `${colors.green('✓')} Updated "${task.title}": ${changes.join(', ')}`; + // type 1 = project; Things ignores `update` on projects, so route to `update-project`. + const isProject = ref.type === 1; + openUrl(isProject ? buildUpdateProjectUrl(params) : buildUpdateUrl(params)); + const label = isProject ? 'project ' : ''; + return `${colors.green('✓')} Updated ${label}"${task.title}": ${changes.join(', ')}`; } module.exports = { diff --git a/src/lib/url.js b/src/lib/url.js index de43fb8..0c56a0e 100644 --- a/src/lib/url.js +++ b/src/lib/url.js @@ -26,6 +26,11 @@ function buildUpdateUrl(params) { return `things:///update?${_encode(params)}`; } +// Things applies `update` to to-dos only; projects need `update-project`. +function buildUpdateProjectUrl(params) { + return `things:///update-project?${_encode(params)}`; +} + function buildShowUrl(params) { return `things:///show?${_encode(params)}`; } @@ -46,6 +51,7 @@ function buildJsonUrl({ data, authToken, reveal }) { module.exports = { buildAddUrl, buildUpdateUrl, + buildUpdateProjectUrl, buildShowUrl, buildAddProjectUrl, buildJsonUrl, diff --git a/test/unit/url.test.js b/test/unit/url.test.js index 2bb83a1..5a613d3 100644 --- a/test/unit/url.test.js +++ b/test/unit/url.test.js @@ -46,6 +46,13 @@ describe('buildUpdateUrl', () => { }); }); +describe('buildUpdateProjectUrl', () => { + test('targets the update-project endpoint', () => { + const u = url.buildUpdateProjectUrl({ id: 'proj1', title: 'New Name' }); + expect(u).toBe('things:///update-project?id=proj1&title=New%20Name'); + }); +}); + describe('buildJsonUrl', () => { test('encodes nested data as JSON', () => { const u = url.buildJsonUrl({