@hasna/knowledge 0.1.0 → 0.2.0
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/.github/ISSUE_TEMPLATE/bug_report.yml +59 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +34 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +21 -0
- package/.github/workflows/ci.yml +49 -0
- package/CODE_OF_CONDUCT.md +31 -0
- package/CONTRIBUTING.md +83 -0
- package/FUNDING.yml +1 -0
- package/LICENSE +202 -0
- package/README.md +146 -0
- package/SECURITY.md +39 -0
- package/bin/open-knowledge.js +58 -0
- package/npmignore +9 -0
- package/package.json +23 -5
- package/src/cli.ts +483 -0
- package/src/store.ts +103 -0
- package/tests/cli.test.ts +9 -2
- package/tsconfig.json +16 -0
- package/src/cli.js +0 -279
- package/src/store.js +0 -32
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
name: Bug Report
|
|
2
|
+
description: Report a bug in open-knowledge
|
|
3
|
+
labels: [bug]
|
|
4
|
+
body:
|
|
5
|
+
- type: markdown
|
|
6
|
+
attributes:
|
|
7
|
+
value: |
|
|
8
|
+
Thanks for reporting a bug!
|
|
9
|
+
- type: textarea
|
|
10
|
+
id: description
|
|
11
|
+
attributes:
|
|
12
|
+
label: Bug Description
|
|
13
|
+
description: A clear description of the bug
|
|
14
|
+
validations:
|
|
15
|
+
required: true
|
|
16
|
+
- type: textarea
|
|
17
|
+
id: steps
|
|
18
|
+
attributes:
|
|
19
|
+
label: Steps to Reproduce
|
|
20
|
+
description: |
|
|
21
|
+
1.
|
|
22
|
+
2.
|
|
23
|
+
3.
|
|
24
|
+
validations:
|
|
25
|
+
required: true
|
|
26
|
+
- type: textarea
|
|
27
|
+
id: expected
|
|
28
|
+
attributes:
|
|
29
|
+
label: Expected Behavior
|
|
30
|
+
validations:
|
|
31
|
+
required: true
|
|
32
|
+
- type: textarea
|
|
33
|
+
id: actual
|
|
34
|
+
attributes:
|
|
35
|
+
label: Actual Behavior
|
|
36
|
+
validations:
|
|
37
|
+
required: true
|
|
38
|
+
- type: input
|
|
39
|
+
id: version
|
|
40
|
+
attributes:
|
|
41
|
+
label: Version
|
|
42
|
+
description: Output of `open-knowledge --version`
|
|
43
|
+
- type: dropdown
|
|
44
|
+
id: os
|
|
45
|
+
attributes:
|
|
46
|
+
label: Operating System
|
|
47
|
+
options:
|
|
48
|
+
- macOS
|
|
49
|
+
- Linux
|
|
50
|
+
- Windows
|
|
51
|
+
- Other
|
|
52
|
+
- type: dropdown
|
|
53
|
+
id: runtime
|
|
54
|
+
attributes:
|
|
55
|
+
label: Runtime
|
|
56
|
+
options:
|
|
57
|
+
- Bun
|
|
58
|
+
- Node.js
|
|
59
|
+
- Other
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Feature Request
|
|
2
|
+
description: Suggest a new feature or improvement
|
|
3
|
+
labels: [enhancement]
|
|
4
|
+
body:
|
|
5
|
+
- type: markdown
|
|
6
|
+
attributes:
|
|
7
|
+
value: |
|
|
8
|
+
Ideas are welcome! The best features solve real problems for AI agents and CLI users.
|
|
9
|
+
- type: textarea
|
|
10
|
+
id: problem
|
|
11
|
+
attributes:
|
|
12
|
+
label: Problem or Motivation
|
|
13
|
+
description: What problem does this solve?
|
|
14
|
+
validations:
|
|
15
|
+
required: true
|
|
16
|
+
- type: textarea
|
|
17
|
+
id: solution
|
|
18
|
+
attributes:
|
|
19
|
+
label: Proposed Solution
|
|
20
|
+
description: How would you like it to work?
|
|
21
|
+
validations:
|
|
22
|
+
required: true
|
|
23
|
+
- type: textarea
|
|
24
|
+
id: alternatives
|
|
25
|
+
attributes:
|
|
26
|
+
label: Alternatives Considered
|
|
27
|
+
description: Any other approaches you considered?
|
|
28
|
+
- type: checkboxes
|
|
29
|
+
id: willingness
|
|
30
|
+
attributes:
|
|
31
|
+
label: Willingness to Implement
|
|
32
|
+
options:
|
|
33
|
+
- label: I am willing to implement this feature
|
|
34
|
+
- label: I can help test a PR for this feature
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
## Summary
|
|
2
|
+
|
|
3
|
+
<!-- 1-3 sentence description of the change -->
|
|
4
|
+
|
|
5
|
+
## Motivation
|
|
6
|
+
|
|
7
|
+
<!-- Why is this change needed? What problem does it solve? -->
|
|
8
|
+
|
|
9
|
+
## Changes
|
|
10
|
+
|
|
11
|
+
<!-- Bulleted list of what was changed -->
|
|
12
|
+
|
|
13
|
+
## Testing
|
|
14
|
+
|
|
15
|
+
<!-- How was this tested? -->
|
|
16
|
+
|
|
17
|
+
## Checklist
|
|
18
|
+
|
|
19
|
+
- [ ] Tests added / updated
|
|
20
|
+
- [ ] Documentation updated (if needed)
|
|
21
|
+
- [ ] `bun test` passes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
os: [ubuntu-latest, macos-latest]
|
|
14
|
+
runtime: [bun, node]
|
|
15
|
+
runs-on: ${{ matrix.os }}
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Setup Bun
|
|
20
|
+
if: matrix.runtime == 'bun'
|
|
21
|
+
uses: oven-sh/setup-bun@v2
|
|
22
|
+
with:
|
|
23
|
+
bun-version: latest
|
|
24
|
+
|
|
25
|
+
- name: Setup Node
|
|
26
|
+
if: matrix.runtime == 'node'
|
|
27
|
+
uses: actions/setup-node@v4
|
|
28
|
+
with:
|
|
29
|
+
node-version: latest
|
|
30
|
+
|
|
31
|
+
- name: Install dependencies
|
|
32
|
+
run: bun install
|
|
33
|
+
|
|
34
|
+
- name: Run tests
|
|
35
|
+
run: bun test
|
|
36
|
+
|
|
37
|
+
test-matrix:
|
|
38
|
+
strategy:
|
|
39
|
+
matrix:
|
|
40
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
41
|
+
runtime: [bun]
|
|
42
|
+
runs-on: ${{ matrix.os }}
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/checkout@v4
|
|
45
|
+
- uses: oven-sh/setup-bun@v2
|
|
46
|
+
with:
|
|
47
|
+
bun-version: latest
|
|
48
|
+
- run: bun install
|
|
49
|
+
- run: bun test
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
## Our Standards
|
|
8
|
+
|
|
9
|
+
Examples of behavior that contributes to a positive environment:
|
|
10
|
+
|
|
11
|
+
* Using welcoming and inclusive language
|
|
12
|
+
* Being respectful of differing viewpoints and experiences
|
|
13
|
+
* Gracefully accepting constructive criticism
|
|
14
|
+
* Focusing on what is best for the community
|
|
15
|
+
* Showing empathy towards other community members
|
|
16
|
+
|
|
17
|
+
Examples of unacceptable behavior:
|
|
18
|
+
|
|
19
|
+
* The use of sexualized language or imagery and unwelcome sexual attention
|
|
20
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
21
|
+
* Public or private harassment
|
|
22
|
+
* Publishing others' private information without explicit permission
|
|
23
|
+
* Other conduct which could reasonably be considered inappropriate
|
|
24
|
+
|
|
25
|
+
## Enforcement
|
|
26
|
+
|
|
27
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate.
|
|
28
|
+
|
|
29
|
+
## Attribution
|
|
30
|
+
|
|
31
|
+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), version 2.1.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Contributing to open-knowledge
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing!
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Clone the repo
|
|
9
|
+
git clone https://github.com/hasna/knowledge.git
|
|
10
|
+
cd knowledge
|
|
11
|
+
|
|
12
|
+
# Install dependencies (Bun)
|
|
13
|
+
bun install
|
|
14
|
+
|
|
15
|
+
# Run tests
|
|
16
|
+
bun test
|
|
17
|
+
|
|
18
|
+
# Run a specific test file
|
|
19
|
+
bun test tests/cli.test.ts
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Project Structure
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
knowledge/
|
|
26
|
+
├── src/
|
|
27
|
+
│ ├── cli.js # CLI entry point, argument parsing, commands
|
|
28
|
+
│ └── store.js # Persistent store, file locking, ID generation
|
|
29
|
+
├── tests/
|
|
30
|
+
│ └── cli.test.ts # Integration tests using Bun.test
|
|
31
|
+
├── package.json
|
|
32
|
+
└── LICENSE
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Design Principles
|
|
36
|
+
|
|
37
|
+
**Agent-friendly first**: every output should be parseable by an LLM. Prefer `--json` for structured data. Keep error messages actionable.
|
|
38
|
+
|
|
39
|
+
**Minimal dependencies**: keep the dependency footprint small. The store is a plain JSON file.
|
|
40
|
+
|
|
41
|
+
**Safe by default**: destructive operations require explicit confirmation flags (`--yes`).
|
|
42
|
+
|
|
43
|
+
**Concurrent-safe**: all store mutations go through `withLock()`. Do not bypass it.
|
|
44
|
+
|
|
45
|
+
## Commit Conventions
|
|
46
|
+
|
|
47
|
+
Use [Conventional Commits](https://www.conventionalcommits.org/):
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
feat(cli): add --tag filter on list command
|
|
51
|
+
fix(store): handle empty store file gracefully
|
|
52
|
+
docs(readme): add installation instructions
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Types: `feat`, `fix`, `docs`, `chore`, `refactor`, `test`
|
|
56
|
+
|
|
57
|
+
## Pull Request Process
|
|
58
|
+
|
|
59
|
+
1. Fork the repo and create a branch from `main`.
|
|
60
|
+
2. Add tests for new functionality.
|
|
61
|
+
3. Ensure all tests pass: `bun test`.
|
|
62
|
+
4. Keep commits atomic and well-described.
|
|
63
|
+
5. Open a PR with a clear description of the change and motivation.
|
|
64
|
+
|
|
65
|
+
## Code Style
|
|
66
|
+
|
|
67
|
+
- 2-space indentation
|
|
68
|
+
- `for` loops over array methods where performance matters
|
|
69
|
+
- Descriptive variable names
|
|
70
|
+
- No unnecessary dependencies
|
|
71
|
+
|
|
72
|
+
## Reporting Issues
|
|
73
|
+
|
|
74
|
+
- Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.yml)
|
|
75
|
+
- Search existing issues first
|
|
76
|
+
- Include: Node/Bun version, OS, steps to reproduce, expected vs actual
|
|
77
|
+
|
|
78
|
+
## Suggesting Features
|
|
79
|
+
|
|
80
|
+
Open a [feature request issue](.github/ISSUE_TEMPLATE/feature_request.yml) describing:
|
|
81
|
+
- The problem you're solving
|
|
82
|
+
- How you envision the solution
|
|
83
|
+
- Whether you're willing to implement it
|
package/FUNDING.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
github: hasna
|
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# open-knowledge
|
|
2
|
+
|
|
3
|
+
> Agent-friendly local knowledge CLI with JSON output, pagination, and safe destructive actions.
|
|
4
|
+
|
|
5
|
+
[](https://npm.im/@hasna/knowledge)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](.github/workflows/ci.yml)
|
|
8
|
+
|
|
9
|
+
A flat key-value knowledge store designed for AI agents. Stores notes with titles, content, source URLs, and tags. Works with Bun and Node.js.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Bun
|
|
15
|
+
bun add -g @hasna/knowledge
|
|
16
|
+
|
|
17
|
+
# npm
|
|
18
|
+
npm install -g @hasna/knowledge
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or run directly:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bun x @hasna/knowledge add "My Note" "Some content"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Add a note
|
|
31
|
+
open-knowledge add "Rust ownership" "Every value has exactly one owner"
|
|
32
|
+
|
|
33
|
+
# List all notes
|
|
34
|
+
open-knowledge list
|
|
35
|
+
|
|
36
|
+
# List with search
|
|
37
|
+
open-knowledge list --search ownership
|
|
38
|
+
|
|
39
|
+
# List notes tagged "rust"
|
|
40
|
+
open-knowledge list --tag rust
|
|
41
|
+
|
|
42
|
+
# Get a note
|
|
43
|
+
open-knowledge get --id <id>
|
|
44
|
+
|
|
45
|
+
# Update a note
|
|
46
|
+
open-knowledge update --id <id> --title "Rust ownership model"
|
|
47
|
+
|
|
48
|
+
# Delete a note (requires --yes)
|
|
49
|
+
open-knowledge delete --id <id> --yes
|
|
50
|
+
|
|
51
|
+
# Export all notes as JSONL
|
|
52
|
+
open-knowledge export --format jsonl
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Commands
|
|
56
|
+
|
|
57
|
+
### add
|
|
58
|
+
```bash
|
|
59
|
+
open-knowledge add <title> <content> [--url <url>] [-t <tag>]
|
|
60
|
+
```
|
|
61
|
+
Add a new knowledge item.
|
|
62
|
+
|
|
63
|
+
### list
|
|
64
|
+
```bash
|
|
65
|
+
open-knowledge list|ls [options]
|
|
66
|
+
```
|
|
67
|
+
List items with pagination, search, and tag filtering.
|
|
68
|
+
|
|
69
|
+
| Flag | Description |
|
|
70
|
+
|------|-------------|
|
|
71
|
+
| `-p, --page <n>` | Page number (default: 1) |
|
|
72
|
+
| `-l, --limit <n>` | Items per page (default: 20) |
|
|
73
|
+
| `-s, --search <text>` | Filter by title or content |
|
|
74
|
+
| `-t, --tag <tag>` | Filter by tag |
|
|
75
|
+
| `--sort created\|title` | Sort field (default: created) |
|
|
76
|
+
| `--desc` | Sort descending |
|
|
77
|
+
|
|
78
|
+
### get
|
|
79
|
+
```bash
|
|
80
|
+
open-knowledge get --id <id>
|
|
81
|
+
```
|
|
82
|
+
Retrieve a single item by ID.
|
|
83
|
+
|
|
84
|
+
### update
|
|
85
|
+
```bash
|
|
86
|
+
open-knowledge update|edit --id <id> [options]
|
|
87
|
+
```
|
|
88
|
+
Update an existing item.
|
|
89
|
+
|
|
90
|
+
| Flag | Description |
|
|
91
|
+
|------|-------------|
|
|
92
|
+
| `--title <title>` | New title |
|
|
93
|
+
| `--content <content>` | New content |
|
|
94
|
+
| `--url <url>` | New source URL |
|
|
95
|
+
| `-t, --tag <tag>` | Add a tag |
|
|
96
|
+
|
|
97
|
+
### delete
|
|
98
|
+
```bash
|
|
99
|
+
open-knowledge delete|rm --id <id> --yes
|
|
100
|
+
```
|
|
101
|
+
Delete an item. Requires `--yes` to confirm.
|
|
102
|
+
|
|
103
|
+
### export
|
|
104
|
+
```bash
|
|
105
|
+
open-knowledge export [--format jsonl]
|
|
106
|
+
```
|
|
107
|
+
Export all items. Use `--format jsonl` for newline-delimited JSON.
|
|
108
|
+
|
|
109
|
+
### help
|
|
110
|
+
```bash
|
|
111
|
+
open-knowledge help [command]
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Global Options
|
|
115
|
+
|
|
116
|
+
| Flag | Description |
|
|
117
|
+
|------|-------------|
|
|
118
|
+
| `--json` | Output raw JSON |
|
|
119
|
+
| `--store <path>` | Override store path |
|
|
120
|
+
| `--version, -v` | Show version |
|
|
121
|
+
| `--help, -h` | Show help |
|
|
122
|
+
|
|
123
|
+
## Store Location
|
|
124
|
+
|
|
125
|
+
Default store: `~/.open-knowledge/db.json`
|
|
126
|
+
|
|
127
|
+
Override with `--store <path>` or set `OPEN_KNOWLEDGE_STORE` env var.
|
|
128
|
+
|
|
129
|
+
## JSON Output
|
|
130
|
+
|
|
131
|
+
Every command returns structured JSON when `--json` is passed:
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"ok": true,
|
|
136
|
+
"item": { "id": "...", "title": "...", "content": "...", "url": null, "tags": [], "created_at": "...", "updated_at": "..." }
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Agent-Friendly Design
|
|
141
|
+
|
|
142
|
+
- **JSON-only mode**: `--json` flag for easy parsing by LLMs
|
|
143
|
+
- **Idempotent IDs**: each item gets a stable unique ID
|
|
144
|
+
- **Safe deletes**: `--yes` flag required; no accidental deletions
|
|
145
|
+
- **Concurrent-safe**: file locking prevents corruption from parallel agents
|
|
146
|
+
- **Scriptable**: works in pipelines, CI, and any automation tool
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported Versions
|
|
4
|
+
|
|
5
|
+
| Version | Supported |
|
|
6
|
+
| ------- | ------------------ |
|
|
7
|
+
| 0.1.x | :white_check_mark: |
|
|
8
|
+
|
|
9
|
+
## Reporting a Vulnerability
|
|
10
|
+
|
|
11
|
+
If you discover a security vulnerability, please report it responsibly.
|
|
12
|
+
|
|
13
|
+
**Do not open a public GitHub issue** for security vulnerabilities.
|
|
14
|
+
|
|
15
|
+
Please send details privately:
|
|
16
|
+
|
|
17
|
+
1. **Email**: Send to the maintainer directly via GitHub.
|
|
18
|
+
2. **GitHub Security Advisories**: Use the [Security Advisories](https://github.com/hasna/knowledge/security/advisories/new) feature to report privately.
|
|
19
|
+
|
|
20
|
+
Include in your report:
|
|
21
|
+
- Description of the vulnerability
|
|
22
|
+
- Steps to reproduce
|
|
23
|
+
- Potential impact
|
|
24
|
+
- Any suggested fixes (optional)
|
|
25
|
+
|
|
26
|
+
## Response Timeline
|
|
27
|
+
|
|
28
|
+
- **Acknowledgment**: within 48 hours
|
|
29
|
+
- **Initial assessment**: within 5 days
|
|
30
|
+
- **Fix timeline**: depends on severity; critical issues are addressed immediately
|
|
31
|
+
|
|
32
|
+
## Scope
|
|
33
|
+
|
|
34
|
+
This project stores data in a local JSON file (`~/.open-knowledge/db.json` by default). Security considerations:
|
|
35
|
+
|
|
36
|
+
- Store file permissions should be restricted to the owner
|
|
37
|
+
- No network access or remote code execution
|
|
38
|
+
- No authentication (local CLI tool)
|
|
39
|
+
- Encryption of the store file is not currently implemented
|