dsh-work-fish 0.2.0 → 0.2.1
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.
- package/lib/core/approve.mjs +2 -2
- package/lib/core/index.mjs +2 -2
- package/lib/core/paths.test.mjs +80 -0
- package/lib/core/skills.mjs +6 -2
- package/package.json +1 -1
package/lib/core/approve.mjs
CHANGED
|
@@ -40,8 +40,8 @@ import { fileURLToPath } from 'node:url'
|
|
|
40
40
|
import { bundleRoots, inspect, trustedRoots } from './approve-paths.mjs'
|
|
41
41
|
import { resolveWorkHome } from '../tools/lib/paths.mjs'
|
|
42
42
|
|
|
43
|
-
/** Absolute path of
|
|
44
|
-
const PACKAGE_DIR = dirname(dirname(fileURLToPath(import.meta.url)))
|
|
43
|
+
/** Absolute path of the package root (this file sits in `<package>/lib/core/`). */
|
|
44
|
+
export const PACKAGE_DIR = dirname(dirname(dirname(fileURLToPath(import.meta.url))))
|
|
45
45
|
|
|
46
46
|
/** Plugin name used by the loader / Cordis row. */
|
|
47
47
|
export const name = 'wf-approve'
|
package/lib/core/index.mjs
CHANGED
|
@@ -125,9 +125,9 @@ const MAX_REPORTS = 40
|
|
|
125
125
|
const MAX_PERSONA_BYTES = 96 * 1024
|
|
126
126
|
|
|
127
127
|
/** The package version, read once for `/wf/info`. */
|
|
128
|
-
const VERSION = (() => {
|
|
128
|
+
export const VERSION = (() => {
|
|
129
129
|
try {
|
|
130
|
-
return String(JSON.parse(fs.readFileSync(path.join(DIR, '..', 'package.json'), 'utf8')).version ?? '')
|
|
130
|
+
return String(JSON.parse(fs.readFileSync(path.join(DIR, '..', '..', 'package.json'), 'utf8')).version ?? '')
|
|
131
131
|
} catch {
|
|
132
132
|
return ''
|
|
133
133
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guards the package-root derivations.
|
|
3
|
+
*
|
|
4
|
+
* Every module under `lib/` resolves the package root from its own URL; the
|
|
5
|
+
* 0.2.0 restructure (code moved from `<pkg>/core/` into `<pkg>/lib/core/`) left
|
|
6
|
+
* three of them one level short, and nothing failed loudly: the skills row threw
|
|
7
|
+
* ENOENT and took the whole preset down, `/wf/info` silently reported an empty
|
|
8
|
+
* version, and the auto-approver trusted `<pkg>/lib` instead of `<pkg>`.
|
|
9
|
+
*
|
|
10
|
+
* These assertions fail the moment a path derivation drifts again.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import test from 'node:test'
|
|
14
|
+
import assert from 'node:assert/strict'
|
|
15
|
+
import fs from 'node:fs'
|
|
16
|
+
import os from 'node:os'
|
|
17
|
+
import path from 'node:path'
|
|
18
|
+
import { fileURLToPath } from 'node:url'
|
|
19
|
+
|
|
20
|
+
import { VERSION } from './index.mjs'
|
|
21
|
+
import { PACKAGE_DIR } from './approve.mjs'
|
|
22
|
+
import { apply as applySkills } from './skills.mjs'
|
|
23
|
+
import { bootstrap } from './bootstrap.mjs'
|
|
24
|
+
|
|
25
|
+
/** This file sits in `<pkg>/lib/core/`, so the package root is two levels up. */
|
|
26
|
+
const PKG = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..')
|
|
27
|
+
|
|
28
|
+
test('VERSION is read from the package manifest', () => {
|
|
29
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(PKG, 'package.json'), 'utf8'))
|
|
30
|
+
assert.equal(VERSION, manifest.version)
|
|
31
|
+
assert.match(VERSION, /^\d+\.\d+\.\d+$/)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test('the auto-approver trusts the package root, not lib/', () => {
|
|
35
|
+
assert.equal(PACKAGE_DIR, PKG)
|
|
36
|
+
assert.ok(fs.existsSync(path.join(PACKAGE_DIR, 'package.json')))
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
test('bundled skills are read from <pkg>/skills', () => {
|
|
40
|
+
/** @type {{path: string}[]} */
|
|
41
|
+
const registered = []
|
|
42
|
+
const ctx = {
|
|
43
|
+
skills: { register: (skill) => registered.push(skill) },
|
|
44
|
+
logger: { info() {}, warn() {} },
|
|
45
|
+
}
|
|
46
|
+
applySkills(ctx)
|
|
47
|
+
|
|
48
|
+
const skillsRoot = path.join(PKG, 'skills')
|
|
49
|
+
const expected = fs
|
|
50
|
+
.readdirSync(skillsRoot, { withFileTypes: true })
|
|
51
|
+
.filter((entry) => entry.isDirectory() && fs.existsSync(path.join(skillsRoot, entry.name, 'SKILL.md')))
|
|
52
|
+
|
|
53
|
+
assert.equal(registered.length, expected.length)
|
|
54
|
+
for (const skill of registered) {
|
|
55
|
+
assert.ok(skill.path.startsWith(skillsRoot + path.sep), `skill outside <pkg>/skills: ${skill.path}`)
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
test('bootstrap points the rules index at files that exist', () => {
|
|
60
|
+
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'wf-paths-'))
|
|
61
|
+
try {
|
|
62
|
+
bootstrap(home)
|
|
63
|
+
const index = fs.readFileSync(path.join(home, 'rules', 'INDEX.md'), 'utf8')
|
|
64
|
+
|
|
65
|
+
const rule = index.match(/\]\(([^)]+code-rules\.md)\)/)
|
|
66
|
+
assert.ok(rule, 'rules/INDEX.md carries no rule link')
|
|
67
|
+
// The generated index uses forward slashes; resolve before comparing.
|
|
68
|
+
const rulePath = path.resolve(rule[1])
|
|
69
|
+
assert.ok(fs.existsSync(rulePath), `rule link points nowhere: ${rule[1]}`)
|
|
70
|
+
assert.ok(rulePath.startsWith(path.resolve(PKG, 'rules') + path.sep), 'rule link is not inside <pkg>/rules')
|
|
71
|
+
|
|
72
|
+
const tools = index.match(/no `tools\/` directory: `([^`]+)`/)
|
|
73
|
+
assert.ok(tools, 'rules/INDEX.md carries no tools path')
|
|
74
|
+
const toolsPath = path.resolve(tools[1])
|
|
75
|
+
assert.ok(fs.existsSync(toolsPath), `tools path points nowhere: ${tools[1]}`)
|
|
76
|
+
assert.equal(toolsPath, path.resolve(PKG, 'lib', 'tools'))
|
|
77
|
+
} finally {
|
|
78
|
+
fs.rmSync(home, { recursive: true, force: true })
|
|
79
|
+
}
|
|
80
|
+
})
|
package/lib/core/skills.mjs
CHANGED
|
@@ -15,8 +15,12 @@ import fs from 'node:fs'
|
|
|
15
15
|
import path from 'node:path'
|
|
16
16
|
import { fileURLToPath } from 'node:url'
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
|
|
18
|
+
/**
|
|
19
|
+
* `<package>/skills`, resolved from this file rather than from `process.cwd()`.
|
|
20
|
+
* This module sits in `<package>/lib/core/`, so the package root is two levels up
|
|
21
|
+
* and the skills directory is a sibling of `lib/`, not of `core/`.
|
|
22
|
+
*/
|
|
23
|
+
const SKILLS_DIR = fileURLToPath(new URL('../../skills', import.meta.url))
|
|
20
24
|
|
|
21
25
|
/** Provider label stored on every registered skill. */
|
|
22
26
|
const SOURCE = 'dsh-work-fish'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-work-fish",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Unofficial Work Fish plugin for DeepSeek Harness: task setup, task board tracking and delivery, with a floating task panel. Not affiliated with DeepSeek.",
|
|
6
6
|
"type": "module",
|