heartcode 0.1.37 → 0.1.41

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/src/update.js ADDED
@@ -0,0 +1,59 @@
1
+ // A newer HeartCode: asked of npm at most once a day (in the background, never waited on), shown in
2
+ // the status bar, installed with /update the way HeartCode was installed. A git checkout (npm link)
3
+ // isn't npm-installed over: it's told to git pull.
4
+ import fs from 'node:fs'
5
+ import path from 'node:path'
6
+ import { fileURLToPath } from 'node:url'
7
+ import { HOME, VERSION, readJson, writeJson } from './config.js'
8
+
9
+ const FILE = path.join(HOME, 'update-check.json')
10
+ const DAY = 24 * 60 * 60 * 1000
11
+ const PKG = fileURLToPath(new URL('..', import.meta.url))
12
+
13
+ // "0.1.38" > "0.1.37": numbers compared part by part (a pre-release tag isn't offered)
14
+ export const newer = (a, b) => {
15
+ const [x, y] = [a, b].map((v) => String(v).split('-')[0].split('.').map(Number))
16
+ for (let i = 0; i < 3; i++) if ((x[i] || 0) !== (y[i] || 0)) return (x[i] || 0) > (y[i] || 0)
17
+ return false
18
+ }
19
+
20
+ // { current, latest, newer }, or null when npm can't be reached. force: ask now, not from the day's answer.
21
+ export async function checkUpdate({ force = false } = {}) {
22
+ const was = readJson(FILE, {})
23
+ let latest = was.latest
24
+ if (force || !latest || Date.now() - (was.checked ?? 0) > DAY) {
25
+ try {
26
+ const r = await fetch('https://registry.npmjs.org/heartcode/latest', { signal: AbortSignal.timeout(8000) })
27
+ latest = (await r.json()).version
28
+ writeJson(FILE, { checked: Date.now(), latest })
29
+ } catch {
30
+ if (!latest) return null
31
+ }
32
+ }
33
+ return { current: VERSION, latest, newer: Boolean(latest) && newer(latest, VERSION) }
34
+ }
35
+
36
+ // How HeartCode was installed: 'git' (a checkout, linked), or the package manager that put it there.
37
+ export function installKind() {
38
+ if (fs.existsSync(path.join(PKG, '.git')) || !PKG.split(path.sep).includes('node_modules')) return 'git'
39
+ if (/[\\/]pnpm[\\/]/.test(PKG)) return 'pnpm'
40
+ if (/[\\/]\.bun[\\/]/.test(PKG)) return 'bun'
41
+ if (/[\\/]yarn[\\/]/.test(PKG)) return 'yarn'
42
+ return 'npm'
43
+ }
44
+
45
+ export const UPDATE_COMMANDS = { npm: 'npm install -g heartcode@latest', pnpm: 'pnpm add -g heartcode@latest', yarn: 'yarn global add heartcode@latest', bun: 'bun add -g heartcode@latest' }
46
+ export const packageDir = PKG
47
+
48
+ // The changelog's sections from the newest down to (not including) the one running, or ''.
49
+ export async function whatsNew(current, latest) {
50
+ try {
51
+ const r = await fetch('https://raw.githubusercontent.com/p32929/HeartCode/main/CHANGELOG.md', { signal: AbortSignal.timeout(8000) })
52
+ const text = await r.text()
53
+ const start = text.indexOf(`## ${latest}`)
54
+ const end = text.indexOf(`## ${current}`)
55
+ return start >= 0 ? text.slice(start, end > start ? end : undefined).trim().replace(/\n {2,}(?=\S)/g, ' ') : '' // a list item's wrapped lines joined: the box wraps it to its width
56
+ } catch {
57
+ return ''
58
+ }
59
+ }
package/prompts/probe.md DELETED
@@ -1,67 +0,0 @@
1
- # probe.md
2
-
3
- The one-time test of a new model's abilities. Changing these changes how models are judged.
4
- Each `## name` below is one prompt. `{{placeholders}}` are filled in by HeartCode;
5
- a `<!-- … -->` note under a heading explains the prompt and is never sent. To change one, copy
6
- its section into ~/.heart/prompts/probe.md (every project) or .heartcode/prompts/probe.md (one project).
7
-
8
- ## capital
9
-
10
- What is the capital of France? Answer in one word.
11
-
12
- ## count
13
-
14
- Count from 1 to 10, separated by spaces. Reply with only the numbers.
15
-
16
- ## edit
17
-
18
- <!-- The "edit skill" test. {{code}}: a small file. {{ask}}: the change to make. -->
19
- Here is a file:
20
- ```
21
- {{code}}```
22
-
23
- {{ask}}
24
- Reply with only a SEARCH/REPLACE block in exactly this format:
25
- <<<<<<< SEARCH
26
- (exact lines to find)
27
- =======
28
- (replacement lines)
29
- >>>>>>> REPLACE
30
-
31
- ## exact-number
32
-
33
- <!-- The "exact format" test. {{n}}: a number. -->
34
- Reply with only the number {{n}}. No other words.
35
-
36
- ## hello
37
-
38
- Say hello in one short sentence.
39
-
40
- ## image-color
41
-
42
- What color is this image? Reply with one word.
43
-
44
- ## menu
45
-
46
- <!-- The "menu picking" test. {{what}}: e.g. "a fruit". {{list}}: numbered options. -->
47
- Which of these is {{what}}?
48
- {{list}}
49
- Reply with only the number.
50
-
51
- ## system
52
-
53
- <!-- The system prompt of the "follows the system prompt" test; the model passes by replying BANANA. -->
54
- Whatever the user says, reply with only the single word BANANA.
55
-
56
- ## tool-description
57
-
58
- Look up the secret code for a name.
59
-
60
- ## tool-question
61
-
62
- <!-- The tool-call test. {{name}}: the name to look up. -->
63
- What is the secret code for "{{name}}"? Use the get_secret_code tool to find out.
64
-
65
- ## tool-result
66
-
67
- The secret code is ZX-4417.